Version 2.15.0-173.0.dev
Merge commit '4f80522fe4ddd9a043aec5b70715021bc47f0cfd' into 'dev'
diff --git a/benchmarks/SDKArtifactSizes/dart/SDKArtifactSizes.dart b/benchmarks/SDKArtifactSizes/dart/SDKArtifactSizes.dart
index 7deaa33..b7c18d1 100644
--- a/benchmarks/SDKArtifactSizes/dart/SDKArtifactSizes.dart
+++ b/benchmarks/SDKArtifactSizes/dart/SDKArtifactSizes.dart
@@ -24,7 +24,6 @@
'dartdev',
'dartdevc',
'dartdoc',
- 'dartfmt',
'dds',
'frontend_server',
'gen_kernel',
diff --git a/benchmarks/SDKArtifactSizes/dart2/SDKArtifactSizes.dart b/benchmarks/SDKArtifactSizes/dart2/SDKArtifactSizes.dart
index 71e5a48..f207e3a 100644
--- a/benchmarks/SDKArtifactSizes/dart2/SDKArtifactSizes.dart
+++ b/benchmarks/SDKArtifactSizes/dart2/SDKArtifactSizes.dart
@@ -26,7 +26,6 @@
'dartdev',
'dartdevc',
'dartdoc',
- 'dartfmt',
'dds',
'frontend_server',
'gen_kernel',
diff --git a/pkg/_fe_analyzer_shared/pubspec.yaml b/pkg/_fe_analyzer_shared/pubspec.yaml
index 8ce5731..8d97c49 100644
--- a/pkg/_fe_analyzer_shared/pubspec.yaml
+++ b/pkg/_fe_analyzer_shared/pubspec.yaml
@@ -1,5 +1,5 @@
name: _fe_analyzer_shared
-version: 26.0.0
+version: 27.0.0
description: Logic that is shared between the front_end and analyzer packages.
homepage: https://github.com/dart-lang/sdk/tree/master/pkg/_fe_analyzer_shared
diff --git a/pkg/analyzer/CHANGELOG.md b/pkg/analyzer/CHANGELOG.md
index dd484df..7007543 100644
--- a/pkg/analyzer/CHANGELOG.md
+++ b/pkg/analyzer/CHANGELOG.md
@@ -1,4 +1,4 @@
-## 2.4.0-dev
+## 2.4.0
* Deprecated `ResourceProvider.getModificationTimes()`.
* Deprecated `MemoryResourceProvider.newDummyLink()`.
* Deprecated `MemoryResourceProvider.updateFile()`.
diff --git a/pkg/analyzer/lib/src/analysis_options/error/option_codes.dart b/pkg/analyzer/lib/src/analysis_options/error/option_codes.dart
index 33ea055..56ca27b 100644
--- a/pkg/analyzer/lib/src/analysis_options/error/option_codes.dart
+++ b/pkg/analyzer/lib/src/analysis_options/error/option_codes.dart
@@ -2,214 +2,4 @@
// 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.
-import 'package:analyzer/error/error.dart';
-
-/// The error codes used for errors in analysis options files. The convention
-/// for this class is for the name of the error code to indicate the problem
-/// that caused the error to be generated and for the error message to explain
-/// what is wrong and, when appropriate, how the problem can be corrected.
-class AnalysisOptionsErrorCode extends ErrorCode {
- /// An error code indicating that there is a syntactic error in the included
- /// file.
- ///
- /// Parameters:
- /// 0: the path of the file containing the error
- /// 1: the starting offset of the text in the file that contains the error
- /// 2: the ending offset of the text in the file that contains the error
- /// 3: the error message
- static const AnalysisOptionsErrorCode INCLUDED_FILE_PARSE_ERROR =
- AnalysisOptionsErrorCode(
- 'INCLUDED_FILE_PARSE_ERROR', '{3} in {0}({1}..{2})');
-
- /// An error code indicating that there is a syntactic error in the file.
- ///
- /// Parameters:
- /// 0: the error message from the parse error
- static const AnalysisOptionsErrorCode PARSE_ERROR =
- AnalysisOptionsErrorCode('PARSE_ERROR', '{0}');
-
- /// Initialize a newly created error code to have the given [name].
- const AnalysisOptionsErrorCode(String name, String message,
- {String? correction})
- : super(
- correction: correction,
- message: message,
- name: name,
- uniqueName: 'AnalysisOptionsErrorCode.$name',
- );
-
- @override
- ErrorSeverity get errorSeverity => ErrorSeverity.ERROR;
-
- @override
- ErrorType get type => ErrorType.COMPILE_TIME_ERROR;
-}
-
-class AnalysisOptionsHintCode extends ErrorCode {
- /// An error code indicating that the enablePreviewDart2 setting is
- /// deprecated.
- static const AnalysisOptionsHintCode PREVIEW_DART_2_SETTING_DEPRECATED =
- AnalysisOptionsHintCode('PREVIEW_DART_2_SETTING_DEPRECATED',
- "The 'enablePreviewDart2' setting is deprecated.",
- correction: "It is no longer necessary to explicitly enable Dart 2.");
-
- /// An error code indicating that strong-mode: true is deprecated.
- static const AnalysisOptionsHintCode STRONG_MODE_SETTING_DEPRECATED =
- AnalysisOptionsHintCode('STRONG_MODE_SETTING_DEPRECATED',
- "The 'strong-mode: true' setting is deprecated.",
- correction:
- "It is no longer necessary to explicitly enable strong mode.");
-
- /// An error code indicating that the enablePreviewDart2 setting is
- /// deprecated.
- static const AnalysisOptionsHintCode SUPER_MIXINS_SETTING_DEPRECATED =
- AnalysisOptionsHintCode('SUPER_MIXINS_SETTING_DEPRECATED',
- "The 'enableSuperMixins' setting is deprecated.",
- correction:
- "Support has been added to the language for 'mixin' based "
- 'mixins.');
-
- /// Initialize a newly created hint code to have the given [name].
- const AnalysisOptionsHintCode(String name, String message,
- {String? correction})
- : super(
- correction: correction,
- message: message,
- name: name,
- uniqueName: 'AnalysisOptionsHintCode.$name',
- );
-
- @override
- ErrorSeverity get errorSeverity => ErrorSeverity.INFO;
-
- @override
- ErrorType get type => ErrorType.HINT;
-}
-
-/// The error codes used for warnings in analysis options files. The convention
-/// for this class is for the name of the error code to indicate the problem
-/// that caused the error to be generated and for the error message to explain
-/// what is wrong and, when appropriate, how the problem can be corrected.
-class AnalysisOptionsWarningCode extends ErrorCode {
- /// An error code indicating that the given option is deprecated.
- static const AnalysisOptionsWarningCode ANALYSIS_OPTION_DEPRECATED =
- AnalysisOptionsWarningCode('ANALYSIS_OPTION_DEPRECATED',
- "The option '{0}' is no longer supported.");
-
- /// An error code indicating a specified include file could not be found.
- ///
- /// Parameters:
- /// 0: the uri of the file to be included
- /// 1: the path of the file containing the include directive
- /// 2: the path of the context being analyzed
- static const AnalysisOptionsWarningCode INCLUDE_FILE_NOT_FOUND =
- AnalysisOptionsWarningCode('INCLUDE_FILE_NOT_FOUND',
- "The include file '{0}' in '{1}' can't be found when analyzing '{2}'.");
-
- /// An error code indicating a specified include file has a warning.
- ///
- /// Parameters:
- /// 0: the path of the file containing the warnings
- /// 1: the starting offset of the text in the file that contains the warning
- /// 2: the ending offset of the text in the file that contains the warning
- /// 3: the warning message
- static const AnalysisOptionsWarningCode INCLUDED_FILE_WARNING =
- AnalysisOptionsWarningCode('INCLUDED_FILE_WARNING',
- "Warning in the included options file {0}({1}..{2}): {3}");
-
- /// An error code indicating that a plugin is being configured with an invalid
- /// value for an option and a detail message is provided.
- static const AnalysisOptionsWarningCode INVALID_OPTION =
- AnalysisOptionsWarningCode(
- 'INVALID_OPTION', "Invalid option specified for '{0}': {1}");
-
- /// An error code indicating an invalid format for an options file section.
- ///
- /// Parameters:
- /// 0: the section name
- static const AnalysisOptionsWarningCode INVALID_SECTION_FORMAT =
- AnalysisOptionsWarningCode(
- 'INVALID_SECTION_FORMAT', "Invalid format for the '{0}' section.");
-
- /// An error code indicating that strong-mode: false is has been removed.
- static const AnalysisOptionsWarningCode SPEC_MODE_REMOVED =
- AnalysisOptionsWarningCode('SPEC_MODE_REMOVED',
- "The option 'strong-mode: false' is no longer supported.",
- correction:
- "It's recommended to remove the 'strong-mode:' setting (and make "
- "your code Dart 2 compliant).");
-
- /// An error code indicating that an unrecognized error code is being used to
- /// specify an error filter.
- ///
- /// Parameters:
- /// 0: the unrecognized error code
- static const AnalysisOptionsWarningCode UNRECOGNIZED_ERROR_CODE =
- AnalysisOptionsWarningCode(
- 'UNRECOGNIZED_ERROR_CODE', "'{0}' isn't a recognized error code.");
-
- /// An error code indicating that a plugin is being configured with an
- /// unsupported option where there is just one legal value.
- ///
- /// Parameters:
- /// 0: the plugin name
- /// 1: the unsupported option key
- /// 2: the legal value
- static const AnalysisOptionsWarningCode UNSUPPORTED_OPTION_WITH_LEGAL_VALUE =
- AnalysisOptionsWarningCode(
- 'UNSUPPORTED_OPTION_WITH_LEGAL_VALUE',
- "The option '{1}' isn't supported by '{0}'. "
- "Try using the only supported option: '{2}'.");
-
- /// An error code indicating that a plugin is being configured with an
- /// unsupported option and legal options are provided.
- ///
- /// Parameters:
- /// 0: the plugin name
- /// 1: the unsupported option key
- /// 2: legal values
- static const AnalysisOptionsWarningCode UNSUPPORTED_OPTION_WITH_LEGAL_VALUES =
- AnalysisOptionsWarningCode('UNSUPPORTED_OPTION_WITH_LEGAL_VALUES',
- "The option '{1}' isn't supported by '{0}'.",
- correction: "Try using one of the supported options: {2}.");
-
- /// An error code indicating that a plugin is being configured with an
- /// unsupported option and legal options are provided.
- ///
- /// Parameters:
- /// 0: the plugin name
- /// 1: the unsupported option key
- static const AnalysisOptionsWarningCode UNSUPPORTED_OPTION_WITHOUT_VALUES =
- AnalysisOptionsWarningCode(
- 'UNSUPPORTED_OPTION_WITHOUT_VALUES',
- "The option '{1}' isn't supported by '{0}'.",
- );
-
- /// An error code indicating that an option entry is being configured with an
- /// unsupported value.
- ///
- /// Parameters:
- /// 0: the option name
- /// 1: the unsupported value
- /// 2: legal values
- static const AnalysisOptionsWarningCode UNSUPPORTED_VALUE =
- AnalysisOptionsWarningCode(
- 'UNSUPPORTED_VALUE', "The value '{1}' isn't supported by '{0}'.",
- correction: "Try using one of the supported options: {2}.");
-
- /// Initialize a newly created warning code to have the given [name].
- const AnalysisOptionsWarningCode(String name, String message,
- {String? correction})
- : super(
- correction: correction,
- message: message,
- name: name,
- uniqueName: 'AnalysisOptionsWarningCode.$name',
- );
-
- @override
- ErrorSeverity get errorSeverity => ErrorSeverity.WARNING;
-
- @override
- ErrorType get type => ErrorType.STATIC_WARNING;
-}
+export 'package:analyzer/src/analysis_options/error/option_codes.g.dart';
diff --git a/pkg/analyzer/lib/src/analysis_options/error/option_codes.g.dart b/pkg/analyzer/lib/src/analysis_options/error/option_codes.g.dart
new file mode 100644
index 0000000..4c95c70
--- /dev/null
+++ b/pkg/analyzer/lib/src/analysis_options/error/option_codes.g.dart
@@ -0,0 +1,294 @@
+// 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";
+
+// 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 AnalysisOptionsErrorCode extends ErrorCode {
+ /**
+ * An error code indicating that there is a syntactic error in the included
+ * file.
+ *
+ * Parameters:
+ * 0: the path of the file containing the error
+ * 1: the starting offset of the text in the file that contains the error
+ * 2: the ending offset of the text in the file that contains the error
+ * 3: the error message
+ */
+ static const AnalysisOptionsErrorCode INCLUDED_FILE_PARSE_ERROR =
+ AnalysisOptionsErrorCode(
+ 'INCLUDED_FILE_PARSE_ERROR',
+ "{3} in {0}({1}..{2})",
+ );
+
+ /**
+ * An error code indicating that there is a syntactic error in the file.
+ *
+ * Parameters:
+ * 0: the error message from the parse error
+ */
+ static const AnalysisOptionsErrorCode PARSE_ERROR = AnalysisOptionsErrorCode(
+ 'PARSE_ERROR',
+ "{0}",
+ );
+
+ /// Initialize a newly created error code to have the given [name].
+ const AnalysisOptionsErrorCode(
+ String name,
+ String message, {
+ String? correction,
+ bool hasPublishedDocs = false,
+ bool isUnresolvedIdentifier = false,
+ String? uniqueName,
+ }) : super(
+ correction: correction,
+ hasPublishedDocs: hasPublishedDocs,
+ isUnresolvedIdentifier: isUnresolvedIdentifier,
+ message: message,
+ name: name,
+ uniqueName: 'AnalysisOptionsErrorCode.${uniqueName ?? name}',
+ );
+
+ @override
+ ErrorSeverity get errorSeverity => ErrorSeverity.ERROR;
+
+ @override
+ ErrorType get type => ErrorType.COMPILE_TIME_ERROR;
+}
+
+class AnalysisOptionsHintCode extends ErrorCode {
+ /**
+ * An error code indicating that the enablePreviewDart2 setting is
+ * deprecated.
+ */
+ static const AnalysisOptionsHintCode PREVIEW_DART_2_SETTING_DEPRECATED =
+ AnalysisOptionsHintCode(
+ 'PREVIEW_DART_2_SETTING_DEPRECATED',
+ "The 'enablePreviewDart2' setting is deprecated.",
+ correction: "It is no longer necessary to explicitly enable Dart 2.",
+ );
+
+ /**
+ * An error code indicating that strong-mode: true is deprecated.
+ */
+ static const AnalysisOptionsHintCode STRONG_MODE_SETTING_DEPRECATED =
+ AnalysisOptionsHintCode(
+ 'STRONG_MODE_SETTING_DEPRECATED',
+ "The 'strong-mode: true' setting is deprecated.",
+ correction: "It is no longer necessary to explicitly enable strong mode.",
+ );
+
+ /**
+ * An error code indicating that the enablePreviewDart2 setting is
+ * deprecated.
+ */
+ static const AnalysisOptionsHintCode SUPER_MIXINS_SETTING_DEPRECATED =
+ AnalysisOptionsHintCode(
+ 'SUPER_MIXINS_SETTING_DEPRECATED',
+ "The 'enableSuperMixins' setting is deprecated.",
+ correction:
+ "Support has been added to the language for 'mixin' based mixins.",
+ );
+
+ /// Initialize a newly created error code to have the given [name].
+ const AnalysisOptionsHintCode(
+ String name,
+ String message, {
+ String? correction,
+ bool hasPublishedDocs = false,
+ bool isUnresolvedIdentifier = false,
+ String? uniqueName,
+ }) : super(
+ correction: correction,
+ hasPublishedDocs: hasPublishedDocs,
+ isUnresolvedIdentifier: isUnresolvedIdentifier,
+ message: message,
+ name: name,
+ uniqueName: 'AnalysisOptionsHintCode.${uniqueName ?? name}',
+ );
+
+ @override
+ ErrorSeverity get errorSeverity => ErrorSeverity.INFO;
+
+ @override
+ ErrorType get type => ErrorType.HINT;
+}
+
+class AnalysisOptionsWarningCode extends ErrorCode {
+ /**
+ * An error code indicating that the given option is deprecated.
+ */
+ static const AnalysisOptionsWarningCode ANALYSIS_OPTION_DEPRECATED =
+ AnalysisOptionsWarningCode(
+ 'ANALYSIS_OPTION_DEPRECATED',
+ "The option '{0}' is no longer supported.",
+ );
+
+ /**
+ * An error code indicating a specified include file has a warning.
+ *
+ * Parameters:
+ * 0: the path of the file containing the warnings
+ * 1: the starting offset of the text in the file that contains the warning
+ * 2: the ending offset of the text in the file that contains the warning
+ * 3: the warning message
+ */
+ static const AnalysisOptionsWarningCode INCLUDED_FILE_WARNING =
+ AnalysisOptionsWarningCode(
+ 'INCLUDED_FILE_WARNING',
+ "Warning in the included options file {0}({1}..{2}): {3}",
+ );
+
+ /**
+ * An error code indicating a specified include file could not be found.
+ *
+ * Parameters:
+ * 0: the uri of the file to be included
+ * 1: the path of the file containing the include directive
+ * 2: the path of the context being analyzed
+ */
+ static const AnalysisOptionsWarningCode INCLUDE_FILE_NOT_FOUND =
+ AnalysisOptionsWarningCode(
+ 'INCLUDE_FILE_NOT_FOUND',
+ "The include file '{0}' in '{1}' can't be found when analyzing '{2}'.",
+ );
+
+ /**
+ * An error code indicating that a plugin is being configured with an invalid
+ * value for an option and a detail message is provided.
+ */
+ static const AnalysisOptionsWarningCode INVALID_OPTION =
+ AnalysisOptionsWarningCode(
+ 'INVALID_OPTION',
+ "Invalid option specified for '{0}': {1}",
+ );
+
+ /**
+ * An error code indicating an invalid format for an options file section.
+ *
+ * Parameters:
+ * 0: the section name
+ */
+ static const AnalysisOptionsWarningCode INVALID_SECTION_FORMAT =
+ AnalysisOptionsWarningCode(
+ 'INVALID_SECTION_FORMAT',
+ "Invalid format for the '{0}' section.",
+ );
+
+ /**
+ * An error code indicating that strong-mode: false is has been removed.
+ */
+ static const AnalysisOptionsWarningCode SPEC_MODE_REMOVED =
+ AnalysisOptionsWarningCode(
+ 'SPEC_MODE_REMOVED',
+ "The option 'strong-mode: false' is no longer supported.",
+ correction:
+ "It's recommended to remove the 'strong-mode:' setting (and make your code Dart 2 compliant).",
+ );
+
+ /**
+ * An error code indicating that an unrecognized error code is being used to
+ * specify an error filter.
+ *
+ * Parameters:
+ * 0: the unrecognized error code
+ */
+ static const AnalysisOptionsWarningCode UNRECOGNIZED_ERROR_CODE =
+ AnalysisOptionsWarningCode(
+ 'UNRECOGNIZED_ERROR_CODE',
+ "'{0}' isn't a recognized error code.",
+ );
+
+ /**
+ * An error code indicating that a plugin is being configured with an
+ * unsupported option and legal options are provided.
+ *
+ * Parameters:
+ * 0: the plugin name
+ * 1: the unsupported option key
+ */
+ static const AnalysisOptionsWarningCode UNSUPPORTED_OPTION_WITHOUT_VALUES =
+ AnalysisOptionsWarningCode(
+ 'UNSUPPORTED_OPTION_WITHOUT_VALUES',
+ "The option '{1}' isn't supported by '{0}'.",
+ );
+
+ /**
+ * An error code indicating that a plugin is being configured with an
+ * unsupported option where there is just one legal value.
+ *
+ * Parameters:
+ * 0: the plugin name
+ * 1: the unsupported option key
+ * 2: the legal value
+ */
+ static const AnalysisOptionsWarningCode UNSUPPORTED_OPTION_WITH_LEGAL_VALUE =
+ AnalysisOptionsWarningCode(
+ 'UNSUPPORTED_OPTION_WITH_LEGAL_VALUE',
+ "The option '{1}' isn't supported by '{0}'. Try using the only supported option: '{2}'.",
+ );
+
+ /**
+ * An error code indicating that a plugin is being configured with an
+ * unsupported option and legal options are provided.
+ *
+ * Parameters:
+ * 0: the plugin name
+ * 1: the unsupported option key
+ * 2: legal values
+ */
+ static const AnalysisOptionsWarningCode UNSUPPORTED_OPTION_WITH_LEGAL_VALUES =
+ AnalysisOptionsWarningCode(
+ 'UNSUPPORTED_OPTION_WITH_LEGAL_VALUES',
+ "The option '{1}' isn't supported by '{0}'.",
+ correction: "Try using one of the supported options: {2}.",
+ );
+
+ /**
+ * An error code indicating that an option entry is being configured with an
+ * unsupported value.
+ *
+ * Parameters:
+ * 0: the option name
+ * 1: the unsupported value
+ * 2: legal values
+ */
+ static const AnalysisOptionsWarningCode UNSUPPORTED_VALUE =
+ AnalysisOptionsWarningCode(
+ 'UNSUPPORTED_VALUE',
+ "The value '{1}' isn't supported by '{0}'.",
+ correction: "Try using one of the supported options: {2}.",
+ );
+
+ /// Initialize a newly created error code to have the given [name].
+ const AnalysisOptionsWarningCode(
+ String name,
+ String message, {
+ String? correction,
+ bool hasPublishedDocs = false,
+ bool isUnresolvedIdentifier = false,
+ String? uniqueName,
+ }) : super(
+ correction: correction,
+ hasPublishedDocs: hasPublishedDocs,
+ isUnresolvedIdentifier: isUnresolvedIdentifier,
+ message: message,
+ name: name,
+ uniqueName: 'AnalysisOptionsWarningCode.${uniqueName ?? name}',
+ );
+
+ @override
+ ErrorSeverity get errorSeverity => ErrorSeverity.WARNING;
+
+ @override
+ ErrorType get type => ErrorType.STATIC_WARNING;
+}
diff --git a/pkg/analyzer/lib/src/dart/error/ffi_code.dart b/pkg/analyzer/lib/src/dart/error/ffi_code.dart
index 8896d3e..07984a3 100644
--- a/pkg/analyzer/lib/src/dart/error/ffi_code.dart
+++ b/pkg/analyzer/lib/src/dart/error/ffi_code.dart
@@ -2,414 +2,4 @@
// 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.
-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
-
-/// The diagnostic codes associated with `dart:ffi`.
-class FfiCode extends AnalyzerErrorCode {
- /**
- * No parameters.
- */
- static const FfiCode ANNOTATION_ON_POINTER_FIELD = FfiCode(
- name: 'ANNOTATION_ON_POINTER_FIELD',
- message:
- "Fields in a struct class whose type is 'Pointer' should not have "
- "any annotations.",
- correction: "Try removing the annotation.");
-
- /**
- * Parameters:
- * 0: the name of the argument
- */
- static const FfiCode ARGUMENT_MUST_BE_A_CONSTANT = FfiCode(
- name: 'ARGUMENT_MUST_BE_A_CONSTANT',
- message: "Argument '{0}' must be a constant.",
- correction: "Try replacing the value with a literal or const.");
-
- /**
- * No parameters.
- */
- static const FfiCode CREATION_OF_STRUCT_OR_UNION = FfiCode(
- name: 'CREATION_OF_STRUCT_OR_UNION',
- message: "Subclasses of 'Struct' and 'Union' are backed by native memory, "
- "and can't be instantiated by a generative constructor.",
- correction: "Try allocating it via allocation, or load from a 'Pointer'.",
- );
-
- /**
- * Parameters:
- * 0: the name of the struct class
- */
- static const FfiCode EMPTY_STRUCT = FfiCode(
- name: 'EMPTY_STRUCT',
- message: "Struct '{0}' is empty. Empty structs are undefined behavior.",
- correction: "Try adding a field to '{0}' or use a different Struct.");
-
- /**
- * No parameters.
- */
- static const FfiCode EXTRA_ANNOTATION_ON_STRUCT_FIELD = FfiCode(
- name: 'EXTRA_ANNOTATION_ON_STRUCT_FIELD',
- message: "Fields in a struct class must have exactly one annotation "
- "indicating the native type.",
- correction: "Try removing the extra annotation.");
-
- /**
- * No parameters.
- */
- static const FfiCode EXTRA_SIZE_ANNOTATION_CARRAY = FfiCode(
- name: 'EXTRA_SIZE_ANNOTATION_CARRAY',
- message: "'Array's must have exactly one 'Array' annotation.",
- correction: "Try removing the extra annotation.");
-
- /**
- * No parameters.
- */
- static const FfiCode FFI_NATIVE_ONLY_STATIC = FfiCode(
- name: 'FFI_NATIVE_ONLY_STATIC',
- message: "FfiNative annotations can only be used on static functions.",
- correction: "Change the method to static.");
-
- /**
- * No parameters.
- */
- static const FfiCode FIELD_IN_STRUCT_WITH_INITIALIZER = FfiCode(
- name: 'FIELD_IN_STRUCT_WITH_INITIALIZER',
- message:
- "Fields in subclasses of 'Struct' and 'Union' can't have initializers.",
- correction:
- "Try removing the initializer and marking the field as external.");
-
- /**
- * No parameters.
- */
- static const FfiCode FIELD_INITIALIZER_IN_STRUCT = FfiCode(
- name: 'FIELD_INITIALIZER_IN_STRUCT',
- message:
- "Constructors in subclasses of 'Struct' and 'Union' can't have field "
- "initializers.",
- correction: "Try removing the field initializer and marking the field as"
- " external.");
-
- /**
- * No parameters.
- */
- static const FfiCode FIELD_MUST_BE_EXTERNAL_IN_STRUCT = FfiCode(
- name: 'FIELD_MUST_BE_EXTERNAL_IN_STRUCT',
- message:
- "Fields of 'Struct' and 'Union' subclasses must be marked external.",
- correction: "Try adding the 'external' modifier.");
-
- /**
- * Parameters:
- * 0: the name of the struct class
- */
- static const FfiCode GENERIC_STRUCT_SUBCLASS = FfiCode(
- name: 'GENERIC_STRUCT_SUBCLASS',
- message:
- "The class '{0}' can't extend 'Struct' or 'Union' because it is generic.",
- correction: "Try removing the type parameters from '{0}'.");
-
- /**
- * No parameters.
- */
- static const FfiCode INVALID_EXCEPTION_VALUE = FfiCode(
- name: 'INVALID_EXCEPTION_VALUE',
- message:
- "The method 'Pointer.fromFunction' must not have an exceptional return "
- "value (the second argument) when the return type of the function is "
- "either 'void', 'Handle' or 'Pointer'.",
- correction: "Try removing the exceptional return value.");
-
- /**
- * Parameters:
- * 0: the type of the field
- */
- static const FfiCode INVALID_FIELD_TYPE_IN_STRUCT = FfiCode(
- name: 'INVALID_FIELD_TYPE_IN_STRUCT',
- message:
- "Fields in struct classes can't have the type '{0}'. They can only "
- "be declared as 'int', 'double', 'Array', 'Pointer', or subtype of "
- "'Struct' or 'Union'.",
- correction:
- "Try using 'int', 'double', 'Array', 'Pointer', or subtype of "
- "'Struct' or 'Union'.");
-
- /**
- * No parameters.
- */
- static const FfiCode LEAF_CALL_MUST_NOT_RETURN_HANDLE = FfiCode(
- name: 'LEAF_CALL_MUST_NOT_RETURN_HANDLE',
- message: "FFI leaf call must not return a Handle.",
- correction: "Try changing the return type to primitive or struct.");
-
- /**
- * No parameters.
- */
- static const FfiCode LEAF_CALL_MUST_NOT_TAKE_HANDLE = FfiCode(
- name: 'LEAF_CALL_MUST_NOT_TAKE_HANDLE',
- message: "FFI leaf call must not take arguments of type Handle.",
- correction: "Try changing the argument type to primitive or struct.");
-
- /**
- * No parameters.
- */
- static const FfiCode MISMATCHED_ANNOTATION_ON_STRUCT_FIELD = FfiCode(
- name: 'MISMATCHED_ANNOTATION_ON_STRUCT_FIELD',
- message: "The annotation does not match the declared type of the field.",
- correction: "Try using a different annotation or changing the declared "
- "type to match.");
-
- /**
- * No parameters.
- */
- static const FfiCode MISSING_ANNOTATION_ON_STRUCT_FIELD = FfiCode(
- name: 'MISSING_ANNOTATION_ON_STRUCT_FIELD',
- message:
- "Fields in a struct class must either have the type 'Pointer' or an "
- "annotation indicating the native type.",
- correction: "Try adding an annotation.");
-
- /**
- * No parameters.
- */
- static const FfiCode MISSING_EXCEPTION_VALUE = FfiCode(
- name: 'MISSING_EXCEPTION_VALUE',
- message:
- "The method 'Pointer.fromFunction' must have an exceptional return "
- "value (the second argument) when the return type of the function is "
- "neither 'void', 'Handle' or 'Pointer'.",
- correction: "Try adding an exceptional return value.");
-
- /**
- * Parameters:
- * 0: the type of the field
- */
- static const FfiCode MISSING_FIELD_TYPE_IN_STRUCT = FfiCode(
- name: 'MISSING_FIELD_TYPE_IN_STRUCT',
- message:
- "Fields in struct classes must have an explicitly declared type of "
- "'int', 'double' or 'Pointer'.",
- correction: "Try using 'int', 'double' or 'Pointer'.");
-
- /**
- * No parameters.
- */
- static const FfiCode MISSING_SIZE_ANNOTATION_CARRAY = FfiCode(
- name: 'MISSING_SIZE_ANNOTATION_CARRAY',
- message: "'Array's must have exactly one 'Array' annotation.",
- correction: "Try adding a 'Array' annotation.");
-
- /**
- * Parameters:
- * 0: the type that should be a valid dart:ffi native type.
- * 1: the name of the function whose invocation depends on this relationship
- */
- static const FfiCode MUST_BE_A_NATIVE_FUNCTION_TYPE = FfiCode(
- name: 'MUST_BE_A_NATIVE_FUNCTION_TYPE',
- message:
- "The type '{0}' given to '{1}' must be a valid 'dart:ffi' native "
- "function type.",
- correction: "Try changing the type to only use members for 'dart:ffi'.");
-
- /**
- * Parameters:
- * 0: the type that should be a subtype
- * 1: the supertype that the subtype is compared to
- * 2: the name of the function whose invocation depends on this relationship
- */
- static const FfiCode MUST_BE_A_SUBTYPE = FfiCode(
- name: 'MUST_BE_A_SUBTYPE',
- message: "The type '{0}' must be a subtype of '{1}' for '{2}'.",
- correction: "Try changing one or both of the type arguments.");
-
- /**
- * Parameters:
- * 0: the name of the function, method, or constructor having type arguments
- */
- static const FfiCode NON_CONSTANT_TYPE_ARGUMENT = FfiCode(
- name: 'NON_CONSTANT_TYPE_ARGUMENT',
- message:
- "The type arguments to '{0}' must be compile time constants but type "
- "parameters are not constants.",
- correction: "Try changing the type argument to be a constant type.");
-
- /**
- * Parameters:
- * 0: the type that should be a valid dart:ffi native type.
- */
- static const FfiCode NON_NATIVE_FUNCTION_TYPE_ARGUMENT_TO_POINTER = FfiCode(
- name: 'NON_NATIVE_FUNCTION_TYPE_ARGUMENT_TO_POINTER',
- message: "The type argument for the pointer '{0}' must be a "
- "'NativeFunction' in order to use 'asFunction'.",
- correction: "Try changing the type argument to be a 'NativeFunction'.");
-
- /**
- * No parameters.
- */
- static const FfiCode NON_POSITIVE_ARRAY_DIMENSION = FfiCode(
- name: 'NON_POSITIVE_ARRAY_DIMENSION',
- message: "Array dimensions must be positive numbers.",
- correction: "Try changing the input to a positive number.");
-
- /**
- * Parameters:
- * 0: the type of the field
- */
- static const FfiCode NON_SIZED_TYPE_ARGUMENT = FfiCode(
- name: 'NON_SIZED_TYPE_ARGUMENT',
- message:
- "Type arguments to '{0}' can't have the type '{1}'. They can only "
- "be declared as native integer, 'Float', 'Double', 'Pointer', or "
- "subtype of 'Struct' or 'Union'.",
- correction: "Try using a native integer, 'Float', 'Double', 'Pointer', "
- "or subtype of 'Struct' or 'Union'.");
-
- /**
- * No parameters.
- */
- static const FfiCode PACKED_ANNOTATION = FfiCode(
- name: 'PACKED_ANNOTATION',
- message: "Structs must have at most one 'Packed' annotation.",
- correction: "Try removing extra 'Packed' annotations.");
-
- /**
- * No parameters.
- */
- static const FfiCode PACKED_ANNOTATION_ALIGNMENT = FfiCode(
- name: 'PACKED_ANNOTATION_ALIGNMENT',
- message: "Only packing to 1, 2, 4, 8, and 16 bytes is supported.",
- correction:
- "Try changing the 'Packed' annotation alignment to 1, 2, 4, 8, or 16.");
-
- /**
- * Parameters:
- * 0: the name of the outer struct
- * 1: the name of the struct being nested
- */
- static const FfiCode PACKED_NESTING_NON_PACKED = FfiCode(
- name: 'PACKED_NESTING_NON_PACKED',
- message:
- "Nesting the non-packed or less tightly packed struct '{0}' in a packed struct '{1}' is not supported.",
- correction:
- "Try packing the nested struct or packing the nested struct more tightly.");
-
- /**
- * No parameters.
- */
- static const FfiCode SIZE_ANNOTATION_DIMENSIONS = FfiCode(
- name: 'SIZE_ANNOTATION_DIMENSIONS',
- message:
- "'Array's must have an 'Array' annotation that matches the dimensions.",
- correction: "Try adjusting the arguments in the 'Array' annotation.");
-
- /**
- * Parameters:
- * 0: the name of the subclass
- * 1: the name of the class being extended, implemented, or mixed in
- */
- static const FfiCode SUBTYPE_OF_FFI_CLASS_IN_EXTENDS = FfiCode(
- name: 'SUBTYPE_OF_FFI_CLASS',
- message: "The class '{0}' can't extend '{1}'.",
- correction: "Try extending 'Struct' or 'Union'.",
- uniqueName: 'SUBTYPE_OF_FFI_CLASS_IN_EXTENDS',
- );
-
- /**
- * Parameters:
- * 0: the name of the subclass
- * 1: the name of the class being extended, implemented, or mixed in
- */
- static const FfiCode SUBTYPE_OF_FFI_CLASS_IN_IMPLEMENTS = FfiCode(
- name: 'SUBTYPE_OF_FFI_CLASS',
- message: "The class '{0}' can't implement '{1}'.",
- correction: "Try extending 'Struct' or 'Union'.",
- uniqueName: 'SUBTYPE_OF_FFI_CLASS_IN_IMPLEMENTS',
- );
-
- /**
- * Parameters:
- * 0: the name of the subclass
- * 1: the name of the class being extended, implemented, or mixed in
- */
- static const FfiCode SUBTYPE_OF_FFI_CLASS_IN_WITH = FfiCode(
- name: 'SUBTYPE_OF_FFI_CLASS',
- message: "The class '{0}' can't mix in '{1}'.",
- correction: "Try extending 'Struct' or 'Union'.",
- uniqueName: 'SUBTYPE_OF_FFI_CLASS_IN_WITH',
- );
-
- /**
- * Parameters:
- * 0: the name of the subclass
- * 1: the name of the class being extended, implemented, or mixed in
- */
- static const FfiCode SUBTYPE_OF_STRUCT_CLASS_IN_EXTENDS = FfiCode(
- name: 'SUBTYPE_OF_STRUCT_CLASS',
- message: "The class '{0}' can't extend '{1}' because '{1}' is a subtype of "
- "'Struct' or 'Union'.",
- correction: "Try extending 'Struct' or 'Union' directly.",
- uniqueName: 'SUBTYPE_OF_STRUCT_CLASS_IN_EXTENDS',
- );
-
- /**
- * Parameters:
- * 0: the name of the subclass
- * 1: the name of the class being extended, implemented, or mixed in
- */
- static const FfiCode SUBTYPE_OF_STRUCT_CLASS_IN_IMPLEMENTS = FfiCode(
- name: 'SUBTYPE_OF_STRUCT_CLASS',
- message:
- "The class '{0}' can't implement '{1}' because '{1}' is a subtype of "
- "'Struct' or 'Union'.",
- correction: "Try extending 'Struct' or 'Union' directly.",
- uniqueName: 'SUBTYPE_OF_STRUCT_CLASS_IN_IMPLEMENTS',
- );
-
- /**
- * Parameters:
- * 0: the name of the subclass
- * 1: the name of the class being extended, implemented, or mixed in
- */
- static const FfiCode SUBTYPE_OF_STRUCT_CLASS_IN_WITH = FfiCode(
- name: 'SUBTYPE_OF_STRUCT_CLASS',
- message: "The class '{0}' can't mix in '{1}' because '{1}' is a subtype of "
- "'Struct' or 'Union'.",
- correction: "Try extending 'Struct' or 'Union' directly.",
- uniqueName: 'SUBTYPE_OF_STRUCT_CLASS_IN_WITH',
- );
-
- /// Initialize a newly created error code to have the given [name]. If
- /// [uniqueName] is provided, then it will be used to construct the unique
- /// name for the code, otherwise the name will be used to construct the unique
- /// name.
- ///
- /// The message associated with the error will be created from the given
- /// [message] template. The correction associated with the error will be
- /// created from the given [correction] template.
- ///
- /// If [hasPublishedDocs] is `true` then a URL for the docs will be generated.
- const FfiCode({
- String? correction,
- bool hasPublishedDocs = false,
- required String message,
- required String name,
- String? uniqueName,
- }) : super(
- correction: correction,
- hasPublishedDocs: hasPublishedDocs,
- message: message,
- name: name,
- uniqueName: 'FfiCode.${uniqueName ?? name}',
- );
-
- @override
- ErrorSeverity get errorSeverity => type.severity;
-
- @override
- ErrorType get type => ErrorType.COMPILE_TIME_ERROR;
-}
+export 'package:analyzer/src/dart/error/ffi_code.g.dart';
diff --git a/pkg/analyzer/lib/src/dart/error/ffi_code.g.dart b/pkg/analyzer/lib/src/dart/error/ffi_code.g.dart
new file mode 100644
index 0000000..8edc5cf
--- /dev/null
+++ b/pkg/analyzer/lib/src/dart/error/ffi_code.g.dart
@@ -0,0 +1,404 @@
+// 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 FfiCode extends AnalyzerErrorCode {
+ /**
+ * No parameters.
+ */
+ static const FfiCode ANNOTATION_ON_POINTER_FIELD = FfiCode(
+ 'ANNOTATION_ON_POINTER_FIELD',
+ "Fields in a struct class whose type is 'Pointer' should not have any annotations.",
+ correction: "Try removing the annotation.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the argument
+ */
+ static const FfiCode ARGUMENT_MUST_BE_A_CONSTANT = FfiCode(
+ 'ARGUMENT_MUST_BE_A_CONSTANT',
+ "Argument '{0}' must be a constant.",
+ correction: "Try replacing the value with a literal or const.",
+ );
+
+ /**
+ * No parameters.
+ */
+ static const FfiCode CREATION_OF_STRUCT_OR_UNION = FfiCode(
+ 'CREATION_OF_STRUCT_OR_UNION',
+ "Subclasses of 'Struct' and 'Union' are backed by native memory, and can't be instantiated by a generative constructor.",
+ correction: "Try allocating it via allocation, or load from a 'Pointer'.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the struct class
+ */
+ static const FfiCode EMPTY_STRUCT = FfiCode(
+ 'EMPTY_STRUCT',
+ "Struct '{0}' is empty. Empty structs are undefined behavior.",
+ correction: "Try adding a field to '{0}' or use a different Struct.",
+ );
+
+ /**
+ * No parameters.
+ */
+ static const FfiCode EXTRA_ANNOTATION_ON_STRUCT_FIELD = FfiCode(
+ 'EXTRA_ANNOTATION_ON_STRUCT_FIELD',
+ "Fields in a struct class must have exactly one annotation indicating the native type.",
+ correction: "Try removing the extra annotation.",
+ );
+
+ /**
+ * No parameters.
+ */
+ static const FfiCode EXTRA_SIZE_ANNOTATION_CARRAY = FfiCode(
+ 'EXTRA_SIZE_ANNOTATION_CARRAY',
+ "'Array's must have exactly one 'Array' annotation.",
+ correction: "Try removing the extra annotation.",
+ );
+
+ /**
+ * No parameters.
+ */
+ static const FfiCode FFI_NATIVE_ONLY_STATIC = FfiCode(
+ 'FFI_NATIVE_ONLY_STATIC',
+ "FfiNative annotations can only be used on static functions.",
+ correction: "Change the method to static.",
+ );
+
+ /**
+ * No parameters.
+ */
+ static const FfiCode FIELD_INITIALIZER_IN_STRUCT = FfiCode(
+ 'FIELD_INITIALIZER_IN_STRUCT',
+ "Constructors in subclasses of 'Struct' and 'Union' can't have field initializers.",
+ correction:
+ "Try removing the field initializer and marking the field as external.",
+ );
+
+ /**
+ * No parameters.
+ */
+ static const FfiCode FIELD_IN_STRUCT_WITH_INITIALIZER = FfiCode(
+ 'FIELD_IN_STRUCT_WITH_INITIALIZER',
+ "Fields in subclasses of 'Struct' and 'Union' can't have initializers.",
+ correction:
+ "Try removing the initializer and marking the field as external.",
+ );
+
+ /**
+ * No parameters.
+ */
+ static const FfiCode FIELD_MUST_BE_EXTERNAL_IN_STRUCT = FfiCode(
+ 'FIELD_MUST_BE_EXTERNAL_IN_STRUCT',
+ "Fields of 'Struct' and 'Union' subclasses must be marked external.",
+ correction: "Try adding the 'external' modifier.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the struct class
+ */
+ static const FfiCode GENERIC_STRUCT_SUBCLASS = FfiCode(
+ 'GENERIC_STRUCT_SUBCLASS',
+ "The class '{0}' can't extend 'Struct' or 'Union' because it is generic.",
+ correction: "Try removing the type parameters from '{0}'.",
+ );
+
+ /**
+ * No parameters.
+ */
+ static const FfiCode INVALID_EXCEPTION_VALUE = FfiCode(
+ 'INVALID_EXCEPTION_VALUE',
+ "The method 'Pointer.fromFunction' must not have an exceptional return value (the second argument) when the return type of the function is either 'void', 'Handle' or 'Pointer'.",
+ correction: "Try removing the exceptional return value.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the type of the field
+ */
+ static const FfiCode INVALID_FIELD_TYPE_IN_STRUCT = FfiCode(
+ 'INVALID_FIELD_TYPE_IN_STRUCT',
+ "Fields in struct classes can't have the type '{0}'. They can only be declared as 'int', 'double', 'Array', 'Pointer', or subtype of 'Struct' or 'Union'.",
+ correction:
+ "Try using 'int', 'double', 'Array', 'Pointer', or subtype of 'Struct' or 'Union'.",
+ );
+
+ /**
+ * No parameters.
+ */
+ static const FfiCode LEAF_CALL_MUST_NOT_RETURN_HANDLE = FfiCode(
+ 'LEAF_CALL_MUST_NOT_RETURN_HANDLE',
+ "FFI leaf call must not return a Handle.",
+ correction: "Try changing the return type to primitive or struct.",
+ );
+
+ /**
+ * No parameters.
+ */
+ static const FfiCode LEAF_CALL_MUST_NOT_TAKE_HANDLE = FfiCode(
+ 'LEAF_CALL_MUST_NOT_TAKE_HANDLE',
+ "FFI leaf call must not take arguments of type Handle.",
+ correction: "Try changing the argument type to primitive or struct.",
+ );
+
+ /**
+ * No parameters.
+ */
+ static const FfiCode MISMATCHED_ANNOTATION_ON_STRUCT_FIELD = FfiCode(
+ 'MISMATCHED_ANNOTATION_ON_STRUCT_FIELD',
+ "The annotation does not match the declared type of the field.",
+ correction:
+ "Try using a different annotation or changing the declared type to match.",
+ );
+
+ /**
+ * No parameters.
+ */
+ static const FfiCode MISSING_ANNOTATION_ON_STRUCT_FIELD = FfiCode(
+ 'MISSING_ANNOTATION_ON_STRUCT_FIELD',
+ "Fields in a struct class must either have the type 'Pointer' or an annotation indicating the native type.",
+ correction: "Try adding an annotation.",
+ );
+
+ /**
+ * No parameters.
+ */
+ static const FfiCode MISSING_EXCEPTION_VALUE = FfiCode(
+ 'MISSING_EXCEPTION_VALUE',
+ "The method 'Pointer.fromFunction' must have an exceptional return value (the second argument) when the return type of the function is neither 'void', 'Handle' or 'Pointer'.",
+ correction: "Try adding an exceptional return value.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the type of the field
+ */
+ static const FfiCode MISSING_FIELD_TYPE_IN_STRUCT = FfiCode(
+ 'MISSING_FIELD_TYPE_IN_STRUCT',
+ "Fields in struct classes must have an explicitly declared type of 'int', 'double' or 'Pointer'.",
+ correction: "Try using 'int', 'double' or 'Pointer'.",
+ );
+
+ /**
+ * No parameters.
+ */
+ static const FfiCode MISSING_SIZE_ANNOTATION_CARRAY = FfiCode(
+ 'MISSING_SIZE_ANNOTATION_CARRAY',
+ "'Array's must have exactly one 'Array' annotation.",
+ correction: "Try adding a 'Array' annotation.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the type that should be a valid dart:ffi native type.
+ * 1: the name of the function whose invocation depends on this relationship
+ */
+ static const FfiCode MUST_BE_A_NATIVE_FUNCTION_TYPE = FfiCode(
+ 'MUST_BE_A_NATIVE_FUNCTION_TYPE',
+ "The type '{0}' given to '{1}' must be a valid 'dart:ffi' native function type.",
+ correction: "Try changing the type to only use members for 'dart:ffi'.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the type that should be a subtype
+ * 1: the supertype that the subtype is compared to
+ * 2: the name of the function whose invocation depends on this relationship
+ */
+ static const FfiCode MUST_BE_A_SUBTYPE = FfiCode(
+ 'MUST_BE_A_SUBTYPE',
+ "The type '{0}' must be a subtype of '{1}' for '{2}'.",
+ correction: "Try changing one or both of the type arguments.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the function, method, or constructor having type arguments
+ */
+ static const FfiCode NON_CONSTANT_TYPE_ARGUMENT = FfiCode(
+ 'NON_CONSTANT_TYPE_ARGUMENT',
+ "The type arguments to '{0}' must be compile time constants but type parameters are not constants.",
+ correction: "Try changing the type argument to be a constant type.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the type that should be a valid dart:ffi native type.
+ */
+ static const FfiCode NON_NATIVE_FUNCTION_TYPE_ARGUMENT_TO_POINTER = FfiCode(
+ 'NON_NATIVE_FUNCTION_TYPE_ARGUMENT_TO_POINTER',
+ "The type argument for the pointer '{0}' must be a 'NativeFunction' in order to use 'asFunction'.",
+ correction: "Try changing the type argument to be a 'NativeFunction'.",
+ );
+
+ /**
+ * No parameters.
+ */
+ static const FfiCode NON_POSITIVE_ARRAY_DIMENSION = FfiCode(
+ 'NON_POSITIVE_ARRAY_DIMENSION',
+ "Array dimensions must be positive numbers.",
+ correction: "Try changing the input to a positive number.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the type of the field
+ */
+ static const FfiCode NON_SIZED_TYPE_ARGUMENT = FfiCode(
+ 'NON_SIZED_TYPE_ARGUMENT',
+ "Type arguments to '{0}' can't have the type '{1}'. They can only be declared as native integer, 'Float', 'Double', 'Pointer', or subtype of 'Struct' or 'Union'.",
+ correction:
+ "Try using a native integer, 'Float', 'Double', 'Pointer', or subtype of 'Struct' or 'Union'.",
+ );
+
+ /**
+ * No parameters.
+ */
+ static const FfiCode PACKED_ANNOTATION = FfiCode(
+ 'PACKED_ANNOTATION',
+ "Structs must have at most one 'Packed' annotation.",
+ correction: "Try removing extra 'Packed' annotations.",
+ );
+
+ /**
+ * No parameters.
+ */
+ static const FfiCode PACKED_ANNOTATION_ALIGNMENT = FfiCode(
+ 'PACKED_ANNOTATION_ALIGNMENT',
+ "Only packing to 1, 2, 4, 8, and 16 bytes is supported.",
+ correction:
+ "Try changing the 'Packed' annotation alignment to 1, 2, 4, 8, or 16.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the outer struct
+ * 1: the name of the struct being nested
+ */
+ static const FfiCode PACKED_NESTING_NON_PACKED = FfiCode(
+ 'PACKED_NESTING_NON_PACKED',
+ "Nesting the non-packed or less tightly packed struct '{0}' in a packed struct '{1}' is not supported.",
+ correction:
+ "Try packing the nested struct or packing the nested struct more tightly.",
+ );
+
+ /**
+ * No parameters.
+ */
+ static const FfiCode SIZE_ANNOTATION_DIMENSIONS = FfiCode(
+ 'SIZE_ANNOTATION_DIMENSIONS',
+ "'Array's must have an 'Array' annotation that matches the dimensions.",
+ correction: "Try adjusting the arguments in the 'Array' annotation.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the subclass
+ * 1: the name of the class being extended, implemented, or mixed in
+ */
+ static const FfiCode SUBTYPE_OF_FFI_CLASS_IN_EXTENDS = FfiCode(
+ 'SUBTYPE_OF_FFI_CLASS',
+ "The class '{0}' can't extend '{1}'.",
+ correction: "Try extending 'Struct' or 'Union'.",
+ uniqueName: 'SUBTYPE_OF_FFI_CLASS_IN_EXTENDS',
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the subclass
+ * 1: the name of the class being extended, implemented, or mixed in
+ */
+ static const FfiCode SUBTYPE_OF_FFI_CLASS_IN_IMPLEMENTS = FfiCode(
+ 'SUBTYPE_OF_FFI_CLASS',
+ "The class '{0}' can't implement '{1}'.",
+ correction: "Try extending 'Struct' or 'Union'.",
+ uniqueName: 'SUBTYPE_OF_FFI_CLASS_IN_IMPLEMENTS',
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the subclass
+ * 1: the name of the class being extended, implemented, or mixed in
+ */
+ static const FfiCode SUBTYPE_OF_FFI_CLASS_IN_WITH = FfiCode(
+ 'SUBTYPE_OF_FFI_CLASS',
+ "The class '{0}' can't mix in '{1}'.",
+ correction: "Try extending 'Struct' or 'Union'.",
+ uniqueName: 'SUBTYPE_OF_FFI_CLASS_IN_WITH',
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the subclass
+ * 1: the name of the class being extended, implemented, or mixed in
+ */
+ static const FfiCode SUBTYPE_OF_STRUCT_CLASS_IN_EXTENDS = FfiCode(
+ 'SUBTYPE_OF_STRUCT_CLASS',
+ "The class '{0}' can't extend '{1}' because '{1}' is a subtype of 'Struct' or 'Union'.",
+ correction: "Try extending 'Struct' or 'Union' directly.",
+ uniqueName: 'SUBTYPE_OF_STRUCT_CLASS_IN_EXTENDS',
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the subclass
+ * 1: the name of the class being extended, implemented, or mixed in
+ */
+ static const FfiCode SUBTYPE_OF_STRUCT_CLASS_IN_IMPLEMENTS = FfiCode(
+ 'SUBTYPE_OF_STRUCT_CLASS',
+ "The class '{0}' can't implement '{1}' because '{1}' is a subtype of 'Struct' or 'Union'.",
+ correction: "Try extending 'Struct' or 'Union' directly.",
+ uniqueName: 'SUBTYPE_OF_STRUCT_CLASS_IN_IMPLEMENTS',
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the subclass
+ * 1: the name of the class being extended, implemented, or mixed in
+ */
+ static const FfiCode SUBTYPE_OF_STRUCT_CLASS_IN_WITH = FfiCode(
+ 'SUBTYPE_OF_STRUCT_CLASS',
+ "The class '{0}' can't mix in '{1}' because '{1}' is a subtype of 'Struct' or 'Union'.",
+ correction: "Try extending 'Struct' or 'Union' directly.",
+ uniqueName: 'SUBTYPE_OF_STRUCT_CLASS_IN_WITH',
+ );
+
+ /// Initialize a newly created error code to have the given [name].
+ const FfiCode(
+ String name,
+ String message, {
+ String? correction,
+ bool hasPublishedDocs = false,
+ bool isUnresolvedIdentifier = false,
+ String? uniqueName,
+ }) : super(
+ correction: correction,
+ hasPublishedDocs: hasPublishedDocs,
+ isUnresolvedIdentifier: isUnresolvedIdentifier,
+ message: message,
+ name: name,
+ uniqueName: 'FfiCode.${uniqueName ?? name}',
+ );
+
+ @override
+ ErrorSeverity get errorSeverity => ErrorType.COMPILE_TIME_ERROR.severity;
+
+ @override
+ ErrorType get type => ErrorType.COMPILE_TIME_ERROR;
+}
diff --git a/pkg/analyzer/lib/src/dart/error/hint_codes.dart b/pkg/analyzer/lib/src/dart/error/hint_codes.dart
index f881032..2ef3842 100644
--- a/pkg/analyzer/lib/src/dart/error/hint_codes.dart
+++ b/pkg/analyzer/lib/src/dart/error/hint_codes.dart
@@ -2,3881 +2,4 @@
// 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.
-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
-
-/**
- * The hints and coding recommendations for best practices which are not
- * mentioned in the Dart Language Specification.
- */
-class HintCode extends AnalyzerErrorCode {
- /**
- * Parameters:
- * 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',
- "The argument type '{0}' can't be assigned to the parameter type "
- "'{1} Function(Object)' or '{1} Function(Object, StackTrace)'.",
- hasPublishedDocs: true);
-
- /**
- * Users should not assign values marked `@doNotStore`.
- */
- static const HintCode ASSIGNMENT_OF_DO_NOT_STORE = HintCode(
- 'ASSIGNMENT_OF_DO_NOT_STORE',
- "'{0}' is marked 'doNotStore' and shouldn't be assigned to a field or top-level variable.",
- correction: "Try removing the assignment.");
-
- /**
- * When the target expression uses '?.' operator, it can be `null`, so all the
- * subsequent invocations should also use '?.' operator.
- */
- static const HintCode CAN_BE_NULL_AFTER_NULL_AWARE = HintCode(
- 'CAN_BE_NULL_AFTER_NULL_AWARE',
- "The receiver uses '?.', so its value can be null.",
- correction: "Replace the '.' with a '?.' in the invocation.");
-
- /**
- * Dead code is code that is never reached, this can happen for instance if a
- * statement follows a return statement.
- *
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when code is found that won't be
- // executed because execution will never reach the code.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because the invocation of
- // `print` occurs after the function has returned:
- //
- // ```dart
- // void f() {
- // return;
- // [!print('here');!]
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the code isn't needed, then remove it:
- //
- // ```dart
- // void f() {
- // return;
- // }
- // ```
- //
- // If the code needs to be executed, then either move the code to a place
- // where it will be executed:
- //
- // ```dart
- // void f() {
- // print('here');
- // return;
- // }
- // ```
- //
- // Or, rewrite the code before it, so that it can be reached:
- //
- // ```dart
- // void f({bool skipPrinting = true}) {
- // if (skipPrinting) {
- // return;
- // }
- // print('here');
- // }
- // ```
- static const HintCode DEAD_CODE = HintCode('DEAD_CODE', "Dead code.",
- correction: "Try removing the code, or "
- "fixing the code before it so that it can be reached.",
- hasPublishedDocs: true);
-
- /**
- * Dead code is code that is never reached. This case covers cases where the
- * user has catch clauses after `catch (e)` or `on Object catch (e)`.
- *
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a `catch` clause is found that
- // can't be executed because it’s after a `catch` clause of the form
- // `catch (e)` or `on Object catch (e)`. The first `catch` clause that matches
- // the thrown object is selected, and both of those forms will match any
- // object, so no `catch` clauses that follow them will be selected.
- //
- // #### Examples
- //
- // The following code produces this diagnostic:
- //
- // ```dart
- // void f() {
- // try {
- // } catch (e) {
- // } [!on String {
- // }!]
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the clause should be selectable, then move the clause before the general
- // clause:
- //
- // ```dart
- // void f() {
- // try {
- // } on String {
- // } catch (e) {
- // }
- // }
- // ```
- //
- // If the clause doesn't need to be selectable, then remove it:
- //
- // ```dart
- // void f() {
- // try {
- // } catch (e) {
- // }
- // }
- // ```
- static const HintCode DEAD_CODE_CATCH_FOLLOWING_CATCH = HintCode(
- 'DEAD_CODE_CATCH_FOLLOWING_CATCH',
- "Dead code: Catch clauses after a 'catch (e)' or an "
- "'on Object catch (e)' are never reached.",
- correction:
- "Try reordering the catch clauses so that they can be reached, or "
- "removing the unreachable catch clauses.",
- hasPublishedDocs: true);
-
- /**
- * Dead code is code that is never reached. This case covers cases where the
- * user has an on-catch clause such as `on A catch (e)`, where a supertype of
- * `A` was already caught.
- *
- * Parameters:
- * 0: name of the subtype
- * 1: name of the supertype
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a `catch` clause is found that
- // can't be executed because it is after a `catch` clause that catches either
- // the same type or a supertype of the clause's type. The first `catch` clause
- // that matches the thrown object is selected, and the earlier clause always
- // matches anything matchable by the highlighted clause, so the highlighted
- // clause will never be selected.
- //
- // #### Examples
- //
- // The following code produces this diagnostic:
- //
- // ```dart
- // void f() {
- // try {
- // } on num {
- // } [!on int {
- // }!]
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the clause should be selectable, then move the clause before the general
- // clause:
- //
- // ```dart
- // void f() {
- // try {
- // } on int {
- // } on num {
- // }
- // }
- // ```
- //
- // If the clause doesn't need to be selectable, then remove it:
- //
- // ```dart
- // void f() {
- // try {
- // } on num {
- // }
- // }
- // ```
- static const HintCode DEAD_CODE_ON_CATCH_SUBTYPE = HintCode(
- 'DEAD_CODE_ON_CATCH_SUBTYPE',
- "Dead code: This on-catch block won’t be executed because '{0}' is a "
- "subtype of '{1}' and hence will have been caught already.",
- correction:
- "Try reordering the catch clauses so that this block can be reached, "
- "or removing the unreachable catch clause.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the class `Function` is used in
- // either the `extends`, `implements`, or `with` clause of a class or mixin.
- // Using the class `Function` in this way has no semantic value, so it's
- // effectively dead code.
- //
- // #### Example
- //
- // The following code produces this diagnostic because `Function` is used as
- // the superclass of `F`:
- //
- // ```dart
- // class F extends [!Function!] {}
- // ```
- //
- // #### Common fixes
- //
- // Remove the class `Function` from whichever clause it's in, and remove the
- // whole clause if `Function` is the only type in the clause:
- //
- // ```dart
- // class F {}
- // ```
- static const HintCode DEPRECATED_EXTENDS_FUNCTION = HintCode(
- 'DEPRECATED_SUBTYPE_OF_FUNCTION', "Extending 'Function' is deprecated.",
- correction: "Try removing 'Function' from the 'extends' clause.",
- hasPublishedDocs: true,
- uniqueName: 'DEPRECATED_EXTENDS_FUNCTION');
-
- /**
- * Users should not create a class named `Function` anymore.
- */
- static const HintCode DEPRECATED_FUNCTION_CLASS_DECLARATION = HintCode(
- 'DEPRECATED_FUNCTION_CLASS_DECLARATION',
- "Declaring a class named 'Function' is deprecated.",
- correction: "Try renaming the class.");
-
- /**
- * No parameters.
- */
- static const HintCode DEPRECATED_IMPLEMENTS_FUNCTION = HintCode(
- 'DEPRECATED_SUBTYPE_OF_FUNCTION',
- "Implementing 'Function' has no effect.",
- correction: "Try removing 'Function' from the 'implements' clause.",
- hasPublishedDocs: true,
- uniqueName: 'DEPRECATED_IMPLEMENTS_FUNCTION');
-
- /**
- * Parameters:
- * 0: the name of the member
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a deprecated library or class
- // member is used in a different package.
- //
- // #### Examples
- //
- // If the method `m` in the class `C` is annotated with `@deprecated`, then
- // the following code produces this diagnostic:
- //
- // ```dart
- // void f(C c) {
- // c.[!m!]();
- // }
- // ```
- //
- // #### Common fixes
- //
- // The documentation for declarations that are annotated with `@deprecated`
- // should indicate what code to use in place of the deprecated code.
- static const HintCode DEPRECATED_MEMBER_USE = HintCode(
- 'DEPRECATED_MEMBER_USE', "'{0}' is deprecated and shouldn't be used.",
- correction: "Try replacing the use of the deprecated member with the "
- "replacement.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the member
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a deprecated library member or
- // class member is used in the same package in which it's declared.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `x` is deprecated:
- //
- // ```dart
- // @deprecated
- // var x = 0;
- // var y = [!x!];
- // ```
- //
- // #### Common fixes
- //
- // The fix depends on what's been deprecated and what the replacement is. The
- // documentation for deprecated declarations should indicate what code to use
- // in place of the deprecated code.
- static const HintCode DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE = HintCode(
- 'DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE',
- "'{0}' is deprecated and shouldn't be used.",
- correction: "Try replacing the use of the deprecated member with the "
- "replacement.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the member
- * 1: message details
- */
- static const HintCode DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE_WITH_MESSAGE =
- HintCode(
- 'DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE',
- "'{0}' is deprecated and shouldn't be used. {1}.",
- correction: "Try replacing the use of the deprecated member with the "
- "replacement.",
- hasPublishedDocs: true,
- uniqueName: 'DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE_WITH_MESSAGE',
- );
-
- /**
- * Parameters:
- * 0: the name of the member
- * 1: message details
- */
- static const HintCode DEPRECATED_MEMBER_USE_WITH_MESSAGE = HintCode(
- 'DEPRECATED_MEMBER_USE',
- "'{0}' is deprecated and shouldn't be used. {1}.",
- correction: "Try replacing the use of the deprecated member with the "
- "replacement.",
- hasPublishedDocs: true,
- uniqueName: 'DEPRECATED_MEMBER_USE_WITH_MESSAGE',
- );
-
- /**
- * No parameters.
- */
- static const HintCode DEPRECATED_MIXIN_FUNCTION = HintCode(
- 'DEPRECATED_SUBTYPE_OF_FUNCTION', "Mixing in 'Function' is deprecated.",
- correction: "Try removing 'Function' from the 'with' clause.",
- hasPublishedDocs: true,
- uniqueName: 'DEPRECATED_MIXIN_FUNCTION');
-
- /**
- * Hint to use the ~/ operator.
- */
- static const HintCode DIVISION_OPTIMIZATION = HintCode(
- 'DIVISION_OPTIMIZATION',
- "The operator x ~/ y is more efficient than (x / y).toInt().",
- correction: "Try re-writing the expression to use the '~/' operator.");
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a name occurs multiple times in
- // a `hide` clause. Repeating the name is unnecessary.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the name `min` is
- // hidden more than once:
- //
- // ```dart
- // import 'dart:math' hide min, [!min!];
- //
- // var x = pi;
- // ```
- //
- // #### Common fixes
- //
- // If the name was mistyped in one or more places, then correct the mistyped
- // names:
- //
- // ```dart
- // import 'dart:math' hide max, min;
- //
- // var x = pi;
- // ```
- //
- // If the name wasn't mistyped, then remove the unnecessary name from the
- // list:
- //
- // ```dart
- // import 'dart:math' hide min;
- //
- // var x = pi;
- // ```
- static const HintCode DUPLICATE_HIDDEN_NAME =
- HintCode('DUPLICATE_HIDDEN_NAME', "Duplicate hidden name.",
- correction: "Try removing the repeated name from the list of hidden "
- "members.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the diagnostic being ignored
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a diagnostic name appears in an
- // `ignore` comment, but the diagnostic is already being ignored, either
- // because it's already included in the same `ignore` comment or because it
- // appears in an `ignore-in-file` comment.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the diagnostic named
- // `unused_local_variable` is already being ignored for the whole file so it
- // doesn't need to be ignored on a specific line:
- //
- // ```dart
- // // ignore_for_file: unused_local_variable
- // void f() {
- // // ignore: [!unused_local_variable!]
- // var x = 0;
- // }
- // ```
- //
- // The following code produces this diagnostic because the diagnostic named
- // `unused_local_variable` is being ignored twice on the same line:
- //
- // ```dart
- // void f() {
- // // ignore: unused_local_variable, [!unused_local_variable!]
- // var x = 0;
- // }
- // ```
- //
- // #### Common fixes
- //
- // Remove the ignore comment, or remove the unnecessary diagnostic name if the
- // ignore comment is ignoring more than one diagnostic:
- //
- // ```dart
- // // ignore_for_file: unused_local_variable
- // void f() {
- // var x = 0;
- // }
- // ```
- static const HintCode DUPLICATE_IGNORE = HintCode(
- 'DUPLICATE_IGNORE',
- "The diagnostic '{0}' doesn't need to be ignored here because it's "
- "already being ignored.",
- correction:
- "Try removing the name from the list, or removing the whole comment "
- "if this is the only name in the list.",
- hasPublishedDocs: true);
-
- /**
- * Duplicate imports.
- *
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an import directive is found
- // that is the same as an import before it in the file. The second import
- // doesn’t add value and should be removed.
- //
- // #### Examples
- //
- // The following code produces this diagnostic:
- //
- // ```dart
- // import 'package:meta/meta.dart';
- // import [!'package:meta/meta.dart'!];
- //
- // @sealed class C {}
- // ```
- //
- // #### Common fixes
- //
- // Remove the unnecessary import:
- //
- // ```dart
- // import 'package:meta/meta.dart';
- //
- // @sealed class C {}
- // ```
- static const HintCode DUPLICATE_IMPORT = HintCode(
- 'DUPLICATE_IMPORT', "Duplicate import.",
- correction: "Try removing all but one import of the library.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a name occurs multiple times in
- // a `show` clause. Repeating the name is unnecessary.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the name `min` is shown
- // more than once:
- //
- // ```dart
- // import 'dart:math' show min, [!min!];
- //
- // var x = min(2, min(0, 1));
- // ```
- //
- // #### Common fixes
- //
- // If the name was mistyped in one or more places, then correct the mistyped
- // names:
- //
- // ```dart
- // import 'dart:math' show max, min;
- //
- // var x = max(2, min(0, 1));
- // ```
- //
- // If the name wasn't mistyped, then remove the unnecessary name from the
- // list:
- //
- // ```dart
- // import 'dart:math' show min;
- //
- // var x = min(2, min(0, 1));
- // ```
- static const HintCode DUPLICATE_SHOWN_NAME =
- HintCode('DUPLICATE_SHOWN_NAME', "Duplicate shown name.",
- correction: "Try removing the repeated name from the list of shown "
- "members.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an element in a non-constant set
- // is the same as a previous element in the same set. If two elements are the
- // same, then the second value is ignored, which makes having both elements
- // pointless and likely signals a bug.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the element `1` appears
- // twice:
- //
- // ```dart
- // const a = 1;
- // const b = 1;
- // var s = <int>{a, [!b!]};
- // ```
- //
- // #### Common fixes
- //
- // If both elements should be included in the set, then change one of the
- // elements:
- //
- // ```dart
- // const a = 1;
- // const b = 2;
- // var s = <int>{a, b};
- // ```
- //
- // If only one of the elements is needed, then remove the one that isn't
- // needed:
- //
- // ```dart
- // const a = 1;
- // var s = <int>{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 HintCode EQUAL_ELEMENTS_IN_SET = HintCode(
- 'EQUAL_ELEMENTS_IN_SET',
- "Two elements in a set literal shouldn't be equal.",
- correction: "Change or remove the duplicate element.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a key in a non-constant map is
- // the same as a previous key in the same map. If two keys are the same, then
- // the second value overwrites the first value, which makes having both pairs
- // pointless and likely signals a bug.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the keys `a` and `b`
- // have the same value:
- //
- // ```dart
- // const a = 1;
- // const b = 1;
- // var m = <int, String>{a: 'a', [!b!]: 'b'};
- // ```
- //
- // #### Common fixes
- //
- // If both entries should be included in the map, then change one of the keys:
- //
- // ```dart
- // const a = 1;
- // const b = 2;
- // var m = <int, String>{a: 'a', b: 'b'};
- // ```
- //
- // If only one of the entries is needed, then remove the one that isn't
- // needed:
- //
- // ```dart
- // const a = 1;
- // var m = <int, String>{a: 'a'};
- // ```
- //
- // Note that literal maps preserve the order of their entries, so the choice
- // of which entry to remove might affect the order in which the keys and
- // values are returned by an iterator.
- static const HintCode EQUAL_KEYS_IN_MAP = HintCode(
- 'EQUAL_KEYS_IN_MAP', "Two keys in a map literal shouldn't be equal.",
- correction: "Change or remove the duplicate key.",
- hasPublishedDocs: true);
-
- /**
- * It is a bad practice for a source file in a package "lib" directory
- * hierarchy to traverse outside that directory hierarchy. For example, a
- * source file in the "lib" directory should not contain a directive such as
- * `import '../web/some.dart'` which references a file outside the lib
- * directory.
- */
- static const HintCode FILE_IMPORT_INSIDE_LIB_REFERENCES_FILE_OUTSIDE =
- HintCode(
- 'FILE_IMPORT_INSIDE_LIB_REFERENCES_FILE_OUTSIDE',
- "A file in the 'lib' directory shouldn't import a file outside the "
- "'lib' directory.",
- correction: "Try removing the import, or "
- "moving the imported file inside the 'lib' directory.");
-
- /**
- * It is a bad practice for a source file ouside a package "lib" directory
- * hierarchy to traverse into that directory hierarchy. For example, a source
- * file in the "web" directory should not contain a directive such as
- * `import '../lib/some.dart'` which references a file inside the lib
- * directory.
- */
- static const HintCode FILE_IMPORT_OUTSIDE_LIB_REFERENCES_FILE_INSIDE =
- HintCode(
- 'FILE_IMPORT_OUTSIDE_LIB_REFERENCES_FILE_INSIDE',
- "A file outside the 'lib' directory shouldn't reference a file "
- "inside the 'lib' directory using a relative path.",
- correction: "Try using a package: URI instead.");
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a library that declares a
- // function named `loadLibrary` is imported using a deferred import. A
- // deferred import introduces an implicit function named `loadLibrary`. This
- // function is used to load the contents of the deferred library, and the
- // implicit function hides the explicit declaration in the deferred library.
- //
- // 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 function named `loadLibrary`:
- //
- // ```dart
- // %uri="lib/a.dart"
- // void loadLibrary(Library library) {}
- //
- // class Library {}
- // ```
- //
- // The following code produces this diagnostic because the implicit
- // declaration of `a.loadLibrary` is hiding the explicit declaration of
- // `loadLibrary` in `a.dart`:
- //
- // ```dart
- // [!import 'a.dart' deferred as a;!]
- //
- // void f() {
- // a.Library();
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the imported library isn't required to be deferred, then remove the
- // keyword `deferred`:
- //
- // ```dart
- // import 'a.dart' as a;
- //
- // void f() {
- // a.Library();
- // }
- // ```
- //
- // If the imported library is required to be deferred and you need to
- // reference the imported function, then rename the function in the imported
- // library:
- //
- // ```dart
- // void populateLibrary(Library library) {}
- //
- // class Library {}
- // ```
- //
- // If the imported library is required to be deferred and you don't need to
- // reference the imported function, then add a `hide` clause:
- //
- // ```dart
- // import 'a.dart' deferred as a hide loadLibrary;
- //
- // void f() {
- // a.Library();
- // }
- // ```
- //
- // If type arguments shouldn't be required for the class, then mark the class
- // with the `@optionalTypeArgs` annotation (from `package:meta`):
- static const HintCode IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION = HintCode(
- 'IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION',
- "The imported library defines a top-level function named 'loadLibrary' "
- "that is hidden by deferring this library.",
- correction: "Try changing the import to not be deferred, or "
- "rename the function in the imported library.",
- hasPublishedDocs: true);
-
- /**
- * https://github.com/dart-lang/sdk/issues/44063
- */
- static const HintCode IMPORT_OF_LEGACY_LIBRARY_INTO_NULL_SAFE = HintCode(
- 'IMPORT_OF_LEGACY_LIBRARY_INTO_NULL_SAFE',
- "The library '{0}' is legacy, and should not be imported into "
- "a null safe library.",
- correction: "Try migrating the imported library.",
- );
-
- /**
- * When "strict-inference" is enabled, collection literal types must be
- * inferred via the context type, or have type arguments.
- */
- static const HintCode INFERENCE_FAILURE_ON_COLLECTION_LITERAL = HintCode(
- 'INFERENCE_FAILURE_ON_COLLECTION_LITERAL',
- "The type argument(s) of '{0}' can't be inferred.",
- correction: "Use explicit type argument(s) for '{0}'.");
-
- /**
- * When "strict-inference" is enabled, types in function invocations must be
- * inferred via the context type, or have type arguments.
- */
- static const HintCode INFERENCE_FAILURE_ON_FUNCTION_INVOCATION = HintCode(
- 'INFERENCE_FAILURE_ON_FUNCTION_INVOCATION',
- "The type argument(s) of the function '{0}' can't be inferred.",
- correction: "Use explicit type argument(s) for '{0}'.");
-
- /**
- * When "strict-inference" is enabled, recursive local functions, top-level
- * functions, methods, and function-typed function parameters must all
- * specify a return type. See the strict-inference resource:
- *
- * https://github.com/dart-lang/language/blob/master/resources/type-system/strict-inference.md
- */
- static const HintCode INFERENCE_FAILURE_ON_FUNCTION_RETURN_TYPE = HintCode(
- 'INFERENCE_FAILURE_ON_FUNCTION_RETURN_TYPE',
- "The return type of '{0}' cannot be inferred.",
- correction: "Declare the return type of '{0}'.");
-
- /**
- * When "strict-inference" is enabled, types in function invocations must be
- * inferred via the context type, or have type arguments.
- */
- static const HintCode INFERENCE_FAILURE_ON_GENERIC_INVOCATION = HintCode(
- 'INFERENCE_FAILURE_ON_GENERIC_INVOCATION',
- "The type argument(s) of the generic function type '{0}' can't be "
- "inferred.",
- correction: "Use explicit type argument(s) for '{0}'.");
-
- /**
- * When "strict-inference" is enabled, types in instance creation
- * (constructor calls) must be inferred via the context type, or have type
- * arguments.
- */
- static const HintCode INFERENCE_FAILURE_ON_INSTANCE_CREATION = HintCode(
- 'INFERENCE_FAILURE_ON_INSTANCE_CREATION',
- "The type argument(s) of the constructor '{0}' can't be inferred.",
- correction: "Use explicit type argument(s) for '{0}'.");
-
- /**
- * When "strict-inference" in enabled, uninitialized variables must be
- * declared with a specific type.
- */
- static const HintCode INFERENCE_FAILURE_ON_UNINITIALIZED_VARIABLE = HintCode(
- 'INFERENCE_FAILURE_ON_UNINITIALIZED_VARIABLE',
- "The type of {0} can't be inferred without either a type or "
- "initializer.",
- correction: "Try specifying the type of the variable.");
-
- /**
- * When "strict-inference" in enabled, function parameters must be
- * declared with a specific type, or inherit a type.
- */
- static const HintCode INFERENCE_FAILURE_ON_UNTYPED_PARAMETER = HintCode(
- 'INFERENCE_FAILURE_ON_UNTYPED_PARAMETER',
- "The type of {0} can't be inferred; a type must be explicitly provided.",
- correction: "Try specifying the type of the parameter.");
-
- /**
- * Parameters:
- * 0: the name of the annotation
- * 1: the list of valid targets
- */
- static const HintCode INVALID_ANNOTATION_TARGET = HintCode(
- 'INVALID_ANNOTATION_TARGET',
- "The annotation '{0}' can only be used on {1}");
-
- /**
- * This hint is generated anywhere where an element annotated with `@internal`
- * is exported as a part of a package's public API.
- *
- * Parameters:
- * 0: the name of the element
- */
- static const HintCode INVALID_EXPORT_OF_INTERNAL_ELEMENT = HintCode(
- 'INVALID_EXPORT_OF_INTERNAL_ELEMENT',
- "The member '{0}' can't be exported as a part of a package's public "
- "API.",
- correction: "Try using a hide clause to hide '{0}'.");
-
- /**
- * This hint is generated anywhere where an element annotated with `@internal`
- * is exported indirectly as a part of a package's public API.
- *
- * Parameters:
- * 0: the name of the element
- */
- static const HintCode INVALID_EXPORT_OF_INTERNAL_ELEMENT_INDIRECTLY = HintCode(
- 'INVALID_EXPORT_OF_INTERNAL_ELEMENT_INDIRECTLY',
- "The member '{0}' can't be exported as a part of a package's public "
- "API, but is indirectly exported as part of the signature of '{1}'.",
- correction: "Try using a hide clause to hide '{0}'.");
-
- /**
- * This hint is generated anywhere a @factory annotation is associated with
- * anything other than a method.
- */
- static const HintCode INVALID_FACTORY_ANNOTATION = HintCode(
- 'INVALID_FACTORY_ANNOTATION',
- "Only methods can be annotated as factories.");
-
- /**
- * This hint is generated anywhere a @factory annotation is associated with
- * a method that does not declare a return type.
- */
- static const HintCode INVALID_FACTORY_METHOD_DECL = HintCode(
- 'INVALID_FACTORY_METHOD_DECL',
- "Factory method '{0}' must have a return type.");
-
- /**
- * This hint is generated anywhere a @factory annotation is associated with
- * a non-abstract method that can return anything other than a newly allocated
- * object.
- *
- * Parameters:
- * 0: the name of the method
- */
- static const HintCode INVALID_FACTORY_METHOD_IMPL = HintCode(
- 'INVALID_FACTORY_METHOD_IMPL',
- "Factory method '{0}' doesn't return a newly allocated object.");
-
- /**
- * This hint is generated anywhere an @immutable annotation is associated with
- * anything other than a class.
- */
- static const HintCode INVALID_IMMUTABLE_ANNOTATION = HintCode(
- 'INVALID_IMMUTABLE_ANNOTATION',
- "Only classes can be annotated as being immutable.");
-
- /**
- * This hint is generated anywhere a @internal annotation is associated with
- * an element found in a package's public API.
- */
- static const HintCode INVALID_INTERNAL_ANNOTATION = HintCode(
- 'INVALID_INTERNAL_ANNOTATION',
- "Only public elements in a package's private API can be annotated as "
- "being internal.");
-
- /// Invalid Dart language version comments don't follow the specification [1].
- /// If a comment begins with "@dart" or "dart" (letters in any case),
- /// followed by optional whitespace, followed by optional non-alphanumeric,
- /// non-whitespace characters, followed by optional whitespace, followed by
- /// an optional alphabetical character, followed by a digit, then the
- /// comment is considered to be an attempt at a language version override
- /// comment. If this attempted language version override comment is not a
- /// valid language version override comment, it is reported.
- ///
- /// [1] https://github.com/dart-lang/language/blob/master/accepted/future-releases/language-versioning/feature-specification.md#individual-library-language-version-override
- static const HintCode INVALID_LANGUAGE_VERSION_OVERRIDE_AT_SIGN = HintCode(
- 'INVALID_LANGUAGE_VERSION_OVERRIDE',
- "The Dart language version override number must begin with '@dart'",
- correction: "Specify a Dart language version override with a comment "
- "like '// @dart = 2.0'.",
- uniqueName: 'INVALID_LANGUAGE_VERSION_OVERRIDE_AT_SIGN',
- );
-
- /// Invalid Dart language version comments don't follow the specification [1].
- /// If a comment begins with "@dart" or "dart" (letters in any case),
- /// followed by optional whitespace, followed by optional non-alphanumeric,
- /// non-whitespace characters, followed by optional whitespace, followed by
- /// an optional alphabetical character, followed by a digit, then the
- /// comment is considered to be an attempt at a language version override
- /// comment. If this attempted language version override comment is not a
- /// valid language version override comment, it is reported.
- ///
- /// [1] https://github.com/dart-lang/language/blob/master/accepted/future-releases/language-versioning/feature-specification.md#individual-library-language-version-override
- static const HintCode INVALID_LANGUAGE_VERSION_OVERRIDE_EQUALS = HintCode(
- 'INVALID_LANGUAGE_VERSION_OVERRIDE',
- "The Dart language version override comment must be specified with "
- "an '=' character",
- correction: "Specify a Dart language version override with a comment "
- "like '// @dart = 2.0'.",
- uniqueName: 'INVALID_LANGUAGE_VERSION_OVERRIDE_EQUALS',
- );
-
- static const HintCode INVALID_LANGUAGE_VERSION_OVERRIDE_GREATER = HintCode(
- 'INVALID_LANGUAGE_VERSION_OVERRIDE',
- "The language version override can't specify a version greater than the "
- "latest known language version: {0}.{1}",
- correction: "Try removing the language version override.",
- uniqueName: 'INVALID_LANGUAGE_VERSION_OVERRIDE_GREATER',
- );
-
- static const HintCode INVALID_LANGUAGE_VERSION_OVERRIDE_LOCATION = HintCode(
- 'INVALID_LANGUAGE_VERSION_OVERRIDE',
- "The language version override must be before any declaration or "
- "directive.",
- correction:
- "Try moving the language version override to the top of the file.",
- uniqueName: 'INVALID_LANGUAGE_VERSION_OVERRIDE_LOCATION',
- );
-
- /// Invalid Dart language version comments don't follow the specification [1].
- /// If a comment begins with "@dart" or "dart" (letters in any case),
- /// followed by optional whitespace, followed by optional non-alphanumeric,
- /// non-whitespace characters, followed by optional whitespace, followed by
- /// an optional alphabetical character, followed by a digit, then the
- /// comment is considered to be an attempt at a language version override
- /// comment. If this attempted language version override comment is not a
- /// valid language version override comment, it is reported.
- ///
- /// [1] https://github.com/dart-lang/language/blob/master/accepted/future-releases/language-versioning/feature-specification.md#individual-library-language-version-override
- static const HintCode INVALID_LANGUAGE_VERSION_OVERRIDE_LOWER_CASE = HintCode(
- 'INVALID_LANGUAGE_VERSION_OVERRIDE',
- "The Dart language version override comment must be specified with "
- "the word 'dart' in all lower case",
- correction: "Specify a Dart language version override with a comment "
- "like '// @dart = 2.0'.",
- uniqueName: 'INVALID_LANGUAGE_VERSION_OVERRIDE_LOWER_CASE',
- );
-
- /// Invalid Dart language version comments don't follow the specification [1].
- /// If a comment begins with "@dart" or "dart" (letters in any case),
- /// followed by optional whitespace, followed by optional non-alphanumeric,
- /// non-whitespace characters, followed by optional whitespace, followed by
- /// an optional alphabetical character, followed by a digit, then the
- /// comment is considered to be an attempt at a language version override
- /// comment. If this attempted language version override comment is not a
- /// valid language version override comment, it is reported.
- ///
- /// [1] https://github.com/dart-lang/language/blob/master/accepted/future-releases/language-versioning/feature-specification.md#individual-library-language-version-override
- static const HintCode INVALID_LANGUAGE_VERSION_OVERRIDE_NUMBER = HintCode(
- 'INVALID_LANGUAGE_VERSION_OVERRIDE',
- "The Dart language version override comment must be specified with a "
- "version number, like '2.0', after the '=' character.",
- correction: "Specify a Dart language version override with a comment "
- "like '// @dart = 2.0'.",
- uniqueName: 'INVALID_LANGUAGE_VERSION_OVERRIDE_NUMBER',
- );
-
- /// Invalid Dart language version comments don't follow the specification [1].
- /// If a comment begins with "@dart" or "dart" (letters in any case),
- /// followed by optional whitespace, followed by optional non-alphanumeric,
- /// non-whitespace characters, followed by optional whitespace, followed by
- /// an optional alphabetical character, followed by a digit, then the
- /// comment is considered to be an attempt at a language version override
- /// comment. If this attempted language version override comment is not a
- /// valid language version override comment, it is reported.
- ///
- /// [1] https://github.com/dart-lang/language/blob/master/accepted/future-releases/language-versioning/feature-specification.md#individual-library-language-version-override
- static const HintCode INVALID_LANGUAGE_VERSION_OVERRIDE_PREFIX = HintCode(
- 'INVALID_LANGUAGE_VERSION_OVERRIDE',
- "The Dart language version override number can't be prefixed with "
- "a letter",
- correction: "Specify a Dart language version override with a comment "
- "like '// @dart = 2.0'.",
- uniqueName: 'INVALID_LANGUAGE_VERSION_OVERRIDE_PREFIX',
- );
-
- /// Invalid Dart language version comments don't follow the specification [1].
- /// If a comment begins with "@dart" or "dart" (letters in any case),
- /// followed by optional whitespace, followed by optional non-alphanumeric,
- /// non-whitespace characters, followed by optional whitespace, followed by
- /// an optional alphabetical character, followed by a digit, then the
- /// comment is considered to be an attempt at a language version override
- /// comment. If this attempted language version override comment is not a
- /// valid language version override comment, it is reported.
- ///
- /// [1] https://github.com/dart-lang/language/blob/master/accepted/future-releases/language-versioning/feature-specification.md#individual-library-language-version-override
- static const HintCode INVALID_LANGUAGE_VERSION_OVERRIDE_TRAILING_CHARACTERS =
- HintCode(
- 'INVALID_LANGUAGE_VERSION_OVERRIDE',
- "The Dart language version override comment can't be followed by "
- "any non-whitespace characters",
- correction: "Specify a Dart language version override with a comment "
- "like '// @dart = 2.0'.",
- uniqueName: 'INVALID_LANGUAGE_VERSION_OVERRIDE_TRAILING_CHARACTERS',
- );
-
- /// Invalid Dart language version comments don't follow the specification [1].
- /// If a comment begins with "@dart" or "dart" (letters in any case),
- /// followed by optional whitespace, followed by optional non-alphanumeric,
- /// non-whitespace characters, followed by optional whitespace, followed by
- /// an optional alphabetical character, followed by a digit, then the
- /// comment is considered to be an attempt at a language version override
- /// comment. If this attempted language version override comment is not a
- /// valid language version override comment, it is reported.
- ///
- /// [1] https://github.com/dart-lang/language/blob/master/accepted/future-releases/language-versioning/feature-specification.md#individual-library-language-version-override
- static const HintCode INVALID_LANGUAGE_VERSION_OVERRIDE_TWO_SLASHES =
- HintCode(
- 'INVALID_LANGUAGE_VERSION_OVERRIDE',
- 'The Dart language version override comment must be specified with '
- 'exactly two slashes.',
- correction: "Specify a Dart language version override with a comment "
- "like '// @dart = 2.0'.",
- uniqueName: 'INVALID_LANGUAGE_VERSION_OVERRIDE_TWO_SLASHES',
- );
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the `@literal` annotation is
- // applied to anything other than a const constructor.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because the constructor isn't
- // a `const` constructor:
- //
- // ```dart
- // import 'package:meta/meta.dart';
- //
- // class C {
- // [!@literal!]
- // C();
- // }
- // ```
- //
- // The following code produces this diagnostic because `x` isn't a
- // constructor:
- //
- // ```dart
- // import 'package:meta/meta.dart';
- //
- // [!@literal!]
- // var x;
- // ```
- //
- // #### Common fixes
- //
- // If the annotation is on a constructor and the constructor should always be
- // invoked with `const`, when possible, then mark the constructor with the
- // `const` keyword:
- //
- // ```dart
- // import 'package:meta/meta.dart';
- //
- // class C {
- // @literal
- // const C();
- // }
- // ```
- //
- // If the constructor can't be marked as `const`, then remove the annotation.
- //
- // If the annotation is on anything other than a constructor, then remove the
- // annotation:
- //
- // ```dart
- // var x;
- // ```
- static const HintCode INVALID_LITERAL_ANNOTATION = HintCode(
- 'INVALID_LITERAL_ANNOTATION',
- "Only const constructors can have the `@literal` annotation.",
- hasPublishedDocs: true);
-
- /**
- * This hint is generated anywhere where `@nonVirtual` annotates something
- * other than a non-abstract instance member in a class or mixin.
- *
- * Parameters:
- * 0: the name of the member
- */
- static const HintCode INVALID_NON_VIRTUAL_ANNOTATION = HintCode(
- 'INVALID_NON_VIRTUAL_ANNOTATION',
- "The member '{0}' can't be '@nonVirtual' because it isn't a concrete "
- "instance member.",
- correction: "Try removing @nonVirtual.");
-
- /**
- * This hint is generated anywhere where an instance member annotated with
- * `@nonVirtual` is overridden in a subclass.
- *
- * Parameters:
- * 0: the name of the member
- * 1: the name of the defining class
- */
- static const HintCode INVALID_OVERRIDE_OF_NON_VIRTUAL_MEMBER = HintCode(
- 'INVALID_OVERRIDE_OF_NON_VIRTUAL_MEMBER',
- "The member '{0}' is declared non-virtual in '{1}' and can't be "
- "overridden in subclasses.");
-
- /**
- * This hint is generated anywhere where `@required` annotates a named
- * parameter with a default value.
- *
- * Parameters:
- * 0: the name of the member
- */
- static const HintCode INVALID_REQUIRED_NAMED_PARAM = HintCode(
- 'INVALID_REQUIRED_NAMED_PARAM',
- "The type parameter '{0}' is annotated with @required but only named "
- "parameters without a default value can be annotated with it.",
- correction: "Remove @required.");
-
- /**
- * This hint is generated anywhere where `@required` annotates an optional
- * positional parameter.
- *
- * Parameters:
- * 0: the name of the member
- */
- static const HintCode INVALID_REQUIRED_OPTIONAL_POSITIONAL_PARAM = HintCode(
- 'INVALID_REQUIRED_OPTIONAL_POSITIONAL_PARAM',
- "Incorrect use of the annotation @required on the optional "
- "positional parameter '{0}'. Optional positional parameters "
- "cannot be required.",
- correction: "Remove @required.");
-
- /**
- * This hint is generated anywhere where `@required` annotates a non named
- * parameter or a named parameter with default value.
- *
- * Parameters:
- * 0: the name of the member
- *
- * Deprecated: Use the more specific [INVALID_REQUIRED_NAMED_PARAM],
- * [INVALID_REQUIRED_OPTIONAL_POSITION_PARAM], and
- * [INVALID_REQUIRED_POSITION_PARAM]
- */
- @deprecated
- static const HintCode INVALID_REQUIRED_PARAM = HintCode(
- 'INVALID_REQUIRED_PARAM',
- "The type parameter '{0}' is annotated with @required but only named "
- "parameters without default value can be annotated with it.",
- correction: "Remove @required.");
-
- /**
- * This hint is generated anywhere where `@required` annotates a non optional
- * positional parameter.
- *
- * Parameters:
- * 0: the name of the member
- */
- static const HintCode INVALID_REQUIRED_POSITIONAL_PARAM = HintCode(
- 'INVALID_REQUIRED_POSITIONAL_PARAM',
- "Redundant use of the annotation @required on the required positional "
- "parameter '{0}'.",
- correction: "Remove @required.");
-
- /**
- * This hint is generated anywhere where `@sealed` annotates something other
- * than a class.
- *
- * Parameters:
- * 0: the name of the member
- */
- static const HintCode INVALID_SEALED_ANNOTATION = HintCode(
- 'INVALID_SEALED_ANNOTATION',
- "The member '{0}' is annotated with '@sealed' but only classes can be "
- "annotated with it.",
- correction: "Remove @sealed.");
-
- /**
- * This hint is generated anywhere where a member annotated with `@internal`
- * is used outside of the package in which it is declared.
- *
- * Parameters:
- * 0: the name of the member
- */
- static const HintCode INVALID_USE_OF_INTERNAL_MEMBER = HintCode(
- 'INVALID_USE_OF_INTERNAL_MEMBER',
- "The member '{0}' can only be used within its package.");
-
- /**
- * This hint is generated anywhere where a member annotated with `@protected`
- * is used outside of an instance member of a subclass.
- *
- * Parameters:
- * 0: the name of the member
- * 1: the name of the defining class
- */
- static const HintCode INVALID_USE_OF_PROTECTED_MEMBER = HintCode(
- 'INVALID_USE_OF_PROTECTED_MEMBER',
- "The member '{0}' can only be used within instance members of subclasses "
- "of '{1}'.");
-
- /**
- * Parameters:
- * 0: the name of the member
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an instance member that is
- // annotated with `visibleForOverriding` is referenced outside the library in
- // which it's declared for any reason other than to override it.
- //
- // #### Example
- //
- // Given a file named `a.dart` containing the following declaration:
- //
- // ```dart
- // %uri="lib/a.dart"
- // import 'package:meta/meta.dart';
- //
- // class A {
- // @visibleForOverriding
- // void a() {}
- // }
- // ```
- //
- // The following code produces this diagnostic because the method `m` is being
- // invoked even though the only reason it's public is to allow it to be
- // overridden:
- //
- // ```dart
- // import 'a.dart';
- //
- // class B extends A {
- // void b() {
- // [!a!]();
- // }
- // }
- // ```
- //
- // #### Common fixes
- //
- // Remove the invalid use of the member.
- static const HintCode INVALID_USE_OF_VISIBLE_FOR_OVERRIDING_MEMBER = HintCode(
- 'INVALID_USE_OF_VISIBLE_FOR_OVERRIDING_MEMBER',
- "The member '{0}' can only be used for overriding.");
-
- /**
- * This hint is generated anywhere where a member annotated with
- * `@visibleForTemplate` is used outside of a "template" Dart file.
- *
- * Parameters:
- * 0: the name of the member
- * 1: the name of the defining class
- */
- static const HintCode INVALID_USE_OF_VISIBLE_FOR_TEMPLATE_MEMBER = HintCode(
- 'INVALID_USE_OF_VISIBLE_FOR_TEMPLATE_MEMBER',
- "The member '{0}' can only be used within '{1}' or a template "
- "library.");
-
- /**
- * This hint is generated anywhere where a member annotated with
- * `@visibleForTesting` is used outside the defining library, or a test.
- *
- * Parameters:
- * 0: the name of the member
- * 1: the name of the defining class
- */
- static const HintCode INVALID_USE_OF_VISIBLE_FOR_TESTING_MEMBER = HintCode(
- 'INVALID_USE_OF_VISIBLE_FOR_TESTING_MEMBER',
- "The member '{0}' can only be used within '{1}' or a test.");
-
- /**
- * This hint is generated anywhere where a private declaration is annotated
- * with `@visibleForTemplate` or `@visibleForTesting`.
- *
- * Parameters:
- * 0: the name of the member
- * 1: the name of the annotation
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when either the `@visibleForTemplate`
- // or `@visibleForTesting` annotation is applied to a non-public declaration.
- //
- // #### Examples
- //
- // The following code produces this diagnostic:
- //
- // ```dart
- // import 'package:meta/meta.dart';
- //
- // [!@visibleForTesting!]
- // void _someFunction() {}
- //
- // void f() => _someFunction();
- // ```
- //
- // #### Common fixes
- //
- // If the declaration doesn't need to be used by test code, then remove the
- // annotation:
- //
- // ```dart
- // void _someFunction() {}
- //
- // void f() => _someFunction();
- // ```
- //
- // If it does, then make it public:
- //
- // ```dart
- // import 'package:meta/meta.dart';
- //
- // @visibleForTesting
- // void someFunction() {}
- //
- // void f() => someFunction();
- // ```
- static const HintCode INVALID_VISIBILITY_ANNOTATION = HintCode(
- 'INVALID_VISIBILITY_ANNOTATION',
- "The member '{0}' is annotated with '{1}', but this annotation is only "
- "meaningful on declarations of public members.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when anything other than a public
- // instance member of a class is annotated with `visibleForOverriding`.
- // Because only public instance members can be overridden outside the defining
- // library, there's no value to annotating any other declarations.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the annotation is on a
- // class, and classes can't be overridden:
- //
- // ```dart
- // import 'package:meta/meta.dart';
- //
- // [!@visibleForOverriding!]
- // class C {}
- // ```
- //
- // #### Common fixes
- //
- // Remove the annotation:
- //
- // ```dart
- // class C {}
- // ```
- static const HintCode INVALID_VISIBLE_FOR_OVERRIDING_ANNOTATION = HintCode(
- 'INVALID_VISIBLE_FOR_OVERRIDING_ANNOTATION',
- "The declaration '{0}' is annotated with 'visibleForOverriding'. Because "
- "'{0}' isn't an interface member that could be overridden, the "
- "annotation is meaningless.",
- );
-
- /**
- * Generate a hint for an element that is annotated with `@JS(...)` whose
- * library declaration is not similarly annotated.
- */
- static const HintCode MISSING_JS_LIB_ANNOTATION = HintCode(
- 'MISSING_JS_LIB_ANNOTATION',
- "The @JS() annotation can only be used if it is also declared on the "
- "library directive.",
- correction: "Try adding the annotation to the library directive.");
-
- /**
- * Generate a hint for a constructor, function or method invocation where a
- * required parameter is missing.
- *
- * Parameters:
- * 0: the name of the parameter
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a method or function with a
- // named parameter that is annotated as being required is invoked without
- // providing a value for the parameter.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because the named parameter `x`
- // is required:
- //
- // ```dart
- // %language=2.9
- // import 'package:meta/meta.dart';
- //
- // void f({@required int x}) {}
- //
- // void g() {
- // [!f!]();
- // }
- // ```
- //
- // #### Common fixes
- //
- // Provide the required value:
- //
- // ```dart
- // %language=2.9
- // import 'package:meta/meta.dart';
- //
- // void f({@required int x}) {}
- //
- // void g() {
- // f(x: 2);
- // }
- // ```
- static const HintCode MISSING_REQUIRED_PARAM = HintCode(
- 'MISSING_REQUIRED_PARAM', "The parameter '{0}' is required.",
- hasPublishedDocs: true);
-
- /**
- * Generate a hint for a constructor, function or method invocation where a
- * required parameter is missing.
- *
- * Parameters:
- * 0: the name of the parameter
- * 1: message details
- */
- static const HintCode MISSING_REQUIRED_PARAM_WITH_DETAILS = HintCode(
- 'MISSING_REQUIRED_PARAM',
- "The parameter '{0}' is required. {1}.",
- hasPublishedDocs: true,
- uniqueName: 'MISSING_REQUIRED_PARAM_WITH_DETAILS',
- );
-
- /**
- * Parameters:
- * 0: the name of the declared return type
- */
- // #### Description
- //
- // Any function or method that doesn't end with either an explicit return or a
- // throw implicitly returns `null`. This is rarely the desired behavior. The
- // analyzer produces this diagnostic when it finds an implicit return.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `f` doesn't end with a
- // return:
- //
- // ```dart
- // %language=2.9
- // int [!f!](int x) {
- // if (x < 0) {
- // return 0;
- // }
- // }
- // ```
- //
- // #### Common fixes
- //
- // Add a `return` statement that makes the return value explicit, even if
- // `null` is the appropriate value.
- static const HintCode MISSING_RETURN = HintCode(
- 'MISSING_RETURN',
- "This function has a return type of '{0}', but doesn't end with a "
- "return statement.",
- correction: "Try adding a return statement, "
- "or changing the return type to 'void'.",
- hasPublishedDocs: true);
-
- /**
- * This hint is generated anywhere where a `@sealed` class is used as a
- * a superclass constraint of a mixin.
- *
- * Parameters:
- * 0: the name of the sealed class
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the superclass constraint of a
- // mixin is a class from a different package that was marked as `@sealed`.
- // Classes that are sealed can't be extended, implemented, mixed in, or used
- // as a superclass constraint.
- //
- // #### Examples
- //
- // If the package `p` defines a sealed class:
- //
- // ```dart
- // %uri="package:p/p.dart"
- // import 'package:meta/meta.dart';
- //
- // @sealed
- // class C {}
- // ```
- //
- // Then, the following code, when in a package other than `p`, produces this
- // diagnostic:
- //
- // ```dart
- // import 'package:p/p.dart';
- //
- // [!mixin M on C {}!]
- // ```
- //
- // #### Common fixes
- //
- // If the classes that use the mixin don't need to be subclasses of the sealed
- // class, then consider adding a field and delegating to the wrapped instance
- // of the sealed class.
- static const HintCode MIXIN_ON_SEALED_CLASS = HintCode(
- 'MIXIN_ON_SEALED_CLASS',
- "The class '{0}' shouldn't be used as a mixin constraint because it is "
- "sealed, and any class mixing in this mixin must have '{0}' as a "
- "superclass.",
- correction:
- "Try composing with this class, or refer to its documentation for "
- "more information.",
- hasPublishedDocs: true);
-
- /**
- * Generate a hint for classes that inherit from classes annotated with
- * `@immutable` but that are not immutable.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an immutable class defines one
- // or more instance fields that aren't final. A class is immutable if it's
- // marked as being immutable using the annotation `@immutable` or if it's a
- // subclass of an immutable class.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because the field `x` isn't
- // final:
- //
- // ```dart
- // import 'package:meta/meta.dart';
- //
- // @immutable
- // class [!C!] {
- // int x;
- //
- // C(this.x);
- // }
- // ```
- //
- // #### Common fixes
- //
- // If instances of the class should be immutable, then add the keyword `final`
- // to all non-final field declarations:
- //
- // ```dart
- // import 'package:meta/meta.dart';
- //
- // @immutable
- // class C {
- // final int x;
- //
- // C(this.x);
- // }
- // ```
- //
- // If the instances of the class should be mutable, then remove the
- // annotation, or choose a different superclass if the annotation is
- // inherited:
- //
- // ```dart
- // class C {
- // int x;
- //
- // C(this.x);
- // }
- // ```
- static const HintCode MUST_BE_IMMUTABLE = HintCode(
- 'MUST_BE_IMMUTABLE',
- "This class (or a class that this class inherits from) is marked as "
- "'@immutable', but one or more of its instance fields aren't final: "
- "{0}",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the class declaring the overridden method
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a method that overrides a method
- // that is annotated as `@mustCallSuper` doesn't invoke the overridden method
- // as required.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because the method `m` in `B`
- // doesn't invoke the overridden method `m` in `A`:
- //
- // ```dart
- // import 'package:meta/meta.dart';
- //
- // class A {
- // @mustCallSuper
- // m() {}
- // }
- //
- // class B extends A {
- // @override
- // [!m!]() {}
- // }
- // ```
- //
- // #### Common fixes
- //
- // Add an invocation of the overridden method in the overriding method:
- //
- // ```dart
- // import 'package:meta/meta.dart';
- //
- // class A {
- // @mustCallSuper
- // m() {}
- // }
- //
- // class B extends A {
- // @override
- // m() {
- // super.m();
- // }
- // }
- // ```
- static const HintCode MUST_CALL_SUPER = HintCode(
- 'MUST_CALL_SUPER',
- "This method overrides a method annotated as '@mustCallSuper' in '{0}', "
- "but doesn't invoke the overridden method.",
- hasPublishedDocs: true);
-
- /**
- * Generate a hint for non-const instance creation using a constructor
- * annotated with `@literal`.
- *
- * Parameters:
- * 0: the name of the class defining the annotated constructor
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a constructor that has the
- // `@literal` annotation is invoked without using the `const` keyword, but all
- // of the arguments to the constructor are constants. The annotation indicates
- // that the constructor should be used to create a constant value whenever
- // possible.
- //
- // #### Examples
- //
- // The following code produces this diagnostic:
- //
- // ```dart
- // import 'package:meta/meta.dart';
- //
- // class C {
- // @literal
- // const C();
- // }
- //
- // C f() => [!C()!];
- // ```
- //
- // #### Common fixes
- //
- // Add the keyword `const` before the constructor invocation:
- //
- // ```dart
- // import 'package:meta/meta.dart';
- //
- // class C {
- // @literal
- // const C();
- // }
- //
- // void f() => const C();
- // ```
- static const HintCode NON_CONST_CALL_TO_LITERAL_CONSTRUCTOR = HintCode(
- 'NON_CONST_CALL_TO_LITERAL_CONSTRUCTOR',
- "This instance creation must be 'const', because the {0} constructor is "
- "marked as '@literal'.",
- correction: "Try adding a 'const' keyword.",
- hasPublishedDocs: true);
-
- /**
- * Generate a hint for non-const instance creation (with the `new` keyword)
- * using a constructor annotated with `@literal`.
- *
- * Parameters:
- * 0: the name of the class defining the annotated constructor
- */
- static const HintCode NON_CONST_CALL_TO_LITERAL_CONSTRUCTOR_USING_NEW =
- HintCode(
- 'NON_CONST_CALL_TO_LITERAL_CONSTRUCTOR',
- "This instance creation must be 'const', because the {0} constructor "
- "is marked as '@literal'.",
- correction: "Try replacing the 'new' keyword with 'const'.",
- hasPublishedDocs: true,
- uniqueName: 'NON_CONST_CALL_TO_LITERAL_CONSTRUCTOR_USING_NEW',
- );
-
- /**
- * Parameters:
- * 0: the name of the method being invoked
- * 1: the type argument associated with the method
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when `null` is passed to either the
- // constructor `Future.value` or the method `Completer.complete` when the type
- // argument used to create the instance was non-nullable. Even though the type
- // system can't express this restriction, passing in a `null` results in a
- // runtime exception.
- //
- // #### Example
- //
- // The following code produces this diagnostic because `null` is being passed
- // to the constructor `Future.value` even though the type argument is the
- // non-nullable type `String`:
- //
- // ```dart
- // Future<String> f() {
- // return Future.value([!null!]);
- // }
- // ```
- //
- // #### Common fixes
- //
- // Pass in a non-null value:
- //
- // ```dart
- // Future<String> f() {
- // return Future.value('');
- // }
- // ```
- static const HintCode NULL_ARGUMENT_TO_NON_NULL_TYPE = HintCode(
- 'NULL_ARGUMENT_TO_NON_NULL_TYPE',
- "'{0}' shouldn't be called with a null argument for the non-nullable "
- "type argument '{1}'.",
- correction: 'Try adding a non-null argument.');
-
- /**
- * When the left operand of a binary expression uses '?.' operator, it can be
- * `null`.
- */
- static const HintCode NULL_AWARE_BEFORE_OPERATOR = HintCode(
- 'NULL_AWARE_BEFORE_OPERATOR',
- "The left operand uses '?.', so its value can be null.");
-
- /**
- * A condition in a control flow statement could evaluate to `null` because it
- * uses the null-aware '?.' operator.
- */
- static const HintCode NULL_AWARE_IN_CONDITION = HintCode(
- 'NULL_AWARE_IN_CONDITION',
- "The value of the '?.' operator can be 'null', which isn't appropriate "
- "in a condition.",
- correction:
- "Try replacing the '?.' with a '.', testing the left-hand side for "
- "null if necessary.");
-
- /**
- * A condition in operands of a logical operator could evaluate to `null`
- * because it uses the null-aware '?.' operator.
- */
- static const HintCode NULL_AWARE_IN_LOGICAL_OPERATOR = HintCode(
- 'NULL_AWARE_IN_LOGICAL_OPERATOR',
- "The value of the '?.' operator can be 'null', which isn't appropriate "
- "as an operand of a logical operator.");
-
- /**
- * This hint indicates that a null literal is null-checked with `!`, but null
- * is never not null.
- */
- static const HintCode NULL_CHECK_ALWAYS_FAILS = HintCode(
- 'NULL_CHECK_ALWAYS_FAILS',
- "This null-check will always throw an exception because the expression "
- "will always evaluate to 'null'.");
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the type following `on` in a
- // `catch` clause is a nullable type. It isn't valid to specify a nullable
- // type because it isn't possible to catch `null` (because it's a runtime
- // error to throw `null`).
- //
- // #### Example
- //
- // The following code produces this diagnostic because the exception type is
- // specified to allow `null` when `null` can't be thrown:
- //
- // ```dart
- // void f() {
- // try {
- // // ...
- // } on [!FormatException?!] {
- // }
- // }
- // ```
- //
- // #### Common fixes
- //
- // Remove the question mark from the type:
- //
- // ```dart
- // void f() {
- // try {
- // // ...
- // } on FormatException {
- // }
- // }
- // ```
- static const HintCode NULLABLE_TYPE_IN_CATCH_CLAUSE = HintCode(
- 'NULLABLE_TYPE_IN_CATCH_CLAUSE',
- "A potentially nullable type can't be used in an 'on' clause because it "
- "isn't valid to throw a nullable expression.",
- correction: "Try using a non-nullable type.",
- hasPublishedDocs: true);
-
- /**
- * A field with the override annotation does not override a getter or setter.
- *
- * No parameters.
- */
- static const HintCode OVERRIDE_ON_NON_OVERRIDING_FIELD = HintCode(
- 'OVERRIDE_ON_NON_OVERRIDING_MEMBER',
- "The field doesn't override an inherited getter or setter.",
- correction: "Try updating this class to match the superclass, or "
- "removing the override annotation.",
- hasPublishedDocs: true,
- uniqueName: 'OVERRIDE_ON_NON_OVERRIDING_FIELD',
- );
-
- /**
- * A getter with the override annotation does not override an existing getter.
- *
- * No parameters.
- */
- static const HintCode OVERRIDE_ON_NON_OVERRIDING_GETTER = HintCode(
- 'OVERRIDE_ON_NON_OVERRIDING_MEMBER',
- "The getter doesn't override an inherited getter.",
- correction: "Try updating this class to match the superclass, or "
- "removing the override annotation.",
- hasPublishedDocs: true,
- uniqueName: 'OVERRIDE_ON_NON_OVERRIDING_GETTER',
- );
-
- /**
- * A method with the override annotation does not override an existing method.
- *
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a class member is annotated with
- // the `@override` annotation, but the member isn’t declared in any of the
- // supertypes of the class.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `m` isn't declared in
- // any of the supertypes of `C`:
- //
- // ```dart
- // class C {
- // @override
- // String [!m!]() => '';
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the member is intended to override a member with a different name, then
- // update the member to have the same name:
- //
- // ```dart
- // class C {
- // @override
- // String toString() => '';
- // }
- // ```
- //
- // If the member is intended to override a member that was removed from the
- // superclass, then consider removing the member from the subclass.
- //
- // If the member can't be removed, then remove the annotation.
- static const HintCode OVERRIDE_ON_NON_OVERRIDING_METHOD = HintCode(
- 'OVERRIDE_ON_NON_OVERRIDING_MEMBER',
- "The method doesn't override an inherited method.",
- correction: "Try updating this class to match the superclass, or "
- "removing the override annotation.",
- hasPublishedDocs: true,
- uniqueName: 'OVERRIDE_ON_NON_OVERRIDING_METHOD',
- );
-
- /**
- * A setter with the override annotation does not override an existing setter.
- *
- * No parameters.
- */
- static const HintCode OVERRIDE_ON_NON_OVERRIDING_SETTER = HintCode(
- 'OVERRIDE_ON_NON_OVERRIDING_MEMBER',
- "The setter doesn't override an inherited setter.",
- correction: "Try updating this class to match the superclass, or "
- "removing the override annotation.",
- hasPublishedDocs: true,
- uniqueName: 'OVERRIDE_ON_NON_OVERRIDING_SETTER',
- );
-
- /**
- * It is a bad practice for a package import to reference anything outside the
- * given package, or more generally, it is bad practice for a package import
- * to contain a "..". For example, a source file should not contain a
- * directive such as `import 'package:foo/../some.dart'`.
- */
- static const HintCode PACKAGE_IMPORT_CONTAINS_DOT_DOT = HintCode(
- 'PACKAGE_IMPORT_CONTAINS_DOT_DOT',
- "A package import shouldn't contain '..'.");
-
- /**
- * It is not an error to call or tear-off a method, setter, or getter, or to
- * read or write a field, on a receiver of static type `Never`.
- * Implementations that provide feedback about dead or unreachable code are
- * encouraged to indicate that any arguments to the invocation are
- * unreachable.
- *
- * It is not an error to apply an expression of type `Never` in the function
- * position of a function call. Implementations that provide feedback about
- * dead or unreachable code are encouraged to indicate that any arguments to
- * the call are unreachable.
- *
- * Parameters: none
- */
- static const HintCode RECEIVER_OF_TYPE_NEVER = HintCode(
- 'RECEIVER_OF_TYPE_NEVER',
- "The receiver is of type 'Never', and will never complete with a value.",
- correction: "Try checking for throw expressions or type errors in the "
- "receiver");
-
- /**
- * Users should not return values marked `@doNotStore` from functions,
- * methods or getters not marked `@doNotStore`.
- */
- static const HintCode RETURN_OF_DO_NOT_STORE = HintCode(
- 'RETURN_OF_DO_NOT_STORE',
- "'{0}' is annotated with 'doNotStore' and shouldn't be returned unless "
- "'{1}' is also annotated.",
- correction: "Annotate '{1}' with 'doNotStore'.");
-
- /**
- * Parameters:
- * 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 "
- "because it must be assignable to '{1}'.",
- hasPublishedDocs: true,
- uniqueName: 'RETURN_OF_INVALID_TYPE_FROM_CATCH_ERROR');
-
- /**
- * Parameters:
- * 0: the return type of the function
- * 1: the expected return type as defined by the type of the Future
- */
- static const HintCode RETURN_TYPE_INVALID_FOR_CATCH_ERROR = HintCode(
- 'INVALID_RETURN_TYPE_FOR_CATCH_ERROR',
- "The return type '{0}' isn't assignable to '{1}', as required by "
- "'Future.catchError'.",
- hasPublishedDocs: true,
- uniqueName: 'RETURN_TYPE_INVALID_FOR_CATCH_ERROR');
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an `as` expression inside a
- // [constant context][] is found in code that has an SDK constraint whose
- // lower bound is less than 2.3.2. Using an `as` expression in a
- // [constant context][] wasn't supported in earlier versions, so this code
- // won't be able to run against earlier versions of the SDK.
- //
- // #### Examples
- //
- // Here's an example of a pubspec that defines an SDK constraint with a lower
- // bound of less than 2.3.2:
- //
- // ```yaml
- // %uri="pubspec.yaml"
- // environment:
- // sdk: '>=2.1.0 <2.4.0'
- // ```
- //
- // In the package that has that pubspec, code like the following produces
- // this diagnostic:
- //
- // ```dart
- // const num n = 3;
- // const int i = [!n as int!];
- // ```
- //
- // #### Common fixes
- //
- // If you don't need to support older versions of the SDK, then you can
- // increase the SDK constraint to allow the expression to be used:
- //
- // ```yaml
- // environment:
- // sdk: '>=2.3.2 <2.4.0'
- // ```
- //
- // If you need to support older versions of the SDK, then either rewrite the
- // code to not use an `as` expression, or change the code so that the `as`
- // expression isn't in a [constant context][]:
- //
- // ```dart
- // num x = 3;
- // int y = x as int;
- // ```
- static const HintCode SDK_VERSION_AS_EXPRESSION_IN_CONST_CONTEXT = HintCode(
- 'SDK_VERSION_AS_EXPRESSION_IN_CONST_CONTEXT',
- "The use of an as expression in a constant expression wasn't "
- "supported until version 2.3.2, but this code is required to be able "
- "to run on earlier versions.",
- correction: "Try updating the SDK constraints.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when either the class `Future` or
- // `Stream` is referenced in a library that doesn't import `dart:async` in
- // code that has an SDK constraint whose lower bound is less than 2.1.0. In
- // earlier versions, these classes weren't defined in `dart:core`, so the
- // import was necessary.
- //
- // #### Examples
- //
- // Here's an example of a pubspec that defines an SDK constraint with a lower
- // bound of less than 2.1.0:
- //
- // ```yaml
- // %uri="pubspec.yaml"
- // environment:
- // sdk: '>=2.0.0 <2.4.0'
- // ```
- //
- // In the package that has that pubspec, code like the following produces this
- // diagnostic:
- //
- // ```dart
- // void f([!Future!] f) {}
- // ```
- //
- // #### Common fixes
- //
- // If you don't need to support older versions of the SDK, then you can
- // increase the SDK constraint to allow the classes to be referenced:
- //
- // ```yaml
- // environment:
- // sdk: '>=2.1.0 <2.4.0'
- // ```
- //
- // If you need to support older versions of the SDK, then import the
- // `dart:async` library.
- //
- // ```dart
- // import 'dart:async';
- //
- // void f(Future f) {}
- // ```
- static const HintCode SDK_VERSION_ASYNC_EXPORTED_FROM_CORE = HintCode(
- 'SDK_VERSION_ASYNC_EXPORTED_FROM_CORE',
- "The class '{0}' wasn't exported from 'dart:core' until version 2.1, "
- "but this code is required to be able to run on earlier versions.",
- correction:
- "Try either importing 'dart:async' or updating the SDK constraints.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when any use of the `&`, `|`, or `^`
- // operators on the class `bool` inside a [constant context][] is found in
- // code that has an SDK constraint whose lower bound is less than 2.3.2. Using
- // these operators in a [constant context][] wasn't supported in earlier
- // versions, so this code won't be able to run against earlier versions of the
- // SDK.
- //
- // #### Examples
- //
- // Here's an example of a pubspec that defines an SDK constraint with a lower
- // bound of less than 2.3.2:
- //
- // ```yaml
- // %uri="pubspec.yaml"
- // environment:
- // sdk: '>=2.1.0 <2.4.0'
- // ```
- //
- // In the package that has that pubspec, code like the following produces this
- // diagnostic:
- //
- // ```dart
- // const bool a = true;
- // const bool b = false;
- // const bool c = a [!&!] b;
- // ```
- //
- // #### Common fixes
- //
- // If you don't need to support older versions of the SDK, then you can
- // increase the SDK constraint to allow the operators to be used:
- //
- // ```yaml
- // environment:
- // sdk: '>=2.3.2 <2.4.0'
- // ```
- //
- // If you need to support older versions of the SDK, then either rewrite the
- // code to not use these operators, or change the code so that the expression
- // isn't in a [constant context][]:
- //
- // ```dart
- // const bool a = true;
- // const bool b = false;
- // bool c = a & b;
- // ```
- static const HintCode SDK_VERSION_BOOL_OPERATOR_IN_CONST_CONTEXT = HintCode(
- 'SDK_VERSION_BOOL_OPERATOR_IN_CONST_CONTEXT',
- "The use of the operator '{0}' for 'bool' operands in a constant context "
- "wasn't supported until version 2.3.2, but this code is required to "
- "be able to run on earlier versions.",
- correction: "Try updating the SDK constraints.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- *
- * There is also a [ParserError.EXPERIMENT_NOT_ENABLED] code which catches
- * some cases of constructor tearoff features (like `List<int>.filled;`).
- * Other constructor tearoff cases are not realized until resolution
- * (like `List.filled;`).
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a constructor tear-off is found
- // in code that has an SDK constraint whose lower bound is less than 2.15.
- // Constructor tear-offs weren't supported in earlier versions, so this code
- // won't be able to run against earlier versions of the SDK.
- //
- // #### Example
- //
- // Here's an example of a pubspec that defines an SDK constraint with a lower
- // bound of less than 2.15:
- //
- // ```yaml
- // %uri="pubspec.yaml"
- // environment:
- // sdk: '>=2.9.0 <2.15.0'
- // ```
- //
- // In the package that has that pubspec, code like the following produces this
- // diagnostic:
- //
- // ```dart
- // %language=2.14
- // var setConstructor = [!Set.identity!];
- // ```
- //
- // #### Common fixes
- //
- // If you don't need to support older versions of the SDK, then you can
- // increase the SDK constraint to allow the operator to be used:
- //
- // ```yaml
- // environment:
- // sdk: '>=2.15.0 <2.16.0'
- // ```
- //
- // If you need to support older versions of the SDK, then rewrite the code to
- // not use constructor tear-offs:
- //
- // ```dart
- // %language=2.14
- // var setConstructor = () => Set.identity();
- // ```
- static const HintCode SDK_VERSION_CONSTRUCTOR_TEAROFFS = HintCode(
- 'SDK_VERSION_CONSTRUCTOR_TEAROFFS',
- "Tearing off a constructor requires the 'constructor-tearoffs' "
- "language feature.",
- correction: "Try updating your pubspec.yaml to set the minimum SDK "
- "constraint to 2.15 or higher, and running 'pub get'.");
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the operator `==` is used on a
- // non-primitive type inside a [constant context][] is found in code that has
- // an SDK constraint whose lower bound is less than 2.3.2. Using this operator
- // in a [constant context][] wasn't supported in earlier versions, so this
- // code won't be able to run against earlier versions of the SDK.
- //
- // #### Examples
- //
- // Here's an example of a pubspec that defines an SDK constraint with a lower
- // bound of less than 2.3.2:
- //
- // ```yaml
- // %uri="pubspec.yaml"
- // environment:
- // sdk: '>=2.1.0 <2.4.0'
- // ```
- //
- // In the package that has that pubspec, code like the following produces this
- // diagnostic:
- //
- // ```dart
- // %language=2.9
- // class C {}
- // const C a = null;
- // const C b = null;
- // const bool same = a [!==!] b;
- // ```
- //
- // #### Common fixes
- //
- // If you don't need to support older versions of the SDK, then you can
- // increase the SDK constraint to allow the operator to be used:
- //
- // ```yaml
- // environment:
- // sdk: '>=2.3.2 <2.4.0'
- // ```
- //
- // If you need to support older versions of the SDK, then either rewrite the
- // code to not use the `==` operator, or change the code so that the
- // expression isn't in a [constant context][]:
- //
- // ```dart
- // %language=2.9
- // class C {}
- // const C a = null;
- // const C b = null;
- // bool same = a == b;
- // ```
- static const HintCode SDK_VERSION_EQ_EQ_OPERATOR_IN_CONST_CONTEXT = HintCode(
- 'SDK_VERSION_EQ_EQ_OPERATOR_IN_CONST_CONTEXT',
- "Using the operator '==' for non-primitive types wasn't supported "
- "until version 2.3.2, but this code is required to be able to "
- "run on earlier versions.",
- correction: "Try updating the SDK constraints.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an extension declaration or an
- // extension override is found in code that has an SDK constraint whose lower
- // bound is less than 2.6.0. Using extensions wasn't supported in earlier
- // versions, so this code won't be able to run against earlier versions of the
- // SDK.
- //
- // #### Examples
- //
- // Here's an example of a pubspec that defines an SDK constraint with a lower
- // bound of less than 2.6.0:
- //
- // ```yaml
- // %uri="pubspec.yaml"
- // environment:
- // sdk: '>=2.4.0 <2.7.0'
- // ```
- //
- // In the package that has that pubspec, code like the following produces
- // this diagnostic:
- //
- // ```dart
- // [!extension!] E on String {
- // void sayHello() {
- // print('Hello $this');
- // }
- // }
- // ```
- //
- // #### Common fixes
- //
- // If you don't need to support older versions of the SDK, then you can
- // increase the SDK constraint to allow the syntax to be used:
- //
- // ```yaml
- // environment:
- // sdk: '>=2.6.0 <2.7.0'
- // ```
- //
- // If you need to support older versions of the SDK, then rewrite the code to
- // not make use of extensions. The most common way to do this is to rewrite
- // the members of the extension as top-level functions (or methods) that take
- // the value that would have been bound to `this` as a parameter:
- //
- // ```dart
- // void sayHello(String s) {
- // print('Hello $s');
- // }
- // ```
- static const HintCode SDK_VERSION_EXTENSION_METHODS = HintCode(
- 'SDK_VERSION_EXTENSION_METHODS',
- "Extension methods weren't supported until version 2.6.0, "
- "but this code is required to be able to run on earlier versions.",
- correction: "Try updating the SDK constraints.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the operator `>>>` is used in
- // code that has an SDK constraint whose lower bound is less than 2.14.0. This
- // operator wasn't supported in earlier versions, so this code won't be able
- // to run against earlier versions of the SDK.
- //
- // #### Examples
- //
- // Here's an example of a pubspec that defines an SDK constraint with a lower
- // bound of less than 2.14.0:
- //
- // ```yaml
- // %uri="pubspec.yaml"
- // environment:
- // sdk: '>=2.0.0 <2.15.0'
- // ```
- //
- // In the package that has that pubspec, code like the following produces this
- // diagnostic:
- //
- // ```dart
- // int x = 3 [!>>>!] 4;
- // ```
- //
- // #### Common fixes
- //
- // If you don't need to support older versions of the SDK, then you can
- // increase the SDK constraint to allow the operator to be used:
- //
- // ```yaml
- // environment:
- // sdk: '>=2.14.0 <2.15.0'
- // ```
- //
- // If you need to support older versions of the SDK, then rewrite the code to
- // not use the `>>>` operator:
- //
- // ```dart
- // int x = logicalShiftRight(3, 4);
- //
- // int logicalShiftRight(int leftOperand, int rightOperand) {
- // int divisor = 1 << rightOperand;
- // if (divisor == 0) {
- // return 0;
- // }
- // return leftOperand ~/ divisor;
- // }
- // ```
- static const HintCode SDK_VERSION_GT_GT_GT_OPERATOR = HintCode(
- 'SDK_VERSION_GT_GT_GT_OPERATOR',
- "The operator '>>>' wasn't supported until version 2.14.0, but this code "
- "is required to be able to run on earlier versions.",
- correction: "Try updating the SDK constraints.");
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an `is` expression inside a
- // [constant context][] is found in code that has an SDK constraint whose
- // lower bound is less than 2.3.2. Using an `is` expression in a
- // [constant context][] wasn't supported in earlier versions, so this code
- // won't be able to run against earlier versions of the SDK.
- //
- // #### Examples
- //
- // Here's an example of a pubspec that defines an SDK constraint with a lower
- // bound of less than 2.3.2:
- //
- // ```yaml
- // %uri="pubspec.yaml"
- // environment:
- // sdk: '>=2.1.0 <2.4.0'
- // ```
- //
- // In the package that has that pubspec, code like the following produces
- // this diagnostic:
- //
- // ```dart
- // const Object x = 4;
- // const y = [!x is int!] ? 0 : 1;
- // ```
- //
- // #### Common fixes
- //
- // If you don't need to support older versions of the SDK, then you can
- // increase the SDK constraint to allow the expression to be used:
- //
- // ```yaml
- // environment:
- // sdk: '>=2.3.2 <2.4.0'
- // ```
- //
- // If you need to support older versions of the SDK, then either rewrite the
- // code to not use the `is` operator, or, if that isn't possible, change the
- // code so that the `is` expression isn't in a
- // [constant context][]:
- //
- // ```dart
- // const Object x = 4;
- // var y = x is int ? 0 : 1;
- // ```
- static const HintCode SDK_VERSION_IS_EXPRESSION_IN_CONST_CONTEXT = HintCode(
- 'SDK_VERSION_IS_EXPRESSION_IN_CONST_CONTEXT',
- "The use of an is expression in a constant context wasn't supported "
- "until version 2.3.2, but this code is required to be able to run on "
- "earlier versions.",
- correction: "Try updating the SDK constraints.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a reference to the class `Never`
- // is found in code that has an SDK constraint whose lower bound is less than
- // 2.12.0. This class wasn't defined in earlier versions, so this code won't
- // be able to run against earlier versions of the SDK.
- //
- // #### Examples
- //
- // Here's an example of a pubspec that defines an SDK constraint with a lower
- // bound of less than 2.12.0:
- //
- // ```yaml
- // %uri="pubspec.yaml"
- // environment:
- // sdk: '>=2.5.0 <2.6.0'
- // ```
- //
- // In the package that has that pubspec, code like the following produces this
- // diagnostic:
- //
- // ```dart
- // %language=2.9
- // [!Never!] n;
- // ```
- //
- // #### Common fixes
- //
- // If you don't need to support older versions of the SDK, then you can
- // increase the SDK constraint to allow the type to be used:
- //
- // ```yaml
- // environment:
- // sdk: '>=2.12.0 <2.13.0'
- // ```
- //
- // If you need to support older versions of the SDK, then rewrite the code to
- // not reference this class:
- //
- // ```dart
- // dynamic x;
- // ```
- static const HintCode SDK_VERSION_NEVER = HintCode(
- 'SDK_VERSION_NEVER',
- "The type 'Never' wasn't supported until version 2.12.0, but this code "
- "is required to be able to run on earlier versions.",
- correction: "Try updating the SDK constraints.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a set literal is found in code
- // that has an SDK constraint whose lower bound is less than 2.2.0. Set
- // literals weren't supported in earlier versions, so this code won't be able
- // to run against earlier versions of the SDK.
- //
- // #### Examples
- //
- // Here's an example of a pubspec that defines an SDK constraint with a lower
- // bound of less than 2.2.0:
- //
- // ```yaml
- // %uri="pubspec.yaml"
- // environment:
- // sdk: '>=2.1.0 <2.4.0'
- // ```
- //
- // In the package that has that pubspec, code like the following produces this
- // diagnostic:
- //
- // ```dart
- // var s = [!<int>{}!];
- // ```
- //
- // #### Common fixes
- //
- // If you don't need to support older versions of the SDK, then you can
- // increase the SDK constraint to allow the syntax to be used:
- //
- // ```yaml
- // environment:
- // sdk: '>=2.2.0 <2.4.0'
- // ```
- //
- // If you do need to support older versions of the SDK, then replace the set
- // literal with code that creates the set without the use of a literal:
- //
- // ```dart
- // var s = new Set<int>();
- // ```
- static const HintCode SDK_VERSION_SET_LITERAL = HintCode(
- 'SDK_VERSION_SET_LITERAL',
- "Set literals weren't supported until version 2.2, but this code is "
- "required to be able to run on earlier versions.",
- correction: "Try updating the SDK constraints.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a for, if, or spread element is
- // found in code that has an SDK constraint whose lower bound is less than
- // 2.3.0. Using a for, if, or spread element wasn't supported in earlier
- // versions, so this code won't be able to run against earlier versions of the
- // SDK.
- //
- // #### Examples
- //
- // Here's an example of a pubspec that defines an SDK constraint with a lower
- // bound of less than 2.3.0:
- //
- // ```yaml
- // %uri="pubspec.yaml"
- // environment:
- // sdk: '>=2.2.0 <2.4.0'
- // ```
- //
- // In the package that has that pubspec, code like the following produces
- // this diagnostic:
- //
- // ```dart
- // var digits = [[!for (int i = 0; i < 10; i++) i!]];
- // ```
- //
- // #### Common fixes
- //
- // If you don't need to support older versions of the SDK, then you can
- // increase the SDK constraint to allow the syntax to be used:
- //
- // ```yaml
- // environment:
- // sdk: '>=2.3.0 <2.4.0'
- // ```
- //
- // If you need to support older versions of the SDK, then rewrite the code to
- // not make use of those elements:
- //
- // ```dart
- // var digits = _initializeDigits();
- //
- // List<int> _initializeDigits() {
- // var digits = <int>[];
- // for (int i = 0; i < 10; i++) {
- // digits.add(i);
- // }
- // return digits;
- // }
- // ```
- static const HintCode SDK_VERSION_UI_AS_CODE = HintCode(
- 'SDK_VERSION_UI_AS_CODE',
- "The for, if, and spread elements weren't supported until version 2.3.0, "
- "but this code is required to be able to run on earlier versions.",
- correction: "Try updating the SDK constraints.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an if or spread element inside
- // a [constant context][] is found in code that has an SDK constraint whose
- // lower bound is less than 2.5.0. Using an if or spread element inside a
- // [constant context][] wasn't supported in earlier versions, so this code
- // won't be able to run against earlier versions of the SDK.
- //
- // #### Examples
- //
- // Here's an example of a pubspec that defines an SDK constraint with a lower
- // bound of less than 2.5.0:
- //
- // ```yaml
- // %uri="pubspec.yaml"
- // environment:
- // sdk: '>=2.4.0 <2.6.0'
- // ```
- //
- // In the package that has that pubspec, code like the following produces
- // this diagnostic:
- //
- // ```dart
- // const a = [1, 2];
- // const b = [[!...a!]];
- // ```
- //
- // #### Common fixes
- //
- // If you don't need to support older versions of the SDK, then you can
- // increase the SDK constraint to allow the syntax to be used:
- //
- // ```yaml
- // environment:
- // sdk: '>=2.5.0 <2.6.0'
- // ```
- //
- // If you need to support older versions of the SDK, then rewrite the code to
- // not make use of those elements:
- //
- // ```dart
- // const a = [1, 2];
- // const b = [1, 2];
- // ```
- //
- // If that isn't possible, change the code so that the element isn't in a
- // [constant context][]:
- //
- // ```dart
- // const a = [1, 2];
- // var b = [...a];
- // ```
- static const HintCode SDK_VERSION_UI_AS_CODE_IN_CONST_CONTEXT = HintCode(
- 'SDK_VERSION_UI_AS_CODE_IN_CONST_CONTEXT',
- "The if and spread elements weren't supported in constant expressions "
- "until version 2.5.0, but this code is required to be able to run on "
- "earlier versions.",
- correction: "Try updating the SDK constraints.",
- hasPublishedDocs: true);
-
- /**
- * When "strict-raw-types" is enabled, "raw types" must have type arguments.
- *
- * A "raw type" is a type name that does not use inference to fill in missing
- * type arguments; instead, each type argument is instantiated to its bound.
- */
- static const HintCode STRICT_RAW_TYPE = HintCode('STRICT_RAW_TYPE',
- "The generic type '{0}' should have explicit type arguments but doesn't.",
- correction: "Use explicit type arguments for '{0}'.");
-
- /**
- * Parameters:
- * 0: the name of the sealed class
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a sealed class (one that either
- // has the `@sealed` annotation or inherits or mixes in a sealed class) is
- // referenced in either the `extends`, `implements`, or `with` clause of a
- // class or mixin declaration if the declaration isn't in the same package as
- // the sealed class.
- //
- // #### Example
- //
- // Given a library in a package other than the package being analyzed that
- // contains the following:
- //
- // ```dart
- // %uri="package:a/a.dart"
- // import 'package:meta/meta.dart';
- //
- // class A {}
- //
- // @sealed
- // class B {}
- // ```
- //
- // The following code produces this diagnostic because `C`, which isn't in the
- // same package as `B`, is extending the sealed class `B`:
- //
- // ```dart
- // import 'package:a/a.dart';
- //
- // [!class C extends B {}!]
- // ```
- //
- // #### Common fixes
- //
- // If the class doesn't need to be a subtype of the sealed class, then change
- // the declaration so that it isn't:
- //
- // ```dart
- // import 'package:a/a.dart';
- //
- // class B extends A {}
- // ```
- //
- // If the class needs to be a subtype of the sealed class, then either change
- // the sealed class so that it's no longer sealed or move the subclass into
- // the same package as the sealed class.
- static const HintCode SUBTYPE_OF_SEALED_CLASS = HintCode(
- 'SUBTYPE_OF_SEALED_CLASS',
- "The class '{0}' shouldn't be extended, mixed in, or implemented because "
- "it's sealed.",
- correction:
- "Try composing instead of inheriting, or refer to the documentation "
- "of '{0}' for more information.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when there's a type check (using the
- // `as` operator) where the type is `Null`. There's only one value whose type
- // is `Null`, so the code is both more readable and more performant when it
- // tests for `null` explicitly.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the code is testing to
- // see whether the value of `s` is `null` by using a type check:
- //
- // ```dart
- // void f(String? s) {
- // if ([!s is Null!]) {
- // return;
- // }
- // print(s);
- // }
- // ```
- //
- // The following code produces this diagnostic because the code is testing to
- // see whether the value of `s` is something other than `null` by using a type
- // check:
- //
- // ```dart
- // void f(String? s) {
- // if ([!s is! Null!]) {
- // print(s);
- // }
- // }
- // ```
- //
- // #### Common fixes
- //
- // Replace the type check with the equivalent comparison with `null`:
- //
- // ```dart
- // void f(String? s) {
- // if (s == null) {
- // return;
- // }
- // print(s);
- // }
- // ```
- static const HintCode TYPE_CHECK_IS_NOT_NULL = HintCode(
- 'TYPE_CHECK_WITH_NULL',
- "Tests for non-null should be done with '!= null'.",
- correction: "Try replacing the 'is! Null' check with '!= null'.",
- hasPublishedDocs: true,
- uniqueName: 'TYPE_CHECK_IS_NOT_NULL');
-
- /**
- * No parameters.
- */
- static const HintCode TYPE_CHECK_IS_NULL = HintCode(
- 'TYPE_CHECK_WITH_NULL', "Tests for null should be done with '== null'.",
- correction: "Try replacing the 'is Null' check with '== null'.",
- hasPublishedDocs: true,
- uniqueName: 'TYPE_CHECK_IS_NULL');
-
- /**
- * Parameters:
- * 0: the name of the library being imported
- * 1: the name in the hide clause that isn't defined in the library
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a hide combinator includes a
- // name that isn't defined by the library being imported.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `dart:math` doesn't
- // define the name `String`:
- //
- // ```dart
- // import 'dart:math' hide [!String!], max;
- //
- // var x = min(0, 1);
- // ```
- //
- // #### Common fixes
- //
- // If a different name should be hidden, then correct the name. Otherwise,
- // remove the name from the list:
- //
- // ```dart
- // import 'dart:math' hide max;
- //
- // var x = min(0, 1);
- // ```
- static const HintCode UNDEFINED_HIDDEN_NAME = HintCode(
- 'UNDEFINED_HIDDEN_NAME',
- "The library '{0}' doesn't export a member with the hidden name '{1}'.",
- correction: "Try removing the name from the list of hidden members.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the undefined parameter
- * 1: the name of the targeted member
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an annotation of the form
- // `@UnusedResult.unless(parameterDefined: parameterName)` specifies a
- // parameter name that isn't defined by the annotated function.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the function `f`
- // doesn't have a parameter named `b`:
- //
- // ```dart
- // import 'package:meta/meta.dart';
- //
- // @UseResult.unless(parameterDefined: [!'b'!])
- // int f([int? a]) => a ?? 0;
- // ```
- //
- // #### Common fixes
- //
- // Change the argument named `parameterDefined` to match the name of one of
- // the parameters to the function:
- //
- // ```dart
- // import 'package:meta/meta.dart';
- //
- // @UseResult.unless(parameterDefined: 'a')
- // int f([int? a]) => a ?? 0;
- // ```
- static const HintCode UNDEFINED_REFERENCED_PARAMETER = HintCode(
- 'UNDEFINED_REFERENCED_PARAMETER',
- "The parameter '{0}' is not defined by '{1}'.");
-
- /**
- * Parameters:
- * 0: the name of the library being imported
- * 1: the name in the show clause that isn't defined in the library
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a show combinator includes a
- // name that isn't defined by the library being imported.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `dart:math` doesn't
- // define the name `String`:
- //
- // ```dart
- // import 'dart:math' show min, [!String!];
- //
- // var x = min(0, 1);
- // ```
- //
- // #### Common fixes
- //
- // If a different name should be shown, then correct the name. Otherwise,
- // remove the name from the list:
- //
- // ```dart
- // import 'dart:math' show min;
- //
- // var x = min(0, 1);
- // ```
- static const HintCode UNDEFINED_SHOWN_NAME = HintCode('UNDEFINED_SHOWN_NAME',
- "The library '{0}' doesn't export a member with the shown name '{1}'.",
- correction: "Try removing the name from the list of shown members.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the non-diagnostic being ignored
- */
- static const HintCode UNIGNORABLE_IGNORE = HintCode(
- 'UNIGNORABLE_IGNORE', "The diagnostic '{0}' can't be ignored.",
- correction:
- "Try removing the name from the list, or removing the whole comment "
- "if this is the only name in the list.");
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the value being cast is already
- // known to be of the type that it's being cast to.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `n` is already known to
- // be an `int` as a result of the `is` test:
- //
- // ```dart
- // void f(num n) {
- // if (n is int) {
- // ([!n as int!]).isEven;
- // }
- // }
- // ```
- //
- // #### Common fixes
- //
- // Remove the unnecessary cast:
- //
- // ```dart
- // void f(num n) {
- // if (n is int) {
- // n.isEven;
- // }
- // }
- // ```
- static const HintCode UNNECESSARY_CAST = HintCode(
- 'UNNECESSARY_CAST', "Unnecessary cast.",
- correction: "Try removing the cast.", hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the diagnostic being ignored
- */
- static const HintCode UNNECESSARY_IGNORE = HintCode(
- 'UNNECESSARY_IGNORE',
- "The diagnostic '{0}' isn't produced at this location so it doesn't "
- "need to be ignored.",
- correction:
- "Try removing the name from the list, or removing the whole comment "
- "if this is the only name in the list.");
-
- /**
- * Parameters:
- * 0: the uri that is not necessary
- * 1: the uri that makes it unnecessary
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an import isn't needed because
- // all of the names that are imported and referenced within the importing
- // library are also visible through another import.
- //
- // #### Example
- //
- // Given a file named `a.dart` that contains the following:
- //
- // ```dart
- // %uri="lib/a.dart"
- // class A {}
- // ```
- //
- // And, given a file named `b.dart` that contains the following:
- //
- // ```dart
- // %uri="lib/b.dart"
- // export 'a.dart';
- //
- // class B {}
- // ```
- //
- // The following code produces this diagnostic because the class `A`, which is
- // imported from `a.dart`, is also imported from `b.dart`. Removing the import
- // of `a.dart` leaves the semantics unchanged:
- //
- // ```dart
- // import [!'a.dart'!];
- // import 'b.dart';
- //
- // void f(A a, B b) {}
- // ```
- //
- // #### Common fixes
- //
- // If the import isn't needed, then remove it.
- //
- // If some of the names imported by this import are intended to be used but
- // aren't yet, and if those names aren't imported by other imports, then add
- // the missing references to those names.
- static const HintCode UNNECESSARY_IMPORT = HintCode(
- 'UNNECESSARY_IMPORT',
- "The import of '{0}' is unnecessary because all of the used elements are "
- "also provided by the import of '{1}'.",
- correction: 'Try removing the import directive.');
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when there's a declaration of
- // `noSuchMethod`, the only thing the declaration does is invoke the
- // overridden declaration, and the overridden declaration isn't the
- // declaration in `Object`.
- //
- // Overriding the implementation of `Object`'s `noSuchMethod` (no matter what
- // the implementation does) signals to the analyzer that it shouldn't flag any
- // inherited abstract methods that aren't implemented in that class. This
- // works even if the overriding implementation is inherited from a superclass,
- // so there's no value to declare it again in a subclass.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the declaration of
- // `noSuchMethod` in `A` makes the declaration of `noSuchMethod` in `B`
- // unnecessary:
- //
- // ```dart
- // class A {
- // @override
- // dynamic noSuchMethod(x) => super.noSuchMethod(x);
- // }
- // class B extends A {
- // @override
- // dynamic [!noSuchMethod!](y) {
- // return super.noSuchMethod(y);
- // }
- // }
- // ```
- //
- // #### Common fixes
- //
- // Remove the unnecessary declaration:
- //
- // ```dart
- // class A {
- // @override
- // dynamic noSuchMethod(x) => super.noSuchMethod(x);
- // }
- // class B extends A {}
- // ```
- static const HintCode UNNECESSARY_NO_SUCH_METHOD = HintCode(
- 'UNNECESSARY_NO_SUCH_METHOD', "Unnecessary 'noSuchMethod' declaration.",
- correction: "Try removing the declaration of 'noSuchMethod'.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when it finds an equality comparison
- // (either `==` or `!=`) with one operand of `null` and the other operand
- // can't be `null`. Such comparisons are always either `true` or `false`, so
- // they serve no purpose.
- //
- // #### Example
- //
- // The following code produces this diagnostic because `x` can never be
- // `null`, so the comparison always evaluates to `true`:
- //
- // ```dart
- // void f(int x) {
- // if (x [!!= null!]) {
- // print(x);
- // }
- // }
- // ```
- //
- // The following code produces this diagnostic because `x` can never be
- // `null`, so the comparison always evaluates to `false`:
- //
- // ```dart
- // void f(int x) {
- // if (x [!== null!]) {
- // throw ArgumentError("x can't be null");
- // }
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the other operand should be able to be `null`, then change the type of
- // the operand:
- //
- // ```dart
- // void f(int? x) {
- // if (x != null) {
- // print(x);
- // }
- // }
- // ```
- //
- // If the other operand really can't be `null`, then remove the condition:
- //
- // ```dart
- // void f(int x) {
- // print(x);
- // }
- // ```
- static const HintCode UNNECESSARY_NULL_COMPARISON_FALSE = HintCode(
- 'UNNECESSARY_NULL_COMPARISON',
- "The operand can't be null, so the condition is always false.",
- correction: "Try removing the condition, an enclosing condition, "
- "or the whole conditional statement.",
- hasPublishedDocs: true,
- uniqueName: 'UNNECESSARY_NULL_COMPARISON_FALSE',
- );
-
- /**
- * No parameters.
- */
- static const HintCode UNNECESSARY_NULL_COMPARISON_TRUE = HintCode(
- 'UNNECESSARY_NULL_COMPARISON',
- "The operand can't be null, so the condition is always true.",
- correction: "Remove the condition.",
- hasPublishedDocs: true,
- uniqueName: 'UNNECESSARY_NULL_COMPARISON_TRUE',
- );
-
- /**
- * Parameters:
- * 0: the name of the type
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when either the type `dynamic` or the
- // type `Null` is followed by a question mark. Both of these types are
- // inherently nullable so the question mark doesn't change the semantics.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the question mark
- // following `dynamic` isn't necessary:
- //
- // ```dart
- // dynamic[!?!] x;
- // ```
- //
- // #### Common fixes
- //
- // Remove the unneeded question mark:
- //
- // ```dart
- // dynamic x;
- // ```
- static const HintCode UNNECESSARY_QUESTION_MARK = HintCode(
- 'UNNECESSARY_QUESTION_MARK',
- "The '?' is unnecessary because '{0}' is nullable without it.");
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the value of a type check (using
- // either `is` or `is!`) is known at compile time.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the test `a is Object?`
- // is always `true`:
- //
- // ```dart
- // bool f<T>(T a) => [!a is Object?!];
- // ```
- //
- // #### Common fixes
- //
- // If the type check doesn't check what you intended to check, then change the
- // test:
- //
- // ```dart
- // bool f<T>(T a) => a is Object;
- // ```
- //
- // If the type check does check what you intended to check, then replace the
- // type check with its known value or completely remove it:
- //
- // ```dart
- // bool f<T>(T a) => true;
- // ```
- static const HintCode UNNECESSARY_TYPE_CHECK_FALSE = HintCode(
- 'UNNECESSARY_TYPE_CHECK',
- "Unnecessary type check; the result is always 'false'.",
- correction: "Try correcting the type check, or removing the type check.",
- hasPublishedDocs: true,
- uniqueName: 'UNNECESSARY_TYPE_CHECK_FALSE',
- );
-
- /**
- * No parameters.
- */
- static const HintCode UNNECESSARY_TYPE_CHECK_TRUE = HintCode(
- 'UNNECESSARY_TYPE_CHECK',
- "Unnecessary type check; the result is always 'true'.",
- correction: "Try correcting the type check, or removing the type check.",
- hasPublishedDocs: true,
- uniqueName: 'UNNECESSARY_TYPE_CHECK_TRUE',
- );
-
- /**
- * Parameters:
- * 0: the name of the exception variable
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a `catch` clause is found, and
- // neither the exception parameter nor the optional stack trace parameter are
- // used in the `catch` block.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `e` isn't referenced:
- //
- // ```dart
- // void f() {
- // try {
- // int.parse(';');
- // } on FormatException catch ([!e!]) {
- // // ignored
- // }
- // }
- // ```
- //
- // #### Common fixes
- //
- // Remove the unused `catch` clause:
- //
- // ```dart
- // void f() {
- // try {
- // int.parse(';');
- // } on FormatException {
- // // ignored
- // }
- // }
- // ```
- static const HintCode UNUSED_CATCH_CLAUSE = HintCode(
- 'UNUSED_CATCH_CLAUSE',
- "The exception variable '{0}' isn't used, so the 'catch' clause can be "
- "removed.",
- // TODO(brianwilkerson) Split this error code so that we can differentiate
- // between removing the catch clause and replacing the catch clause with
- // an on clause.
- correction: "Try removing the catch clause.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the stack trace variable
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the stack trace parameter in a
- // `catch` clause isn't referenced within the body of the `catch` block.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `stackTrace` isn't
- // referenced:
- //
- // ```dart
- // void f() {
- // try {
- // // ...
- // } catch (exception, [!stackTrace!]) {
- // // ...
- // }
- // }
- // ```
- //
- // #### Common fixes
- //
- // If you need to reference the stack trace parameter, then add a reference to
- // it. Otherwise, remove it:
- //
- // ```dart
- // void f() {
- // try {
- // // ...
- // } catch (exception) {
- // // ...
- // }
- // }
- // ```
- static const HintCode UNUSED_CATCH_STACK = HintCode('UNUSED_CATCH_STACK',
- "The stack trace variable '{0}' isn't used and can be removed.",
- correction: "Try removing the stack trace variable, or using it.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name that is declared but not referenced
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a private declaration isn't
- // referenced in the library that contains the declaration. The following
- // kinds of declarations are analyzed:
- // - Private top-level declarations, such as classes, enums, mixins, typedefs,
- // top-level variables, and top-level functions
- // - Private static and instance methods
- // - Optional parameters of private functions for which a value is never
- // passed, even when the parameter doesn't have a private name
- //
- // #### Examples
- //
- // Assuming that no code in the library references `_C`, the following code
- // produces this diagnostic:
- //
- // ```dart
- // class [!_C!] {}
- // ```
- //
- // Assuming that no code in the library passes a value for `y` in any
- // invocation of `_m`, the following code produces this diagnostic:
- //
- // ```dart
- // %language=2.9
- // class C {
- // void _m(int x, [int [!y!]]) {}
- //
- // void n() => _m(0);
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the declaration isn't needed, then remove it:
- //
- // ```dart
- // class C {
- // void _m(int x) {}
- //
- // void n() => _m(0);
- // }
- // ```
- //
- // If the declaration is intended to be used, then add the code to use it.
- static const HintCode UNUSED_ELEMENT = HintCode(
- 'UNUSED_ELEMENT', "The declaration '{0}' isn't referenced.",
- correction: "Try removing the declaration of '{0}'.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the parameter that is declared but not used
- */
- static const HintCode UNUSED_ELEMENT_PARAMETER = HintCode(
- 'UNUSED_ELEMENT',
- "A value for optional parameter '{0}' isn't ever given.",
- correction: "Try removing the unused parameter.",
- hasPublishedDocs: true,
- uniqueName: 'UNUSED_ELEMENT_PARAMETER',
- );
-
- /**
- * Parameters:
- * 0: the name of the unused field
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a private field is declared but
- // never read, even if it's written in one or more places.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because the field
- // `_originalValue` isn't read anywhere in the library:
- //
- // ```dart
- // class C {
- // final String [!_originalValue!];
- // final String _currentValue;
- //
- // C(this._originalValue) : _currentValue = _originalValue;
- //
- // String get value => _currentValue;
- // }
- // ```
- //
- // It might appear that the field `_originalValue` is being read in the
- // initializer (`_currentValue = _originalValue`), but that is actually a
- // reference to the parameter of the same name, not a reference to the field.
- //
- // #### Common fixes
- //
- // If the field isn't needed, then remove it.
- //
- // If the field was intended to be used, then add the missing code.
- static const HintCode UNUSED_FIELD = HintCode(
- 'UNUSED_FIELD', "The value of the field '{0}' isn't used.",
- correction: "Try removing the field, or using it.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the content of the unused import's uri
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an import isn't needed because
- // none of the names that are imported are referenced within the importing
- // library.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because nothing defined in
- // `dart:async` is referenced in the library:
- //
- // ```dart
- // import [!'dart:async'!];
- //
- // void main() {}
- // ```
- //
- // #### Common fixes
- //
- // If the import isn't needed, then remove it.
- //
- // If some of the imported names are intended to be used, then add the missing
- // code.
- static const HintCode UNUSED_IMPORT = HintCode(
- 'UNUSED_IMPORT', "Unused import: '{0}'.",
- correction: "Try removing the import directive.", hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the label that isn't used
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a label that isn't used is
- // found.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because the label `loop` isn't
- // referenced anywhere in the method:
- //
- // ```dart
- // void f(int limit) {
- // [!loop:!] for (int i = 0; i < limit; i++) {
- // print(i);
- // }
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the label isn't needed, then remove it:
- //
- // ```dart
- // void f(int limit) {
- // for (int i = 0; i < limit; i++) {
- // print(i);
- // }
- // }
- // ```
- //
- // If the label is needed, then use it:
- //
- // ```dart
- // void f(int limit) {
- // loop: for (int i = 0; i < limit; i++) {
- // print(i);
- // break loop;
- // }
- // }
- // ```
- // TODO(brianwilkerson) Highlight the identifier without the colon.
- static const HintCode UNUSED_LABEL =
- HintCode('UNUSED_LABEL', "The label '{0}' isn't used.",
- correction: "Try removing the label, or "
- "using it in either a 'break' or 'continue' statement.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the unused variable
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a local variable is declared but
- // never read, even if it's written in one or more places.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because the value of `count` is
- // never read:
- //
- // ```dart
- // void main() {
- // int [!count!] = 0;
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the variable isn't needed, then remove it.
- //
- // If the variable was intended to be used, then add the missing code.
- static const HintCode UNUSED_LOCAL_VARIABLE = HintCode(
- 'UNUSED_LOCAL_VARIABLE',
- "The value of the local variable '{0}' isn't used.",
- correction: "Try removing the variable or using it.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the annotated method, property or function
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a function annotated with
- // `useResult` is invoked, and the value returned by that function isn't used.
- // The value is considered to be used if a member of the value is invoked, if
- // the value is passed to another function, or if the value is assigned to a
- // variable or field.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the invocation of
- // `c.a()` isn't used, even though the method `a` is annotated with
- // `useResult`:
- //
- // ```dart
- // import 'package:meta/meta.dart';
- //
- // class C {
- // @useResult
- // int a() => 0;
- //
- // int b() => 0;
- // }
- //
- // void f(C c) {
- // c.[!a!]();
- // }
- // ```
- //
- // #### Common fixes
- //
- // If you intended to invoke the annotated function, then use the value that
- // was returned:
- //
- // ```dart
- // import 'package:meta/meta.dart';
- //
- // class C {
- // @useResult
- // int a() => 0;
- //
- // int b() => 0;
- // }
- //
- // void f(C c) {
- // print(c.a());
- // }
- // ```
- //
- // If you intended to invoke a different function, then correct the name of
- // the function being invoked:
- //
- // ```dart
- // import 'package:meta/meta.dart';
- //
- // class C {
- // @useResult
- // int a() => 0;
- //
- // int b() => 0;
- // }
- //
- // void f(C c) {
- // c.b();
- // }
- // ```
- static const HintCode UNUSED_RESULT = HintCode(
- 'UNUSED_RESULT',
- "The value of '{0}' should be used.",
- correction: "Try using the result by invoking a member, passing it to a "
- "function, or returning it from this function.",
- hasPublishedDocs: false,
- );
-
- /**
- * The result of invoking a method, property, or function annotated with
- * `@useResult` must be used (assigned, passed to a function as an argument,
- * or returned by a function).
- *
- * Parameters:
- * 0: the name of the annotated method, property or function
- * 1: message details
- */
- static const HintCode UNUSED_RESULT_WITH_MESSAGE = HintCode(
- 'UNUSED_RESULT',
- "'{0}' should be used. {1}.",
- // todo(pq): consider passing in correction details:
- // https://github.com/dart-lang/sdk/issues/46066
- correction:
- "Try using the result by invoking a member, passing it to a function, "
- "or returning it from this function.",
- hasPublishedDocs: false,
- uniqueName: 'UNUSED_RESULT_WITH_MESSAGE',
- );
-
- /**
- * Parameters:
- * 0: the name that is shown but not used
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a show combinator includes a
- // name that isn't used within the library. Because it isn't referenced, the
- // name can be removed.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because the function `max`
- // isn't used:
- //
- // ```dart
- // import 'dart:math' show min, [!max!];
- //
- // var x = min(0, 1);
- // ```
- //
- // #### Common fixes
- //
- // Either use the name or remove it:
- //
- // ```dart
- // import 'dart:math' show min;
- //
- // var x = min(0, 1);
- // ```
- static const HintCode UNUSED_SHOWN_NAME = HintCode(
- 'UNUSED_SHOWN_NAME', "The name {0} is shown, but isn’t used.",
- correction: "Try removing the name from the list of shown members.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a library is imported using the
- // `dart-ext` scheme.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the native library `x`
- // is being imported using a scheme of `dart-ext`:
- //
- // ```dart
- // [!import 'dart-ext:x';!]
- // int f() native 'string';
- // ```
- //
- // #### Common fixes
- //
- // Rewrite the code to use `dart:ffi` as a way of invoking the contents of the
- // native library.
- static const HintCode USE_OF_NATIVE_EXTENSION = HintCode(
- 'USE_OF_NATIVE_EXTENSION',
- "Dart native extensions are deprecated and aren’t available in Dart 2.15.",
- correction: "Try using dart:ffi for C interop.");
-
- /**
- * Initialize a newly created error code to have the given [name]. The message
- * associated with the error will be created from the given [message]
- * template. The correction associated with the error will be created from the
- * given [correction] template.
- */
- const HintCode(
- String name,
- String message, {
- String? correction,
- bool hasPublishedDocs = false,
- String? uniqueName,
- }) : super(
- correction: correction,
- hasPublishedDocs: hasPublishedDocs,
- message: message,
- name: name,
- uniqueName: 'HintCode.${uniqueName ?? name}',
- );
-
- @override
- ErrorSeverity get errorSeverity => ErrorType.HINT.severity;
-
- @override
- ErrorType get type => ErrorType.HINT;
-}
+export 'package:analyzer/src/dart/error/hint_codes.g.dart';
diff --git a/pkg/analyzer/lib/src/dart/error/hint_codes.g.dart b/pkg/analyzer/lib/src/dart/error/hint_codes.g.dart
new file mode 100644
index 0000000..f1f850a
--- /dev/null
+++ b/pkg/analyzer/lib/src/dart/error/hint_codes.g.dart
@@ -0,0 +1,3916 @@
+// 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 HintCode extends AnalyzerErrorCode {
+ /**
+ * Parameters:
+ * 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',
+ "The argument type '{0}' can't be assigned to the parameter type '{1} Function(Object)' or '{1} Function(Object, StackTrace)'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Users should not assign values marked `@doNotStore`.
+ */
+ static const HintCode ASSIGNMENT_OF_DO_NOT_STORE = HintCode(
+ 'ASSIGNMENT_OF_DO_NOT_STORE',
+ "'{0}' is marked 'doNotStore' and shouldn't be assigned to a field or top-level variable.",
+ correction: "Try removing the assignment.",
+ );
+
+ /**
+ * When the target expression uses '?.' operator, it can be `null`, so all the
+ * subsequent invocations should also use '?.' operator.
+ */
+ static const HintCode CAN_BE_NULL_AFTER_NULL_AWARE = HintCode(
+ 'CAN_BE_NULL_AFTER_NULL_AWARE',
+ "The receiver uses '?.', so its value can be null.",
+ correction: "Replace the '.' with a '?.' in the invocation.",
+ );
+
+ /**
+ * Dead code is code that is never reached, this can happen for instance if a
+ * statement follows a return statement.
+ *
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when code is found that won't be
+ // executed because execution will never reach the code.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because the invocation of
+ // `print` occurs after the function has returned:
+ //
+ // ```dart
+ // void f() {
+ // return;
+ // [!print('here');!]
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the code isn't needed, then remove it:
+ //
+ // ```dart
+ // void f() {
+ // return;
+ // }
+ // ```
+ //
+ // If the code needs to be executed, then either move the code to a place
+ // where it will be executed:
+ //
+ // ```dart
+ // void f() {
+ // print('here');
+ // return;
+ // }
+ // ```
+ //
+ // Or, rewrite the code before it, so that it can be reached:
+ //
+ // ```dart
+ // void f({bool skipPrinting = true}) {
+ // if (skipPrinting) {
+ // return;
+ // }
+ // print('here');
+ // }
+ // ```
+ static const HintCode DEAD_CODE = HintCode(
+ 'DEAD_CODE',
+ "Dead code.",
+ correction:
+ "Try removing the code, or fixing the code before it so that it can be reached.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Dead code is code that is never reached. This case covers cases where the
+ * user has catch clauses after `catch (e)` or `on Object catch (e)`.
+ *
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a `catch` clause is found that
+ // can't be executed because it’s after a `catch` clause of the form
+ // `catch (e)` or `on Object catch (e)`. The first `catch` clause that matches
+ // the thrown object is selected, and both of those forms will match any
+ // object, so no `catch` clauses that follow them will be selected.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic:
+ //
+ // ```dart
+ // void f() {
+ // try {
+ // } catch (e) {
+ // } [!on String {
+ // }!]
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the clause should be selectable, then move the clause before the general
+ // clause:
+ //
+ // ```dart
+ // void f() {
+ // try {
+ // } on String {
+ // } catch (e) {
+ // }
+ // }
+ // ```
+ //
+ // If the clause doesn't need to be selectable, then remove it:
+ //
+ // ```dart
+ // void f() {
+ // try {
+ // } catch (e) {
+ // }
+ // }
+ // ```
+ static const HintCode DEAD_CODE_CATCH_FOLLOWING_CATCH = HintCode(
+ 'DEAD_CODE_CATCH_FOLLOWING_CATCH',
+ "Dead code: Catch clauses after a 'catch (e)' or an 'on Object catch (e)' are never reached.",
+ correction:
+ "Try reordering the catch clauses so that they can be reached, or removing the unreachable catch clauses.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Dead code is code that is never reached. This case covers cases where the
+ * user has an on-catch clause such as `on A catch (e)`, where a supertype of
+ * `A` was already caught.
+ *
+ * Parameters:
+ * 0: name of the subtype
+ * 1: name of the supertype
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a `catch` clause is found that
+ // can't be executed because it is after a `catch` clause that catches either
+ // the same type or a supertype of the clause's type. The first `catch` clause
+ // that matches the thrown object is selected, and the earlier clause always
+ // matches anything matchable by the highlighted clause, so the highlighted
+ // clause will never be selected.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic:
+ //
+ // ```dart
+ // void f() {
+ // try {
+ // } on num {
+ // } [!on int {
+ // }!]
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the clause should be selectable, then move the clause before the general
+ // clause:
+ //
+ // ```dart
+ // void f() {
+ // try {
+ // } on int {
+ // } on num {
+ // }
+ // }
+ // ```
+ //
+ // If the clause doesn't need to be selectable, then remove it:
+ //
+ // ```dart
+ // void f() {
+ // try {
+ // } on num {
+ // }
+ // }
+ // ```
+ static const HintCode DEAD_CODE_ON_CATCH_SUBTYPE = HintCode(
+ 'DEAD_CODE_ON_CATCH_SUBTYPE',
+ "Dead code: This on-catch block won’t be executed because '{0}' is a subtype of '{1}' and hence will have been caught already.",
+ correction:
+ "Try reordering the catch clauses so that this block can be reached, or removing the unreachable catch clause.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the class `Function` is used in
+ // either the `extends`, `implements`, or `with` clause of a class or mixin.
+ // Using the class `Function` in this way has no semantic value, so it's
+ // effectively dead code.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because `Function` is used as
+ // the superclass of `F`:
+ //
+ // ```dart
+ // class F extends [!Function!] {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Remove the class `Function` from whichever clause it's in, and remove the
+ // whole clause if `Function` is the only type in the clause:
+ //
+ // ```dart
+ // class F {}
+ // ```
+ static const HintCode DEPRECATED_EXTENDS_FUNCTION = HintCode(
+ 'DEPRECATED_SUBTYPE_OF_FUNCTION',
+ "Extending 'Function' is deprecated.",
+ correction: "Try removing 'Function' from the 'extends' clause.",
+ hasPublishedDocs: true,
+ uniqueName: 'DEPRECATED_EXTENDS_FUNCTION',
+ );
+
+ /**
+ * Users should not create a class named `Function` anymore.
+ */
+ static const HintCode DEPRECATED_FUNCTION_CLASS_DECLARATION = HintCode(
+ 'DEPRECATED_FUNCTION_CLASS_DECLARATION',
+ "Declaring a class named 'Function' is deprecated.",
+ correction: "Try renaming the class.",
+ );
+
+ /**
+ * No parameters.
+ */
+ static const HintCode DEPRECATED_IMPLEMENTS_FUNCTION = HintCode(
+ 'DEPRECATED_SUBTYPE_OF_FUNCTION',
+ "Implementing 'Function' has no effect.",
+ correction: "Try removing 'Function' from the 'implements' clause.",
+ hasPublishedDocs: true,
+ uniqueName: 'DEPRECATED_IMPLEMENTS_FUNCTION',
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the member
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a deprecated library or class
+ // member is used in a different package.
+ //
+ // #### Examples
+ //
+ // If the method `m` in the class `C` is annotated with `@deprecated`, then
+ // the following code produces this diagnostic:
+ //
+ // ```dart
+ // void f(C c) {
+ // c.[!m!]();
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // The documentation for declarations that are annotated with `@deprecated`
+ // should indicate what code to use in place of the deprecated code.
+ static const HintCode DEPRECATED_MEMBER_USE = HintCode(
+ 'DEPRECATED_MEMBER_USE',
+ "'{0}' is deprecated and shouldn't be used.",
+ correction:
+ "Try replacing the use of the deprecated member with the replacement.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the member
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a deprecated library member or
+ // class member is used in the same package in which it's declared.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `x` is deprecated:
+ //
+ // ```dart
+ // @deprecated
+ // var x = 0;
+ // var y = [!x!];
+ // ```
+ //
+ // #### Common fixes
+ //
+ // The fix depends on what's been deprecated and what the replacement is. The
+ // documentation for deprecated declarations should indicate what code to use
+ // in place of the deprecated code.
+ static const HintCode DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE = HintCode(
+ 'DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE',
+ "'{0}' is deprecated and shouldn't be used.",
+ correction:
+ "Try replacing the use of the deprecated member with the replacement.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the member
+ * 1: message details
+ */
+ static const HintCode DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE_WITH_MESSAGE =
+ HintCode(
+ 'DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE',
+ "'{0}' is deprecated and shouldn't be used. {1}.",
+ correction:
+ "Try replacing the use of the deprecated member with the replacement.",
+ hasPublishedDocs: true,
+ uniqueName: 'DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE_WITH_MESSAGE',
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the member
+ * 1: message details
+ */
+ static const HintCode DEPRECATED_MEMBER_USE_WITH_MESSAGE = HintCode(
+ 'DEPRECATED_MEMBER_USE',
+ "'{0}' is deprecated and shouldn't be used. {1}.",
+ correction:
+ "Try replacing the use of the deprecated member with the replacement.",
+ hasPublishedDocs: true,
+ uniqueName: 'DEPRECATED_MEMBER_USE_WITH_MESSAGE',
+ );
+
+ /**
+ * No parameters.
+ */
+ static const HintCode DEPRECATED_MIXIN_FUNCTION = HintCode(
+ 'DEPRECATED_SUBTYPE_OF_FUNCTION',
+ "Mixing in 'Function' is deprecated.",
+ correction: "Try removing 'Function' from the 'with' clause.",
+ hasPublishedDocs: true,
+ uniqueName: 'DEPRECATED_MIXIN_FUNCTION',
+ );
+
+ /**
+ * Hint to use the ~/ operator.
+ */
+ static const HintCode DIVISION_OPTIMIZATION = HintCode(
+ 'DIVISION_OPTIMIZATION',
+ "The operator x ~/ y is more efficient than (x / y).toInt().",
+ correction: "Try re-writing the expression to use the '~/' operator.",
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a name occurs multiple times in
+ // a `hide` clause. Repeating the name is unnecessary.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the name `min` is
+ // hidden more than once:
+ //
+ // ```dart
+ // import 'dart:math' hide min, [!min!];
+ //
+ // var x = pi;
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the name was mistyped in one or more places, then correct the mistyped
+ // names:
+ //
+ // ```dart
+ // import 'dart:math' hide max, min;
+ //
+ // var x = pi;
+ // ```
+ //
+ // If the name wasn't mistyped, then remove the unnecessary name from the
+ // list:
+ //
+ // ```dart
+ // import 'dart:math' hide min;
+ //
+ // var x = pi;
+ // ```
+ static const HintCode DUPLICATE_HIDDEN_NAME = HintCode(
+ 'DUPLICATE_HIDDEN_NAME',
+ "Duplicate hidden name.",
+ correction:
+ "Try removing the repeated name from the list of hidden members.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the diagnostic being ignored
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a diagnostic name appears in an
+ // `ignore` comment, but the diagnostic is already being ignored, either
+ // because it's already included in the same `ignore` comment or because it
+ // appears in an `ignore-in-file` comment.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the diagnostic named
+ // `unused_local_variable` is already being ignored for the whole file so it
+ // doesn't need to be ignored on a specific line:
+ //
+ // ```dart
+ // // ignore_for_file: unused_local_variable
+ // void f() {
+ // // ignore: [!unused_local_variable!]
+ // var x = 0;
+ // }
+ // ```
+ //
+ // The following code produces this diagnostic because the diagnostic named
+ // `unused_local_variable` is being ignored twice on the same line:
+ //
+ // ```dart
+ // void f() {
+ // // ignore: unused_local_variable, [!unused_local_variable!]
+ // var x = 0;
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Remove the ignore comment, or remove the unnecessary diagnostic name if the
+ // ignore comment is ignoring more than one diagnostic:
+ //
+ // ```dart
+ // // ignore_for_file: unused_local_variable
+ // void f() {
+ // var x = 0;
+ // }
+ // ```
+ static const HintCode DUPLICATE_IGNORE = HintCode(
+ 'DUPLICATE_IGNORE',
+ "The diagnostic '{0}' doesn't need to be ignored here because it's already being ignored.",
+ correction:
+ "Try removing the name from the list, or removing the whole comment if this is the only name in the list.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Duplicate imports.
+ *
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an import directive is found
+ // that is the same as an import before it in the file. The second import
+ // doesn’t add value and should be removed.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic:
+ //
+ // ```dart
+ // import 'package:meta/meta.dart';
+ // import [!'package:meta/meta.dart'!];
+ //
+ // @sealed class C {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Remove the unnecessary import:
+ //
+ // ```dart
+ // import 'package:meta/meta.dart';
+ //
+ // @sealed class C {}
+ // ```
+ static const HintCode DUPLICATE_IMPORT = HintCode(
+ 'DUPLICATE_IMPORT',
+ "Duplicate import.",
+ correction: "Try removing all but one import of the library.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a name occurs multiple times in
+ // a `show` clause. Repeating the name is unnecessary.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the name `min` is shown
+ // more than once:
+ //
+ // ```dart
+ // import 'dart:math' show min, [!min!];
+ //
+ // var x = min(2, min(0, 1));
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the name was mistyped in one or more places, then correct the mistyped
+ // names:
+ //
+ // ```dart
+ // import 'dart:math' show max, min;
+ //
+ // var x = max(2, min(0, 1));
+ // ```
+ //
+ // If the name wasn't mistyped, then remove the unnecessary name from the
+ // list:
+ //
+ // ```dart
+ // import 'dart:math' show min;
+ //
+ // var x = min(2, min(0, 1));
+ // ```
+ static const HintCode DUPLICATE_SHOWN_NAME = HintCode(
+ 'DUPLICATE_SHOWN_NAME',
+ "Duplicate shown name.",
+ correction:
+ "Try removing the repeated name from the list of shown members.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an element in a non-constant set
+ // is the same as a previous element in the same set. If two elements are the
+ // same, then the second value is ignored, which makes having both elements
+ // pointless and likely signals a bug.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the element `1` appears
+ // twice:
+ //
+ // ```dart
+ // const a = 1;
+ // const b = 1;
+ // var s = <int>{a, [!b!]};
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If both elements should be included in the set, then change one of the
+ // elements:
+ //
+ // ```dart
+ // const a = 1;
+ // const b = 2;
+ // var s = <int>{a, b};
+ // ```
+ //
+ // If only one of the elements is needed, then remove the one that isn't
+ // needed:
+ //
+ // ```dart
+ // const a = 1;
+ // var s = <int>{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 HintCode EQUAL_ELEMENTS_IN_SET = HintCode(
+ 'EQUAL_ELEMENTS_IN_SET',
+ "Two elements in a set literal shouldn't be equal.",
+ correction: "Change or remove the duplicate element.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a key in a non-constant map is
+ // the same as a previous key in the same map. If two keys are the same, then
+ // the second value overwrites the first value, which makes having both pairs
+ // pointless and likely signals a bug.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the keys `a` and `b`
+ // have the same value:
+ //
+ // ```dart
+ // const a = 1;
+ // const b = 1;
+ // var m = <int, String>{a: 'a', [!b!]: 'b'};
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If both entries should be included in the map, then change one of the keys:
+ //
+ // ```dart
+ // const a = 1;
+ // const b = 2;
+ // var m = <int, String>{a: 'a', b: 'b'};
+ // ```
+ //
+ // If only one of the entries is needed, then remove the one that isn't
+ // needed:
+ //
+ // ```dart
+ // const a = 1;
+ // var m = <int, String>{a: 'a'};
+ // ```
+ //
+ // Note that literal maps preserve the order of their entries, so the choice
+ // of which entry to remove might affect the order in which the keys and
+ // values are returned by an iterator.
+ static const HintCode EQUAL_KEYS_IN_MAP = HintCode(
+ 'EQUAL_KEYS_IN_MAP',
+ "Two keys in a map literal shouldn't be equal.",
+ correction: "Change or remove the duplicate key.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * It is a bad practice for a source file in a package "lib" directory
+ * hierarchy to traverse outside that directory hierarchy. For example, a
+ * source file in the "lib" directory should not contain a directive such as
+ * `import '../web/some.dart'` which references a file outside the lib
+ * directory.
+ */
+ static const HintCode FILE_IMPORT_INSIDE_LIB_REFERENCES_FILE_OUTSIDE =
+ HintCode(
+ 'FILE_IMPORT_INSIDE_LIB_REFERENCES_FILE_OUTSIDE',
+ "A file in the 'lib' directory shouldn't import a file outside the 'lib' directory.",
+ correction:
+ "Try removing the import, or moving the imported file inside the 'lib' directory.",
+ );
+
+ /**
+ * It is a bad practice for a source file ouside a package "lib" directory
+ * hierarchy to traverse into that directory hierarchy. For example, a source
+ * file in the "web" directory should not contain a directive such as
+ * `import '../lib/some.dart'` which references a file inside the lib
+ * directory.
+ */
+ static const HintCode FILE_IMPORT_OUTSIDE_LIB_REFERENCES_FILE_INSIDE =
+ HintCode(
+ 'FILE_IMPORT_OUTSIDE_LIB_REFERENCES_FILE_INSIDE',
+ "A file outside the 'lib' directory shouldn't reference a file inside the 'lib' directory using a relative path.",
+ correction: "Try using a package: URI instead.",
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a library that declares a
+ // function named `loadLibrary` is imported using a deferred import. A
+ // deferred import introduces an implicit function named `loadLibrary`. This
+ // function is used to load the contents of the deferred library, and the
+ // implicit function hides the explicit declaration in the deferred library.
+ //
+ // 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 function named `loadLibrary`:
+ //
+ // ```dart
+ // %uri="lib/a.dart"
+ // void loadLibrary(Library library) {}
+ //
+ // class Library {}
+ // ```
+ //
+ // The following code produces this diagnostic because the implicit
+ // declaration of `a.loadLibrary` is hiding the explicit declaration of
+ // `loadLibrary` in `a.dart`:
+ //
+ // ```dart
+ // [!import 'a.dart' deferred as a;!]
+ //
+ // void f() {
+ // a.Library();
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the imported library isn't required to be deferred, then remove the
+ // keyword `deferred`:
+ //
+ // ```dart
+ // import 'a.dart' as a;
+ //
+ // void f() {
+ // a.Library();
+ // }
+ // ```
+ //
+ // If the imported library is required to be deferred and you need to
+ // reference the imported function, then rename the function in the imported
+ // library:
+ //
+ // ```dart
+ // void populateLibrary(Library library) {}
+ //
+ // class Library {}
+ // ```
+ //
+ // If the imported library is required to be deferred and you don't need to
+ // reference the imported function, then add a `hide` clause:
+ //
+ // ```dart
+ // import 'a.dart' deferred as a hide loadLibrary;
+ //
+ // void f() {
+ // a.Library();
+ // }
+ // ```
+ //
+ // If type arguments shouldn't be required for the class, then mark the class
+ // with the `@optionalTypeArgs` annotation (from `package:meta`):
+ static const HintCode IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION = HintCode(
+ 'IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION',
+ "The imported library defines a top-level function named 'loadLibrary' that is hidden by deferring this library.",
+ correction:
+ "Try changing the import to not be deferred, or rename the function in the imported library.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * https://github.com/dart-lang/sdk/issues/44063
+ */
+ static const HintCode IMPORT_OF_LEGACY_LIBRARY_INTO_NULL_SAFE = HintCode(
+ 'IMPORT_OF_LEGACY_LIBRARY_INTO_NULL_SAFE',
+ "The library '{0}' is legacy, and should not be imported into a null safe library.",
+ correction: "Try migrating the imported library.",
+ );
+
+ /**
+ * When "strict-inference" is enabled, collection literal types must be
+ * inferred via the context type, or have type arguments.
+ */
+ static const HintCode INFERENCE_FAILURE_ON_COLLECTION_LITERAL = HintCode(
+ 'INFERENCE_FAILURE_ON_COLLECTION_LITERAL',
+ "The type argument(s) of '{0}' can't be inferred.",
+ correction: "Use explicit type argument(s) for '{0}'.",
+ );
+
+ /**
+ * When "strict-inference" is enabled, types in function invocations must be
+ * inferred via the context type, or have type arguments.
+ */
+ static const HintCode INFERENCE_FAILURE_ON_FUNCTION_INVOCATION = HintCode(
+ 'INFERENCE_FAILURE_ON_FUNCTION_INVOCATION',
+ "The type argument(s) of the function '{0}' can't be inferred.",
+ correction: "Use explicit type argument(s) for '{0}'.",
+ );
+
+ /**
+ * When "strict-inference" is enabled, recursive local functions, top-level
+ * functions, methods, and function-typed function parameters must all
+ * specify a return type. See the strict-inference resource:
+ *
+ * https://github.com/dart-lang/language/blob/master/resources/type-system/strict-inference.md
+ */
+ static const HintCode INFERENCE_FAILURE_ON_FUNCTION_RETURN_TYPE = HintCode(
+ 'INFERENCE_FAILURE_ON_FUNCTION_RETURN_TYPE',
+ "The return type of '{0}' cannot be inferred.",
+ correction: "Declare the return type of '{0}'.",
+ );
+
+ /**
+ * When "strict-inference" is enabled, types in function invocations must be
+ * inferred via the context type, or have type arguments.
+ */
+ static const HintCode INFERENCE_FAILURE_ON_GENERIC_INVOCATION = HintCode(
+ 'INFERENCE_FAILURE_ON_GENERIC_INVOCATION',
+ "The type argument(s) of the generic function type '{0}' can't be inferred.",
+ correction: "Use explicit type argument(s) for '{0}'.",
+ );
+
+ /**
+ * When "strict-inference" is enabled, types in instance creation
+ * (constructor calls) must be inferred via the context type, or have type
+ * arguments.
+ */
+ static const HintCode INFERENCE_FAILURE_ON_INSTANCE_CREATION = HintCode(
+ 'INFERENCE_FAILURE_ON_INSTANCE_CREATION',
+ "The type argument(s) of the constructor '{0}' can't be inferred.",
+ correction: "Use explicit type argument(s) for '{0}'.",
+ );
+
+ /**
+ * When "strict-inference" in enabled, uninitialized variables must be
+ * declared with a specific type.
+ */
+ static const HintCode INFERENCE_FAILURE_ON_UNINITIALIZED_VARIABLE = HintCode(
+ 'INFERENCE_FAILURE_ON_UNINITIALIZED_VARIABLE',
+ "The type of {0} can't be inferred without either a type or initializer.",
+ correction: "Try specifying the type of the variable.",
+ );
+
+ /**
+ * When "strict-inference" in enabled, function parameters must be
+ * declared with a specific type, or inherit a type.
+ */
+ static const HintCode INFERENCE_FAILURE_ON_UNTYPED_PARAMETER = HintCode(
+ 'INFERENCE_FAILURE_ON_UNTYPED_PARAMETER',
+ "The type of {0} can't be inferred; a type must be explicitly provided.",
+ correction: "Try specifying the type of the parameter.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the annotation
+ * 1: the list of valid targets
+ */
+ static const HintCode INVALID_ANNOTATION_TARGET = HintCode(
+ 'INVALID_ANNOTATION_TARGET',
+ "The annotation '{0}' can only be used on {1}",
+ );
+
+ /**
+ * This hint is generated anywhere where an element annotated with `@internal`
+ * is exported as a part of a package's public API.
+ *
+ * Parameters:
+ * 0: the name of the element
+ */
+ static const HintCode INVALID_EXPORT_OF_INTERNAL_ELEMENT = HintCode(
+ 'INVALID_EXPORT_OF_INTERNAL_ELEMENT',
+ "The member '{0}' can't be exported as a part of a package's public API.",
+ correction: "Try using a hide clause to hide '{0}'.",
+ );
+
+ /**
+ * This hint is generated anywhere where an element annotated with `@internal`
+ * is exported indirectly as a part of a package's public API.
+ *
+ * Parameters:
+ * 0: the name of the element
+ */
+ static const HintCode INVALID_EXPORT_OF_INTERNAL_ELEMENT_INDIRECTLY =
+ HintCode(
+ 'INVALID_EXPORT_OF_INTERNAL_ELEMENT_INDIRECTLY',
+ "The member '{0}' can't be exported as a part of a package's public API, but is indirectly exported as part of the signature of '{1}'.",
+ correction: "Try using a hide clause to hide '{0}'.",
+ );
+
+ /**
+ * This hint is generated anywhere a @factory annotation is associated with
+ * anything other than a method.
+ */
+ static const HintCode INVALID_FACTORY_ANNOTATION = HintCode(
+ 'INVALID_FACTORY_ANNOTATION',
+ "Only methods can be annotated as factories.",
+ );
+
+ /**
+ * This hint is generated anywhere a @factory annotation is associated with
+ * a method that does not declare a return type.
+ */
+ static const HintCode INVALID_FACTORY_METHOD_DECL = HintCode(
+ 'INVALID_FACTORY_METHOD_DECL',
+ "Factory method '{0}' must have a return type.",
+ );
+
+ /**
+ * This hint is generated anywhere a @factory annotation is associated with
+ * a non-abstract method that can return anything other than a newly allocated
+ * object.
+ *
+ * Parameters:
+ * 0: the name of the method
+ */
+ static const HintCode INVALID_FACTORY_METHOD_IMPL = HintCode(
+ 'INVALID_FACTORY_METHOD_IMPL',
+ "Factory method '{0}' doesn't return a newly allocated object.",
+ );
+
+ /**
+ * This hint is generated anywhere an @immutable annotation is associated with
+ * anything other than a class.
+ */
+ static const HintCode INVALID_IMMUTABLE_ANNOTATION = HintCode(
+ 'INVALID_IMMUTABLE_ANNOTATION',
+ "Only classes can be annotated as being immutable.",
+ );
+
+ /**
+ * This hint is generated anywhere a @internal annotation is associated with
+ * an element found in a package's public API.
+ */
+ static const HintCode INVALID_INTERNAL_ANNOTATION = HintCode(
+ 'INVALID_INTERNAL_ANNOTATION',
+ "Only public elements in a package's private API can be annotated as being internal.",
+ );
+
+ /**
+ * Invalid Dart language version comments don't follow the specification [1].
+ * If a comment begins with "@dart" or "dart" (letters in any case),
+ * followed by optional whitespace, followed by optional non-alphanumeric,
+ * non-whitespace characters, followed by optional whitespace, followed by
+ * an optional alphabetical character, followed by a digit, then the
+ * comment is considered to be an attempt at a language version override
+ * comment. If this attempted language version override comment is not a
+ * valid language version override comment, it is reported.
+ *
+ * [1] https://github.com/dart-lang/language/blob/master/accepted/future-releases/language-versioning/feature-specification.md#individual-library-language-version-override
+ */
+ static const HintCode INVALID_LANGUAGE_VERSION_OVERRIDE_AT_SIGN = HintCode(
+ 'INVALID_LANGUAGE_VERSION_OVERRIDE',
+ "The Dart language version override number must begin with '@dart'",
+ correction:
+ "Specify a Dart language version override with a comment like '// @dart = 2.0'.",
+ uniqueName: 'INVALID_LANGUAGE_VERSION_OVERRIDE_AT_SIGN',
+ );
+
+ /**
+ * Invalid Dart language version comments don't follow the specification [1].
+ * If a comment begins with "@dart" or "dart" (letters in any case),
+ * followed by optional whitespace, followed by optional non-alphanumeric,
+ * non-whitespace characters, followed by optional whitespace, followed by
+ * an optional alphabetical character, followed by a digit, then the
+ * comment is considered to be an attempt at a language version override
+ * comment. If this attempted language version override comment is not a
+ * valid language version override comment, it is reported.
+ *
+ * [1] https://github.com/dart-lang/language/blob/master/accepted/future-releases/language-versioning/feature-specification.md#individual-library-language-version-override
+ */
+ static const HintCode INVALID_LANGUAGE_VERSION_OVERRIDE_EQUALS = HintCode(
+ 'INVALID_LANGUAGE_VERSION_OVERRIDE',
+ "The Dart language version override comment must be specified with an '=' character",
+ correction:
+ "Specify a Dart language version override with a comment like '// @dart = 2.0'.",
+ uniqueName: 'INVALID_LANGUAGE_VERSION_OVERRIDE_EQUALS',
+ );
+
+ static const HintCode INVALID_LANGUAGE_VERSION_OVERRIDE_GREATER = HintCode(
+ 'INVALID_LANGUAGE_VERSION_OVERRIDE',
+ "The language version override can't specify a version greater than the latest known language version: {0}.{1}",
+ correction: "Try removing the language version override.",
+ uniqueName: 'INVALID_LANGUAGE_VERSION_OVERRIDE_GREATER',
+ );
+
+ static const HintCode INVALID_LANGUAGE_VERSION_OVERRIDE_LOCATION = HintCode(
+ 'INVALID_LANGUAGE_VERSION_OVERRIDE',
+ "The language version override must be before any declaration or directive.",
+ correction:
+ "Try moving the language version override to the top of the file.",
+ uniqueName: 'INVALID_LANGUAGE_VERSION_OVERRIDE_LOCATION',
+ );
+
+ /**
+ * Invalid Dart language version comments don't follow the specification [1].
+ * If a comment begins with "@dart" or "dart" (letters in any case),
+ * followed by optional whitespace, followed by optional non-alphanumeric,
+ * non-whitespace characters, followed by optional whitespace, followed by
+ * an optional alphabetical character, followed by a digit, then the
+ * comment is considered to be an attempt at a language version override
+ * comment. If this attempted language version override comment is not a
+ * valid language version override comment, it is reported.
+ *
+ * [1] https://github.com/dart-lang/language/blob/master/accepted/future-releases/language-versioning/feature-specification.md#individual-library-language-version-override
+ */
+ static const HintCode INVALID_LANGUAGE_VERSION_OVERRIDE_LOWER_CASE = HintCode(
+ 'INVALID_LANGUAGE_VERSION_OVERRIDE',
+ "The Dart language version override comment must be specified with the word 'dart' in all lower case",
+ correction:
+ "Specify a Dart language version override with a comment like '// @dart = 2.0'.",
+ uniqueName: 'INVALID_LANGUAGE_VERSION_OVERRIDE_LOWER_CASE',
+ );
+
+ /**
+ * Invalid Dart language version comments don't follow the specification [1].
+ * If a comment begins with "@dart" or "dart" (letters in any case),
+ * followed by optional whitespace, followed by optional non-alphanumeric,
+ * non-whitespace characters, followed by optional whitespace, followed by
+ * an optional alphabetical character, followed by a digit, then the
+ * comment is considered to be an attempt at a language version override
+ * comment. If this attempted language version override comment is not a
+ * valid language version override comment, it is reported.
+ *
+ * [1] https://github.com/dart-lang/language/blob/master/accepted/future-releases/language-versioning/feature-specification.md#individual-library-language-version-override
+ */
+ static const HintCode INVALID_LANGUAGE_VERSION_OVERRIDE_NUMBER = HintCode(
+ 'INVALID_LANGUAGE_VERSION_OVERRIDE',
+ "The Dart language version override comment must be specified with a version number, like '2.0', after the '=' character.",
+ correction:
+ "Specify a Dart language version override with a comment like '// @dart = 2.0'.",
+ uniqueName: 'INVALID_LANGUAGE_VERSION_OVERRIDE_NUMBER',
+ );
+
+ /**
+ * Invalid Dart language version comments don't follow the specification [1].
+ * If a comment begins with "@dart" or "dart" (letters in any case),
+ * followed by optional whitespace, followed by optional non-alphanumeric,
+ * non-whitespace characters, followed by optional whitespace, followed by
+ * an optional alphabetical character, followed by a digit, then the
+ * comment is considered to be an attempt at a language version override
+ * comment. If this attempted language version override comment is not a
+ * valid language version override comment, it is reported.
+ *
+ * [1] https://github.com/dart-lang/language/blob/master/accepted/future-releases/language-versioning/feature-specification.md#individual-library-language-version-override
+ */
+ static const HintCode INVALID_LANGUAGE_VERSION_OVERRIDE_PREFIX = HintCode(
+ 'INVALID_LANGUAGE_VERSION_OVERRIDE',
+ "The Dart language version override number can't be prefixed with a letter",
+ correction:
+ "Specify a Dart language version override with a comment like '// @dart = 2.0'.",
+ uniqueName: 'INVALID_LANGUAGE_VERSION_OVERRIDE_PREFIX',
+ );
+
+ /**
+ * Invalid Dart language version comments don't follow the specification [1].
+ * If a comment begins with "@dart" or "dart" (letters in any case),
+ * followed by optional whitespace, followed by optional non-alphanumeric,
+ * non-whitespace characters, followed by optional whitespace, followed by
+ * an optional alphabetical character, followed by a digit, then the
+ * comment is considered to be an attempt at a language version override
+ * comment. If this attempted language version override comment is not a
+ * valid language version override comment, it is reported.
+ *
+ * [1] https://github.com/dart-lang/language/blob/master/accepted/future-releases/language-versioning/feature-specification.md#individual-library-language-version-override
+ */
+ static const HintCode INVALID_LANGUAGE_VERSION_OVERRIDE_TRAILING_CHARACTERS =
+ HintCode(
+ 'INVALID_LANGUAGE_VERSION_OVERRIDE',
+ "The Dart language version override comment can't be followed by any non-whitespace characters",
+ correction:
+ "Specify a Dart language version override with a comment like '// @dart = 2.0'.",
+ uniqueName: 'INVALID_LANGUAGE_VERSION_OVERRIDE_TRAILING_CHARACTERS',
+ );
+
+ /**
+ * Invalid Dart language version comments don't follow the specification [1].
+ * If a comment begins with "@dart" or "dart" (letters in any case),
+ * followed by optional whitespace, followed by optional non-alphanumeric,
+ * non-whitespace characters, followed by optional whitespace, followed by
+ * an optional alphabetical character, followed by a digit, then the
+ * comment is considered to be an attempt at a language version override
+ * comment. If this attempted language version override comment is not a
+ * valid language version override comment, it is reported.
+ *
+ * [1] https://github.com/dart-lang/language/blob/master/accepted/future-releases/language-versioning/feature-specification.md#individual-library-language-version-override
+ */
+ static const HintCode INVALID_LANGUAGE_VERSION_OVERRIDE_TWO_SLASHES =
+ HintCode(
+ 'INVALID_LANGUAGE_VERSION_OVERRIDE',
+ "The Dart language version override comment must be specified with exactly two slashes.",
+ correction:
+ "Specify a Dart language version override with a comment like '// @dart = 2.0'.",
+ uniqueName: 'INVALID_LANGUAGE_VERSION_OVERRIDE_TWO_SLASHES',
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the `@literal` annotation is
+ // applied to anything other than a const constructor.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because the constructor isn't
+ // a `const` constructor:
+ //
+ // ```dart
+ // import 'package:meta/meta.dart';
+ //
+ // class C {
+ // [!@literal!]
+ // C();
+ // }
+ // ```
+ //
+ // The following code produces this diagnostic because `x` isn't a
+ // constructor:
+ //
+ // ```dart
+ // import 'package:meta/meta.dart';
+ //
+ // [!@literal!]
+ // var x;
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the annotation is on a constructor and the constructor should always be
+ // invoked with `const`, when possible, then mark the constructor with the
+ // `const` keyword:
+ //
+ // ```dart
+ // import 'package:meta/meta.dart';
+ //
+ // class C {
+ // @literal
+ // const C();
+ // }
+ // ```
+ //
+ // If the constructor can't be marked as `const`, then remove the annotation.
+ //
+ // If the annotation is on anything other than a constructor, then remove the
+ // annotation:
+ //
+ // ```dart
+ // var x;
+ // ```
+ static const HintCode INVALID_LITERAL_ANNOTATION = HintCode(
+ 'INVALID_LITERAL_ANNOTATION',
+ "Only const constructors can have the `@literal` annotation.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * This hint is generated anywhere where `@nonVirtual` annotates something
+ * other than a non-abstract instance member in a class or mixin.
+ *
+ * Parameters:
+ * 0: the name of the member
+ */
+ static const HintCode INVALID_NON_VIRTUAL_ANNOTATION = HintCode(
+ 'INVALID_NON_VIRTUAL_ANNOTATION',
+ "The member '{0}' can't be '@nonVirtual' because it isn't a concrete instance member.",
+ correction: "Try removing @nonVirtual.",
+ );
+
+ /**
+ * This hint is generated anywhere where an instance member annotated with
+ * `@nonVirtual` is overridden in a subclass.
+ *
+ * Parameters:
+ * 0: the name of the member
+ * 1: the name of the defining class
+ */
+ static const HintCode INVALID_OVERRIDE_OF_NON_VIRTUAL_MEMBER = HintCode(
+ 'INVALID_OVERRIDE_OF_NON_VIRTUAL_MEMBER',
+ "The member '{0}' is declared non-virtual in '{1}' and can't be overridden in subclasses.",
+ );
+
+ /**
+ * This hint is generated anywhere where `@required` annotates a named
+ * parameter with a default value.
+ *
+ * Parameters:
+ * 0: the name of the member
+ */
+ static const HintCode INVALID_REQUIRED_NAMED_PARAM = HintCode(
+ 'INVALID_REQUIRED_NAMED_PARAM',
+ "The type parameter '{0}' is annotated with @required but only named parameters without a default value can be annotated with it.",
+ correction: "Remove @required.",
+ );
+
+ /**
+ * This hint is generated anywhere where `@required` annotates an optional
+ * positional parameter.
+ *
+ * Parameters:
+ * 0: the name of the member
+ */
+ static const HintCode INVALID_REQUIRED_OPTIONAL_POSITIONAL_PARAM = HintCode(
+ 'INVALID_REQUIRED_OPTIONAL_POSITIONAL_PARAM',
+ "Incorrect use of the annotation @required on the optional positional parameter '{0}'. Optional positional parameters cannot be required.",
+ correction: "Remove @required.",
+ );
+
+ /**
+ * This hint is generated anywhere where `@required` annotates a non optional
+ * positional parameter.
+ *
+ * Parameters:
+ * 0: the name of the member
+ */
+ static const HintCode INVALID_REQUIRED_POSITIONAL_PARAM = HintCode(
+ 'INVALID_REQUIRED_POSITIONAL_PARAM',
+ "Redundant use of the annotation @required on the required positional parameter '{0}'.",
+ correction: "Remove @required.",
+ );
+
+ /**
+ * This hint is generated anywhere where `@sealed` annotates something other
+ * than a class.
+ *
+ * Parameters:
+ * 0: the name of the member
+ */
+ static const HintCode INVALID_SEALED_ANNOTATION = HintCode(
+ 'INVALID_SEALED_ANNOTATION',
+ "The member '{0}' is annotated with '@sealed' but only classes can be annotated with it.",
+ correction: "Remove @sealed.",
+ );
+
+ /**
+ * This hint is generated anywhere where a member annotated with `@internal`
+ * is used outside of the package in which it is declared.
+ *
+ * Parameters:
+ * 0: the name of the member
+ */
+ static const HintCode INVALID_USE_OF_INTERNAL_MEMBER = HintCode(
+ 'INVALID_USE_OF_INTERNAL_MEMBER',
+ "The member '{0}' can only be used within its package.",
+ );
+
+ /**
+ * This hint is generated anywhere where a member annotated with `@protected`
+ * is used outside of an instance member of a subclass.
+ *
+ * Parameters:
+ * 0: the name of the member
+ * 1: the name of the defining class
+ */
+ static const HintCode INVALID_USE_OF_PROTECTED_MEMBER = HintCode(
+ 'INVALID_USE_OF_PROTECTED_MEMBER',
+ "The member '{0}' can only be used within instance members of subclasses of '{1}'.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the member
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an instance member that is
+ // annotated with `visibleForOverriding` is referenced outside the library in
+ // which it's declared for any reason other than to override it.
+ //
+ // #### Example
+ //
+ // Given a file named `a.dart` containing the following declaration:
+ //
+ // ```dart
+ // %uri="lib/a.dart"
+ // import 'package:meta/meta.dart';
+ //
+ // class A {
+ // @visibleForOverriding
+ // void a() {}
+ // }
+ // ```
+ //
+ // The following code produces this diagnostic because the method `m` is being
+ // invoked even though the only reason it's public is to allow it to be
+ // overridden:
+ //
+ // ```dart
+ // import 'a.dart';
+ //
+ // class B extends A {
+ // void b() {
+ // [!a!]();
+ // }
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Remove the invalid use of the member.
+ static const HintCode INVALID_USE_OF_VISIBLE_FOR_OVERRIDING_MEMBER = HintCode(
+ 'INVALID_USE_OF_VISIBLE_FOR_OVERRIDING_MEMBER',
+ "The member '{0}' can only be used for overriding.",
+ );
+
+ /**
+ * This hint is generated anywhere where a member annotated with
+ * `@visibleForTemplate` is used outside of a "template" Dart file.
+ *
+ * Parameters:
+ * 0: the name of the member
+ * 1: the name of the defining class
+ */
+ static const HintCode INVALID_USE_OF_VISIBLE_FOR_TEMPLATE_MEMBER = HintCode(
+ 'INVALID_USE_OF_VISIBLE_FOR_TEMPLATE_MEMBER',
+ "The member '{0}' can only be used within '{1}' or a template library.",
+ );
+
+ /**
+ * This hint is generated anywhere where a member annotated with
+ * `@visibleForTesting` is used outside the defining library, or a test.
+ *
+ * Parameters:
+ * 0: the name of the member
+ * 1: the name of the defining class
+ */
+ static const HintCode INVALID_USE_OF_VISIBLE_FOR_TESTING_MEMBER = HintCode(
+ 'INVALID_USE_OF_VISIBLE_FOR_TESTING_MEMBER',
+ "The member '{0}' can only be used within '{1}' or a test.",
+ );
+
+ /**
+ * This hint is generated anywhere where a private declaration is annotated
+ * with `@visibleForTemplate` or `@visibleForTesting`.
+ *
+ * Parameters:
+ * 0: the name of the member
+ * 1: the name of the annotation
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when either the `@visibleForTemplate`
+ // or `@visibleForTesting` annotation is applied to a non-public declaration.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic:
+ //
+ // ```dart
+ // import 'package:meta/meta.dart';
+ //
+ // [!@visibleForTesting!]
+ // void _someFunction() {}
+ //
+ // void f() => _someFunction();
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the declaration doesn't need to be used by test code, then remove the
+ // annotation:
+ //
+ // ```dart
+ // void _someFunction() {}
+ //
+ // void f() => _someFunction();
+ // ```
+ //
+ // If it does, then make it public:
+ //
+ // ```dart
+ // import 'package:meta/meta.dart';
+ //
+ // @visibleForTesting
+ // void someFunction() {}
+ //
+ // void f() => someFunction();
+ // ```
+ static const HintCode INVALID_VISIBILITY_ANNOTATION = HintCode(
+ 'INVALID_VISIBILITY_ANNOTATION',
+ "The member '{0}' is annotated with '{1}', but this annotation is only meaningful on declarations of public members.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when anything other than a public
+ // instance member of a class is annotated with `visibleForOverriding`.
+ // Because only public instance members can be overridden outside the defining
+ // library, there's no value to annotating any other declarations.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the annotation is on a
+ // class, and classes can't be overridden:
+ //
+ // ```dart
+ // import 'package:meta/meta.dart';
+ //
+ // [!@visibleForOverriding!]
+ // class C {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Remove the annotation:
+ //
+ // ```dart
+ // class C {}
+ // ```
+ static const HintCode INVALID_VISIBLE_FOR_OVERRIDING_ANNOTATION = HintCode(
+ 'INVALID_VISIBLE_FOR_OVERRIDING_ANNOTATION',
+ "The declaration '{0}' is annotated with 'visibleForOverriding'. Because '{0}' isn't an interface member that could be overridden, the annotation is meaningless.",
+ );
+
+ /**
+ * Generate a hint for an element that is annotated with `@JS(...)` whose
+ * library declaration is not similarly annotated.
+ */
+ static const HintCode MISSING_JS_LIB_ANNOTATION = HintCode(
+ 'MISSING_JS_LIB_ANNOTATION',
+ "The @JS() annotation can only be used if it is also declared on the library directive.",
+ correction: "Try adding the annotation to the library directive.",
+ );
+
+ /**
+ * Generate a hint for a constructor, function or method invocation where a
+ * required parameter is missing.
+ *
+ * Parameters:
+ * 0: the name of the parameter
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a method or function with a
+ // named parameter that is annotated as being required is invoked without
+ // providing a value for the parameter.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because the named parameter `x`
+ // is required:
+ //
+ // ```dart
+ // %language=2.9
+ // import 'package:meta/meta.dart';
+ //
+ // void f({@required int x}) {}
+ //
+ // void g() {
+ // [!f!]();
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Provide the required value:
+ //
+ // ```dart
+ // %language=2.9
+ // import 'package:meta/meta.dart';
+ //
+ // void f({@required int x}) {}
+ //
+ // void g() {
+ // f(x: 2);
+ // }
+ // ```
+ static const HintCode MISSING_REQUIRED_PARAM = HintCode(
+ 'MISSING_REQUIRED_PARAM',
+ "The parameter '{0}' is required.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Generate a hint for a constructor, function or method invocation where a
+ * required parameter is missing.
+ *
+ * Parameters:
+ * 0: the name of the parameter
+ * 1: message details
+ */
+ static const HintCode MISSING_REQUIRED_PARAM_WITH_DETAILS = HintCode(
+ 'MISSING_REQUIRED_PARAM',
+ "The parameter '{0}' is required. {1}.",
+ hasPublishedDocs: true,
+ uniqueName: 'MISSING_REQUIRED_PARAM_WITH_DETAILS',
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the declared return type
+ */
+ // #### Description
+ //
+ // Any function or method that doesn't end with either an explicit return or a
+ // throw implicitly returns `null`. This is rarely the desired behavior. The
+ // analyzer produces this diagnostic when it finds an implicit return.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `f` doesn't end with a
+ // return:
+ //
+ // ```dart
+ // %language=2.9
+ // int [!f!](int x) {
+ // if (x < 0) {
+ // return 0;
+ // }
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Add a `return` statement that makes the return value explicit, even if
+ // `null` is the appropriate value.
+ static const HintCode MISSING_RETURN = HintCode(
+ 'MISSING_RETURN',
+ "This function has a return type of '{0}', but doesn't end with a return statement.",
+ correction:
+ "Try adding a return statement, or changing the return type to 'void'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * This hint is generated anywhere where a `@sealed` class is used as a
+ * a superclass constraint of a mixin.
+ *
+ * Parameters:
+ * 0: the name of the sealed class
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the superclass constraint of a
+ // mixin is a class from a different package that was marked as `@sealed`.
+ // Classes that are sealed can't be extended, implemented, mixed in, or used
+ // as a superclass constraint.
+ //
+ // #### Examples
+ //
+ // If the package `p` defines a sealed class:
+ //
+ // ```dart
+ // %uri="package:p/p.dart"
+ // import 'package:meta/meta.dart';
+ //
+ // @sealed
+ // class C {}
+ // ```
+ //
+ // Then, the following code, when in a package other than `p`, produces this
+ // diagnostic:
+ //
+ // ```dart
+ // import 'package:p/p.dart';
+ //
+ // [!mixin M on C {}!]
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the classes that use the mixin don't need to be subclasses of the sealed
+ // class, then consider adding a field and delegating to the wrapped instance
+ // of the sealed class.
+ static const HintCode MIXIN_ON_SEALED_CLASS = HintCode(
+ 'MIXIN_ON_SEALED_CLASS',
+ "The class '{0}' shouldn't be used as a mixin constraint because it is sealed, and any class mixing in this mixin must have '{0}' as a superclass.",
+ correction:
+ "Try composing with this class, or refer to its documentation for more information.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Generate a hint for classes that inherit from classes annotated with
+ * `@immutable` but that are not immutable.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an immutable class defines one
+ // or more instance fields that aren't final. A class is immutable if it's
+ // marked as being immutable using the annotation `@immutable` or if it's a
+ // subclass of an immutable class.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because the field `x` isn't
+ // final:
+ //
+ // ```dart
+ // import 'package:meta/meta.dart';
+ //
+ // @immutable
+ // class [!C!] {
+ // int x;
+ //
+ // C(this.x);
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If instances of the class should be immutable, then add the keyword `final`
+ // to all non-final field declarations:
+ //
+ // ```dart
+ // import 'package:meta/meta.dart';
+ //
+ // @immutable
+ // class C {
+ // final int x;
+ //
+ // C(this.x);
+ // }
+ // ```
+ //
+ // If the instances of the class should be mutable, then remove the
+ // annotation, or choose a different superclass if the annotation is
+ // inherited:
+ //
+ // ```dart
+ // class C {
+ // int x;
+ //
+ // C(this.x);
+ // }
+ // ```
+ static const HintCode MUST_BE_IMMUTABLE = HintCode(
+ 'MUST_BE_IMMUTABLE',
+ "This class (or a class that this class inherits from) is marked as '@immutable', but one or more of its instance fields aren't final: {0}",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the class declaring the overridden method
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a method that overrides a method
+ // that is annotated as `@mustCallSuper` doesn't invoke the overridden method
+ // as required.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because the method `m` in `B`
+ // doesn't invoke the overridden method `m` in `A`:
+ //
+ // ```dart
+ // import 'package:meta/meta.dart';
+ //
+ // class A {
+ // @mustCallSuper
+ // m() {}
+ // }
+ //
+ // class B extends A {
+ // @override
+ // [!m!]() {}
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Add an invocation of the overridden method in the overriding method:
+ //
+ // ```dart
+ // import 'package:meta/meta.dart';
+ //
+ // class A {
+ // @mustCallSuper
+ // m() {}
+ // }
+ //
+ // class B extends A {
+ // @override
+ // m() {
+ // super.m();
+ // }
+ // }
+ // ```
+ static const HintCode MUST_CALL_SUPER = HintCode(
+ 'MUST_CALL_SUPER',
+ "This method overrides a method annotated as '@mustCallSuper' in '{0}', but doesn't invoke the overridden method.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Generate a hint for non-const instance creation using a constructor
+ * annotated with `@literal`.
+ *
+ * Parameters:
+ * 0: the name of the class defining the annotated constructor
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a constructor that has the
+ // `@literal` annotation is invoked without using the `const` keyword, but all
+ // of the arguments to the constructor are constants. The annotation indicates
+ // that the constructor should be used to create a constant value whenever
+ // possible.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic:
+ //
+ // ```dart
+ // import 'package:meta/meta.dart';
+ //
+ // class C {
+ // @literal
+ // const C();
+ // }
+ //
+ // C f() => [!C()!];
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Add the keyword `const` before the constructor invocation:
+ //
+ // ```dart
+ // import 'package:meta/meta.dart';
+ //
+ // class C {
+ // @literal
+ // const C();
+ // }
+ //
+ // void f() => const C();
+ // ```
+ static const HintCode NON_CONST_CALL_TO_LITERAL_CONSTRUCTOR = HintCode(
+ 'NON_CONST_CALL_TO_LITERAL_CONSTRUCTOR',
+ "This instance creation must be 'const', because the {0} constructor is marked as '@literal'.",
+ correction: "Try adding a 'const' keyword.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Generate a hint for non-const instance creation (with the `new` keyword)
+ * using a constructor annotated with `@literal`.
+ *
+ * Parameters:
+ * 0: the name of the class defining the annotated constructor
+ */
+ static const HintCode NON_CONST_CALL_TO_LITERAL_CONSTRUCTOR_USING_NEW =
+ HintCode(
+ 'NON_CONST_CALL_TO_LITERAL_CONSTRUCTOR',
+ "This instance creation must be 'const', because the {0} constructor is marked as '@literal'.",
+ correction: "Try replacing the 'new' keyword with 'const'.",
+ hasPublishedDocs: true,
+ uniqueName: 'NON_CONST_CALL_TO_LITERAL_CONSTRUCTOR_USING_NEW',
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the type following `on` in a
+ // `catch` clause is a nullable type. It isn't valid to specify a nullable
+ // type because it isn't possible to catch `null` (because it's a runtime
+ // error to throw `null`).
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the exception type is
+ // specified to allow `null` when `null` can't be thrown:
+ //
+ // ```dart
+ // void f() {
+ // try {
+ // // ...
+ // } on [!FormatException?!] {
+ // }
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Remove the question mark from the type:
+ //
+ // ```dart
+ // void f() {
+ // try {
+ // // ...
+ // } on FormatException {
+ // }
+ // }
+ // ```
+ static const HintCode NULLABLE_TYPE_IN_CATCH_CLAUSE = HintCode(
+ 'NULLABLE_TYPE_IN_CATCH_CLAUSE',
+ "A potentially nullable type can't be used in an 'on' clause because it isn't valid to throw a nullable expression.",
+ correction: "Try using a non-nullable type.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the method being invoked
+ * 1: the type argument associated with the method
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when `null` is passed to either the
+ // constructor `Future.value` or the method `Completer.complete` when the type
+ // argument used to create the instance was non-nullable. Even though the type
+ // system can't express this restriction, passing in a `null` results in a
+ // runtime exception.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because `null` is being passed
+ // to the constructor `Future.value` even though the type argument is the
+ // non-nullable type `String`:
+ //
+ // ```dart
+ // Future<String> f() {
+ // return Future.value([!null!]);
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Pass in a non-null value:
+ //
+ // ```dart
+ // Future<String> f() {
+ // return Future.value('');
+ // }
+ // ```
+ static const HintCode NULL_ARGUMENT_TO_NON_NULL_TYPE = HintCode(
+ 'NULL_ARGUMENT_TO_NON_NULL_TYPE',
+ "'{0}' shouldn't be called with a null argument for the non-nullable type argument '{1}'.",
+ correction: "Try adding a non-null argument.",
+ );
+
+ /**
+ * When the left operand of a binary expression uses '?.' operator, it can be
+ * `null`.
+ */
+ static const HintCode NULL_AWARE_BEFORE_OPERATOR = HintCode(
+ 'NULL_AWARE_BEFORE_OPERATOR',
+ "The left operand uses '?.', so its value can be null.",
+ );
+
+ /**
+ * A condition in a control flow statement could evaluate to `null` because it
+ * uses the null-aware '?.' operator.
+ */
+ static const HintCode NULL_AWARE_IN_CONDITION = HintCode(
+ 'NULL_AWARE_IN_CONDITION',
+ "The value of the '?.' operator can be 'null', which isn't appropriate in a condition.",
+ correction:
+ "Try replacing the '?.' with a '.', testing the left-hand side for null if necessary.",
+ );
+
+ /**
+ * A condition in operands of a logical operator could evaluate to `null`
+ * because it uses the null-aware '?.' operator.
+ */
+ static const HintCode NULL_AWARE_IN_LOGICAL_OPERATOR = HintCode(
+ 'NULL_AWARE_IN_LOGICAL_OPERATOR',
+ "The value of the '?.' operator can be 'null', which isn't appropriate as an operand of a logical operator.",
+ );
+
+ /**
+ * This hint indicates that a null literal is null-checked with `!`, but null
+ * is never not null.
+ */
+ static const HintCode NULL_CHECK_ALWAYS_FAILS = HintCode(
+ 'NULL_CHECK_ALWAYS_FAILS',
+ "This null-check will always throw an exception because the expression will always evaluate to 'null'.",
+ );
+
+ /**
+ * A field with the override annotation does not override a getter or setter.
+ *
+ * No parameters.
+ */
+ static const HintCode OVERRIDE_ON_NON_OVERRIDING_FIELD = HintCode(
+ 'OVERRIDE_ON_NON_OVERRIDING_MEMBER',
+ "The field doesn't override an inherited getter or setter.",
+ correction:
+ "Try updating this class to match the superclass, or removing the override annotation.",
+ hasPublishedDocs: true,
+ uniqueName: 'OVERRIDE_ON_NON_OVERRIDING_FIELD',
+ );
+
+ /**
+ * A getter with the override annotation does not override an existing getter.
+ *
+ * No parameters.
+ */
+ static const HintCode OVERRIDE_ON_NON_OVERRIDING_GETTER = HintCode(
+ 'OVERRIDE_ON_NON_OVERRIDING_MEMBER',
+ "The getter doesn't override an inherited getter.",
+ correction:
+ "Try updating this class to match the superclass, or removing the override annotation.",
+ hasPublishedDocs: true,
+ uniqueName: 'OVERRIDE_ON_NON_OVERRIDING_GETTER',
+ );
+
+ /**
+ * A method with the override annotation does not override an existing method.
+ *
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a class member is annotated with
+ // the `@override` annotation, but the member isn’t declared in any of the
+ // supertypes of the class.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `m` isn't declared in
+ // any of the supertypes of `C`:
+ //
+ // ```dart
+ // class C {
+ // @override
+ // String [!m!]() => '';
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the member is intended to override a member with a different name, then
+ // update the member to have the same name:
+ //
+ // ```dart
+ // class C {
+ // @override
+ // String toString() => '';
+ // }
+ // ```
+ //
+ // If the member is intended to override a member that was removed from the
+ // superclass, then consider removing the member from the subclass.
+ //
+ // If the member can't be removed, then remove the annotation.
+ static const HintCode OVERRIDE_ON_NON_OVERRIDING_METHOD = HintCode(
+ 'OVERRIDE_ON_NON_OVERRIDING_MEMBER',
+ "The method doesn't override an inherited method.",
+ correction:
+ "Try updating this class to match the superclass, or removing the override annotation.",
+ hasPublishedDocs: true,
+ uniqueName: 'OVERRIDE_ON_NON_OVERRIDING_METHOD',
+ );
+
+ /**
+ * A setter with the override annotation does not override an existing setter.
+ *
+ * No parameters.
+ */
+ static const HintCode OVERRIDE_ON_NON_OVERRIDING_SETTER = HintCode(
+ 'OVERRIDE_ON_NON_OVERRIDING_MEMBER',
+ "The setter doesn't override an inherited setter.",
+ correction:
+ "Try updating this class to match the superclass, or removing the override annotation.",
+ hasPublishedDocs: true,
+ uniqueName: 'OVERRIDE_ON_NON_OVERRIDING_SETTER',
+ );
+
+ /**
+ * It is a bad practice for a package import to reference anything outside the
+ * given package, or more generally, it is bad practice for a package import
+ * to contain a "..". For example, a source file should not contain a
+ * directive such as `import 'package:foo/../some.dart'`.
+ */
+ static const HintCode PACKAGE_IMPORT_CONTAINS_DOT_DOT = HintCode(
+ 'PACKAGE_IMPORT_CONTAINS_DOT_DOT',
+ "A package import shouldn't contain '..'.",
+ );
+
+ /**
+ * It is not an error to call or tear-off a method, setter, or getter, or to
+ * read or write a field, on a receiver of static type `Never`.
+ * Implementations that provide feedback about dead or unreachable code are
+ * encouraged to indicate that any arguments to the invocation are
+ * unreachable.
+ *
+ * It is not an error to apply an expression of type `Never` in the function
+ * position of a function call. Implementations that provide feedback about
+ * dead or unreachable code are encouraged to indicate that any arguments to
+ * the call are unreachable.
+ *
+ * Parameters: none
+ */
+ static const HintCode RECEIVER_OF_TYPE_NEVER = HintCode(
+ 'RECEIVER_OF_TYPE_NEVER',
+ "The receiver is of type 'Never', and will never complete with a value.",
+ correction:
+ "Try checking for throw expressions or type errors in the receiver",
+ );
+
+ /**
+ * Users should not return values marked `@doNotStore` from functions,
+ * methods or getters not marked `@doNotStore`.
+ */
+ static const HintCode RETURN_OF_DO_NOT_STORE = HintCode(
+ 'RETURN_OF_DO_NOT_STORE',
+ "'{0}' is annotated with 'doNotStore' and shouldn't be returned unless '{1}' is also annotated.",
+ correction: "Annotate '{1}' with 'doNotStore'.",
+ );
+
+ /**
+ * Parameters:
+ * 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 because it must be assignable to '{1}'.",
+ hasPublishedDocs: true,
+ uniqueName: 'RETURN_OF_INVALID_TYPE_FROM_CATCH_ERROR',
+ );
+
+ /**
+ * Parameters:
+ * 0: the return type of the function
+ * 1: the expected return type as defined by the type of the Future
+ */
+ static const HintCode RETURN_TYPE_INVALID_FOR_CATCH_ERROR = HintCode(
+ 'INVALID_RETURN_TYPE_FOR_CATCH_ERROR',
+ "The return type '{0}' isn't assignable to '{1}', as required by 'Future.catchError'.",
+ hasPublishedDocs: true,
+ uniqueName: 'RETURN_TYPE_INVALID_FOR_CATCH_ERROR',
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when either the class `Future` or
+ // `Stream` is referenced in a library that doesn't import `dart:async` in
+ // code that has an SDK constraint whose lower bound is less than 2.1.0. In
+ // earlier versions, these classes weren't defined in `dart:core`, so the
+ // import was necessary.
+ //
+ // #### Examples
+ //
+ // Here's an example of a pubspec that defines an SDK constraint with a lower
+ // bound of less than 2.1.0:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // environment:
+ // sdk: '>=2.0.0 <2.4.0'
+ // ```
+ //
+ // In the package that has that pubspec, code like the following produces this
+ // diagnostic:
+ //
+ // ```dart
+ // void f([!Future!] f) {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you don't need to support older versions of the SDK, then you can
+ // increase the SDK constraint to allow the classes to be referenced:
+ //
+ // ```yaml
+ // environment:
+ // sdk: '>=2.1.0 <2.4.0'
+ // ```
+ //
+ // If you need to support older versions of the SDK, then import the
+ // `dart:async` library.
+ //
+ // ```dart
+ // import 'dart:async';
+ //
+ // void f(Future f) {}
+ // ```
+ static const HintCode SDK_VERSION_ASYNC_EXPORTED_FROM_CORE = HintCode(
+ 'SDK_VERSION_ASYNC_EXPORTED_FROM_CORE',
+ "The class '{0}' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.",
+ correction:
+ "Try either importing 'dart:async' or updating the SDK constraints.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an `as` expression inside a
+ // [constant context][] is found in code that has an SDK constraint whose
+ // lower bound is less than 2.3.2. Using an `as` expression in a
+ // [constant context][] wasn't supported in earlier versions, so this code
+ // won't be able to run against earlier versions of the SDK.
+ //
+ // #### Examples
+ //
+ // Here's an example of a pubspec that defines an SDK constraint with a lower
+ // bound of less than 2.3.2:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // environment:
+ // sdk: '>=2.1.0 <2.4.0'
+ // ```
+ //
+ // In the package that has that pubspec, code like the following produces
+ // this diagnostic:
+ //
+ // ```dart
+ // const num n = 3;
+ // const int i = [!n as int!];
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you don't need to support older versions of the SDK, then you can
+ // increase the SDK constraint to allow the expression to be used:
+ //
+ // ```yaml
+ // environment:
+ // sdk: '>=2.3.2 <2.4.0'
+ // ```
+ //
+ // If you need to support older versions of the SDK, then either rewrite the
+ // code to not use an `as` expression, or change the code so that the `as`
+ // expression isn't in a [constant context][]:
+ //
+ // ```dart
+ // num x = 3;
+ // int y = x as int;
+ // ```
+ static const HintCode SDK_VERSION_AS_EXPRESSION_IN_CONST_CONTEXT = HintCode(
+ 'SDK_VERSION_AS_EXPRESSION_IN_CONST_CONTEXT',
+ "The use of an as expression in a constant expression wasn't supported until version 2.3.2, but this code is required to be able to run on earlier versions.",
+ correction: "Try updating the SDK constraints.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when any use of the `&`, `|`, or `^`
+ // operators on the class `bool` inside a [constant context][] is found in
+ // code that has an SDK constraint whose lower bound is less than 2.3.2. Using
+ // these operators in a [constant context][] wasn't supported in earlier
+ // versions, so this code won't be able to run against earlier versions of the
+ // SDK.
+ //
+ // #### Examples
+ //
+ // Here's an example of a pubspec that defines an SDK constraint with a lower
+ // bound of less than 2.3.2:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // environment:
+ // sdk: '>=2.1.0 <2.4.0'
+ // ```
+ //
+ // In the package that has that pubspec, code like the following produces this
+ // diagnostic:
+ //
+ // ```dart
+ // const bool a = true;
+ // const bool b = false;
+ // const bool c = a [!&!] b;
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you don't need to support older versions of the SDK, then you can
+ // increase the SDK constraint to allow the operators to be used:
+ //
+ // ```yaml
+ // environment:
+ // sdk: '>=2.3.2 <2.4.0'
+ // ```
+ //
+ // If you need to support older versions of the SDK, then either rewrite the
+ // code to not use these operators, or change the code so that the expression
+ // isn't in a [constant context][]:
+ //
+ // ```dart
+ // const bool a = true;
+ // const bool b = false;
+ // bool c = a & b;
+ // ```
+ static const HintCode SDK_VERSION_BOOL_OPERATOR_IN_CONST_CONTEXT = HintCode(
+ 'SDK_VERSION_BOOL_OPERATOR_IN_CONST_CONTEXT',
+ "The use of the operator '{0}' for 'bool' operands in a constant context wasn't supported until version 2.3.2, but this code is required to be able to run on earlier versions.",
+ correction: "Try updating the SDK constraints.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ *
+ * There is also a [ParserError.EXPERIMENT_NOT_ENABLED] code which catches
+ * some cases of constructor tearoff features (like `List<int>.filled;`).
+ * Other constructor tearoff cases are not realized until resolution
+ * (like `List.filled;`).
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a constructor tear-off is found
+ // in code that has an SDK constraint whose lower bound is less than 2.15.
+ // Constructor tear-offs weren't supported in earlier versions, so this code
+ // won't be able to run against earlier versions of the SDK.
+ //
+ // #### Example
+ //
+ // Here's an example of a pubspec that defines an SDK constraint with a lower
+ // bound of less than 2.15:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // environment:
+ // sdk: '>=2.9.0 <2.15.0'
+ // ```
+ //
+ // In the package that has that pubspec, code like the following produces this
+ // diagnostic:
+ //
+ // ```dart
+ // %language=2.14
+ // var setConstructor = [!Set.identity!];
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you don't need to support older versions of the SDK, then you can
+ // increase the SDK constraint to allow the operator to be used:
+ //
+ // ```yaml
+ // environment:
+ // sdk: '>=2.15.0 <2.16.0'
+ // ```
+ //
+ // If you need to support older versions of the SDK, then rewrite the code to
+ // not use constructor tear-offs:
+ //
+ // ```dart
+ // %language=2.14
+ // var setConstructor = () => Set.identity();
+ // ```
+ static const HintCode SDK_VERSION_CONSTRUCTOR_TEAROFFS = HintCode(
+ 'SDK_VERSION_CONSTRUCTOR_TEAROFFS',
+ "Tearing off a constructor requires the 'constructor-tearoffs' language feature.",
+ correction:
+ "Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.",
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the operator `==` is used on a
+ // non-primitive type inside a [constant context][] is found in code that has
+ // an SDK constraint whose lower bound is less than 2.3.2. Using this operator
+ // in a [constant context][] wasn't supported in earlier versions, so this
+ // code won't be able to run against earlier versions of the SDK.
+ //
+ // #### Examples
+ //
+ // Here's an example of a pubspec that defines an SDK constraint with a lower
+ // bound of less than 2.3.2:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // environment:
+ // sdk: '>=2.1.0 <2.4.0'
+ // ```
+ //
+ // In the package that has that pubspec, code like the following produces this
+ // diagnostic:
+ //
+ // ```dart
+ // %language=2.9
+ // class C {}
+ // const C a = null;
+ // const C b = null;
+ // const bool same = a [!==!] b;
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you don't need to support older versions of the SDK, then you can
+ // increase the SDK constraint to allow the operator to be used:
+ //
+ // ```yaml
+ // environment:
+ // sdk: '>=2.3.2 <2.4.0'
+ // ```
+ //
+ // If you need to support older versions of the SDK, then either rewrite the
+ // code to not use the `==` operator, or change the code so that the
+ // expression isn't in a [constant context][]:
+ //
+ // ```dart
+ // %language=2.9
+ // class C {}
+ // const C a = null;
+ // const C b = null;
+ // bool same = a == b;
+ // ```
+ static const HintCode SDK_VERSION_EQ_EQ_OPERATOR_IN_CONST_CONTEXT = HintCode(
+ 'SDK_VERSION_EQ_EQ_OPERATOR_IN_CONST_CONTEXT',
+ "Using the operator '==' for non-primitive types wasn't supported until version 2.3.2, but this code is required to be able to run on earlier versions.",
+ correction: "Try updating the SDK constraints.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an extension declaration or an
+ // extension override is found in code that has an SDK constraint whose lower
+ // bound is less than 2.6.0. Using extensions wasn't supported in earlier
+ // versions, so this code won't be able to run against earlier versions of the
+ // SDK.
+ //
+ // #### Examples
+ //
+ // Here's an example of a pubspec that defines an SDK constraint with a lower
+ // bound of less than 2.6.0:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // environment:
+ // sdk: '>=2.4.0 <2.7.0'
+ // ```
+ //
+ // In the package that has that pubspec, code like the following produces
+ // this diagnostic:
+ //
+ // ```dart
+ // [!extension!] E on String {
+ // void sayHello() {
+ // print('Hello $this');
+ // }
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you don't need to support older versions of the SDK, then you can
+ // increase the SDK constraint to allow the syntax to be used:
+ //
+ // ```yaml
+ // environment:
+ // sdk: '>=2.6.0 <2.7.0'
+ // ```
+ //
+ // If you need to support older versions of the SDK, then rewrite the code to
+ // not make use of extensions. The most common way to do this is to rewrite
+ // the members of the extension as top-level functions (or methods) that take
+ // the value that would have been bound to `this` as a parameter:
+ //
+ // ```dart
+ // void sayHello(String s) {
+ // print('Hello $s');
+ // }
+ // ```
+ static const HintCode SDK_VERSION_EXTENSION_METHODS = HintCode(
+ 'SDK_VERSION_EXTENSION_METHODS',
+ "Extension methods weren't supported until version 2.6.0, but this code is required to be able to run on earlier versions.",
+ correction: "Try updating the SDK constraints.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the operator `>>>` is used in
+ // code that has an SDK constraint whose lower bound is less than 2.14.0. This
+ // operator wasn't supported in earlier versions, so this code won't be able
+ // to run against earlier versions of the SDK.
+ //
+ // #### Examples
+ //
+ // Here's an example of a pubspec that defines an SDK constraint with a lower
+ // bound of less than 2.14.0:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // environment:
+ // sdk: '>=2.0.0 <2.15.0'
+ // ```
+ //
+ // In the package that has that pubspec, code like the following produces this
+ // diagnostic:
+ //
+ // ```dart
+ // int x = 3 [!>>>!] 4;
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you don't need to support older versions of the SDK, then you can
+ // increase the SDK constraint to allow the operator to be used:
+ //
+ // ```yaml
+ // environment:
+ // sdk: '>=2.14.0 <2.15.0'
+ // ```
+ //
+ // If you need to support older versions of the SDK, then rewrite the code to
+ // not use the `>>>` operator:
+ //
+ // ```dart
+ // int x = logicalShiftRight(3, 4);
+ //
+ // int logicalShiftRight(int leftOperand, int rightOperand) {
+ // int divisor = 1 << rightOperand;
+ // if (divisor == 0) {
+ // return 0;
+ // }
+ // return leftOperand ~/ divisor;
+ // }
+ // ```
+ static const HintCode SDK_VERSION_GT_GT_GT_OPERATOR = HintCode(
+ 'SDK_VERSION_GT_GT_GT_OPERATOR',
+ "The operator '>>>' wasn't supported until version 2.14.0, but this code is required to be able to run on earlier versions.",
+ correction: "Try updating the SDK constraints.",
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an `is` expression inside a
+ // [constant context][] is found in code that has an SDK constraint whose
+ // lower bound is less than 2.3.2. Using an `is` expression in a
+ // [constant context][] wasn't supported in earlier versions, so this code
+ // won't be able to run against earlier versions of the SDK.
+ //
+ // #### Examples
+ //
+ // Here's an example of a pubspec that defines an SDK constraint with a lower
+ // bound of less than 2.3.2:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // environment:
+ // sdk: '>=2.1.0 <2.4.0'
+ // ```
+ //
+ // In the package that has that pubspec, code like the following produces
+ // this diagnostic:
+ //
+ // ```dart
+ // const Object x = 4;
+ // const y = [!x is int!] ? 0 : 1;
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you don't need to support older versions of the SDK, then you can
+ // increase the SDK constraint to allow the expression to be used:
+ //
+ // ```yaml
+ // environment:
+ // sdk: '>=2.3.2 <2.4.0'
+ // ```
+ //
+ // If you need to support older versions of the SDK, then either rewrite the
+ // code to not use the `is` operator, or, if that isn't possible, change the
+ // code so that the `is` expression isn't in a
+ // [constant context][]:
+ //
+ // ```dart
+ // const Object x = 4;
+ // var y = x is int ? 0 : 1;
+ // ```
+ static const HintCode SDK_VERSION_IS_EXPRESSION_IN_CONST_CONTEXT = HintCode(
+ 'SDK_VERSION_IS_EXPRESSION_IN_CONST_CONTEXT',
+ "The use of an is expression in a constant context wasn't supported until version 2.3.2, but this code is required to be able to run on earlier versions.",
+ correction: "Try updating the SDK constraints.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a reference to the class `Never`
+ // is found in code that has an SDK constraint whose lower bound is less than
+ // 2.12.0. This class wasn't defined in earlier versions, so this code won't
+ // be able to run against earlier versions of the SDK.
+ //
+ // #### Examples
+ //
+ // Here's an example of a pubspec that defines an SDK constraint with a lower
+ // bound of less than 2.12.0:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // environment:
+ // sdk: '>=2.5.0 <2.6.0'
+ // ```
+ //
+ // In the package that has that pubspec, code like the following produces this
+ // diagnostic:
+ //
+ // ```dart
+ // %language=2.9
+ // [!Never!] n;
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you don't need to support older versions of the SDK, then you can
+ // increase the SDK constraint to allow the type to be used:
+ //
+ // ```yaml
+ // environment:
+ // sdk: '>=2.12.0 <2.13.0'
+ // ```
+ //
+ // If you need to support older versions of the SDK, then rewrite the code to
+ // not reference this class:
+ //
+ // ```dart
+ // dynamic x;
+ // ```
+ static const HintCode SDK_VERSION_NEVER = HintCode(
+ 'SDK_VERSION_NEVER',
+ "The type 'Never' wasn't supported until version 2.12.0, but this code is required to be able to run on earlier versions.",
+ correction: "Try updating the SDK constraints.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a set literal is found in code
+ // that has an SDK constraint whose lower bound is less than 2.2.0. Set
+ // literals weren't supported in earlier versions, so this code won't be able
+ // to run against earlier versions of the SDK.
+ //
+ // #### Examples
+ //
+ // Here's an example of a pubspec that defines an SDK constraint with a lower
+ // bound of less than 2.2.0:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // environment:
+ // sdk: '>=2.1.0 <2.4.0'
+ // ```
+ //
+ // In the package that has that pubspec, code like the following produces this
+ // diagnostic:
+ //
+ // ```dart
+ // var s = [!<int>{}!];
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you don't need to support older versions of the SDK, then you can
+ // increase the SDK constraint to allow the syntax to be used:
+ //
+ // ```yaml
+ // environment:
+ // sdk: '>=2.2.0 <2.4.0'
+ // ```
+ //
+ // If you do need to support older versions of the SDK, then replace the set
+ // literal with code that creates the set without the use of a literal:
+ //
+ // ```dart
+ // var s = new Set<int>();
+ // ```
+ static const HintCode SDK_VERSION_SET_LITERAL = HintCode(
+ 'SDK_VERSION_SET_LITERAL',
+ "Set literals weren't supported until version 2.2, but this code is required to be able to run on earlier versions.",
+ correction: "Try updating the SDK constraints.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a for, if, or spread element is
+ // found in code that has an SDK constraint whose lower bound is less than
+ // 2.3.0. Using a for, if, or spread element wasn't supported in earlier
+ // versions, so this code won't be able to run against earlier versions of the
+ // SDK.
+ //
+ // #### Examples
+ //
+ // Here's an example of a pubspec that defines an SDK constraint with a lower
+ // bound of less than 2.3.0:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // environment:
+ // sdk: '>=2.2.0 <2.4.0'
+ // ```
+ //
+ // In the package that has that pubspec, code like the following produces
+ // this diagnostic:
+ //
+ // ```dart
+ // var digits = [[!for (int i = 0; i < 10; i++) i!]];
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you don't need to support older versions of the SDK, then you can
+ // increase the SDK constraint to allow the syntax to be used:
+ //
+ // ```yaml
+ // environment:
+ // sdk: '>=2.3.0 <2.4.0'
+ // ```
+ //
+ // If you need to support older versions of the SDK, then rewrite the code to
+ // not make use of those elements:
+ //
+ // ```dart
+ // var digits = _initializeDigits();
+ //
+ // List<int> _initializeDigits() {
+ // var digits = <int>[];
+ // for (int i = 0; i < 10; i++) {
+ // digits.add(i);
+ // }
+ // return digits;
+ // }
+ // ```
+ static const HintCode SDK_VERSION_UI_AS_CODE = HintCode(
+ 'SDK_VERSION_UI_AS_CODE',
+ "The for, if, and spread elements weren't supported until version 2.3.0, but this code is required to be able to run on earlier versions.",
+ correction: "Try updating the SDK constraints.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an if or spread element inside
+ // a [constant context][] is found in code that has an SDK constraint whose
+ // lower bound is less than 2.5.0. Using an if or spread element inside a
+ // [constant context][] wasn't supported in earlier versions, so this code
+ // won't be able to run against earlier versions of the SDK.
+ //
+ // #### Examples
+ //
+ // Here's an example of a pubspec that defines an SDK constraint with a lower
+ // bound of less than 2.5.0:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // environment:
+ // sdk: '>=2.4.0 <2.6.0'
+ // ```
+ //
+ // In the package that has that pubspec, code like the following produces
+ // this diagnostic:
+ //
+ // ```dart
+ // const a = [1, 2];
+ // const b = [[!...a!]];
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you don't need to support older versions of the SDK, then you can
+ // increase the SDK constraint to allow the syntax to be used:
+ //
+ // ```yaml
+ // environment:
+ // sdk: '>=2.5.0 <2.6.0'
+ // ```
+ //
+ // If you need to support older versions of the SDK, then rewrite the code to
+ // not make use of those elements:
+ //
+ // ```dart
+ // const a = [1, 2];
+ // const b = [1, 2];
+ // ```
+ //
+ // If that isn't possible, change the code so that the element isn't in a
+ // [constant context][]:
+ //
+ // ```dart
+ // const a = [1, 2];
+ // var b = [...a];
+ // ```
+ static const HintCode SDK_VERSION_UI_AS_CODE_IN_CONST_CONTEXT = HintCode(
+ 'SDK_VERSION_UI_AS_CODE_IN_CONST_CONTEXT',
+ "The if and spread elements weren't supported in constant expressions until version 2.5.0, but this code is required to be able to run on earlier versions.",
+ correction: "Try updating the SDK constraints.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * When "strict-raw-types" is enabled, "raw types" must have type arguments.
+ *
+ * A "raw type" is a type name that does not use inference to fill in missing
+ * type arguments; instead, each type argument is instantiated to its bound.
+ */
+ static const HintCode STRICT_RAW_TYPE = HintCode(
+ 'STRICT_RAW_TYPE',
+ "The generic type '{0}' should have explicit type arguments but doesn't.",
+ correction: "Use explicit type arguments for '{0}'.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the sealed class
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a sealed class (one that either
+ // has the `@sealed` annotation or inherits or mixes in a sealed class) is
+ // referenced in either the `extends`, `implements`, or `with` clause of a
+ // class or mixin declaration if the declaration isn't in the same package as
+ // the sealed class.
+ //
+ // #### Example
+ //
+ // Given a library in a package other than the package being analyzed that
+ // contains the following:
+ //
+ // ```dart
+ // %uri="package:a/a.dart"
+ // import 'package:meta/meta.dart';
+ //
+ // class A {}
+ //
+ // @sealed
+ // class B {}
+ // ```
+ //
+ // The following code produces this diagnostic because `C`, which isn't in the
+ // same package as `B`, is extending the sealed class `B`:
+ //
+ // ```dart
+ // import 'package:a/a.dart';
+ //
+ // [!class C extends B {}!]
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the class doesn't need to be a subtype of the sealed class, then change
+ // the declaration so that it isn't:
+ //
+ // ```dart
+ // import 'package:a/a.dart';
+ //
+ // class B extends A {}
+ // ```
+ //
+ // If the class needs to be a subtype of the sealed class, then either change
+ // the sealed class so that it's no longer sealed or move the subclass into
+ // the same package as the sealed class.
+ static const HintCode SUBTYPE_OF_SEALED_CLASS = HintCode(
+ 'SUBTYPE_OF_SEALED_CLASS',
+ "The class '{0}' shouldn't be extended, mixed in, or implemented because it's sealed.",
+ correction:
+ "Try composing instead of inheriting, or refer to the documentation of '{0}' for more information.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when there's a type check (using the
+ // `as` operator) where the type is `Null`. There's only one value whose type
+ // is `Null`, so the code is both more readable and more performant when it
+ // tests for `null` explicitly.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the code is testing to
+ // see whether the value of `s` is `null` by using a type check:
+ //
+ // ```dart
+ // void f(String? s) {
+ // if ([!s is Null!]) {
+ // return;
+ // }
+ // print(s);
+ // }
+ // ```
+ //
+ // The following code produces this diagnostic because the code is testing to
+ // see whether the value of `s` is something other than `null` by using a type
+ // check:
+ //
+ // ```dart
+ // void f(String? s) {
+ // if ([!s is! Null!]) {
+ // print(s);
+ // }
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Replace the type check with the equivalent comparison with `null`:
+ //
+ // ```dart
+ // void f(String? s) {
+ // if (s == null) {
+ // return;
+ // }
+ // print(s);
+ // }
+ // ```
+ static const HintCode TYPE_CHECK_IS_NOT_NULL = HintCode(
+ 'TYPE_CHECK_WITH_NULL',
+ "Tests for non-null should be done with '!= null'.",
+ correction: "Try replacing the 'is! Null' check with '!= null'.",
+ hasPublishedDocs: true,
+ uniqueName: 'TYPE_CHECK_IS_NOT_NULL',
+ );
+
+ /**
+ * No parameters.
+ */
+ static const HintCode TYPE_CHECK_IS_NULL = HintCode(
+ 'TYPE_CHECK_WITH_NULL',
+ "Tests for null should be done with '== null'.",
+ correction: "Try replacing the 'is Null' check with '== null'.",
+ hasPublishedDocs: true,
+ uniqueName: 'TYPE_CHECK_IS_NULL',
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the library being imported
+ * 1: the name in the hide clause that isn't defined in the library
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a hide combinator includes a
+ // name that isn't defined by the library being imported.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `dart:math` doesn't
+ // define the name `String`:
+ //
+ // ```dart
+ // import 'dart:math' hide [!String!], max;
+ //
+ // var x = min(0, 1);
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If a different name should be hidden, then correct the name. Otherwise,
+ // remove the name from the list:
+ //
+ // ```dart
+ // import 'dart:math' hide max;
+ //
+ // var x = min(0, 1);
+ // ```
+ static const HintCode UNDEFINED_HIDDEN_NAME = HintCode(
+ 'UNDEFINED_HIDDEN_NAME',
+ "The library '{0}' doesn't export a member with the hidden name '{1}'.",
+ correction: "Try removing the name from the list of hidden members.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the undefined parameter
+ * 1: the name of the targeted member
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an annotation of the form
+ // `@UnusedResult.unless(parameterDefined: parameterName)` specifies a
+ // parameter name that isn't defined by the annotated function.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the function `f`
+ // doesn't have a parameter named `b`:
+ //
+ // ```dart
+ // import 'package:meta/meta.dart';
+ //
+ // @UseResult.unless(parameterDefined: [!'b'!])
+ // int f([int? a]) => a ?? 0;
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Change the argument named `parameterDefined` to match the name of one of
+ // the parameters to the function:
+ //
+ // ```dart
+ // import 'package:meta/meta.dart';
+ //
+ // @UseResult.unless(parameterDefined: 'a')
+ // int f([int? a]) => a ?? 0;
+ // ```
+ static const HintCode UNDEFINED_REFERENCED_PARAMETER = HintCode(
+ 'UNDEFINED_REFERENCED_PARAMETER',
+ "The parameter '{0}' is not defined by '{1}'.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the library being imported
+ * 1: the name in the show clause that isn't defined in the library
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a show combinator includes a
+ // name that isn't defined by the library being imported.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `dart:math` doesn't
+ // define the name `String`:
+ //
+ // ```dart
+ // import 'dart:math' show min, [!String!];
+ //
+ // var x = min(0, 1);
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If a different name should be shown, then correct the name. Otherwise,
+ // remove the name from the list:
+ //
+ // ```dart
+ // import 'dart:math' show min;
+ //
+ // var x = min(0, 1);
+ // ```
+ static const HintCode UNDEFINED_SHOWN_NAME = HintCode(
+ 'UNDEFINED_SHOWN_NAME',
+ "The library '{0}' doesn't export a member with the shown name '{1}'.",
+ correction: "Try removing the name from the list of shown members.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the non-diagnostic being ignored
+ */
+ static const HintCode UNIGNORABLE_IGNORE = HintCode(
+ 'UNIGNORABLE_IGNORE',
+ "The diagnostic '{0}' can't be ignored.",
+ correction:
+ "Try removing the name from the list, or removing the whole comment if this is the only name in the list.",
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the value being cast is already
+ // known to be of the type that it's being cast to.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `n` is already known to
+ // be an `int` as a result of the `is` test:
+ //
+ // ```dart
+ // void f(num n) {
+ // if (n is int) {
+ // ([!n as int!]).isEven;
+ // }
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Remove the unnecessary cast:
+ //
+ // ```dart
+ // void f(num n) {
+ // if (n is int) {
+ // n.isEven;
+ // }
+ // }
+ // ```
+ static const HintCode UNNECESSARY_CAST = HintCode(
+ 'UNNECESSARY_CAST',
+ "Unnecessary cast.",
+ correction: "Try removing the cast.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the diagnostic being ignored
+ */
+ static const HintCode UNNECESSARY_IGNORE = HintCode(
+ 'UNNECESSARY_IGNORE',
+ "The diagnostic '{0}' isn't produced at this location so it doesn't need to be ignored.",
+ correction:
+ "Try removing the name from the list, or removing the whole comment if this is the only name in the list.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the uri that is not necessary
+ * 1: the uri that makes it unnecessary
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an import isn't needed because
+ // all of the names that are imported and referenced within the importing
+ // library are also visible through another import.
+ //
+ // #### Example
+ //
+ // Given a file named `a.dart` that contains the following:
+ //
+ // ```dart
+ // %uri="lib/a.dart"
+ // class A {}
+ // ```
+ //
+ // And, given a file named `b.dart` that contains the following:
+ //
+ // ```dart
+ // %uri="lib/b.dart"
+ // export 'a.dart';
+ //
+ // class B {}
+ // ```
+ //
+ // The following code produces this diagnostic because the class `A`, which is
+ // imported from `a.dart`, is also imported from `b.dart`. Removing the import
+ // of `a.dart` leaves the semantics unchanged:
+ //
+ // ```dart
+ // import [!'a.dart'!];
+ // import 'b.dart';
+ //
+ // void f(A a, B b) {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the import isn't needed, then remove it.
+ //
+ // If some of the names imported by this import are intended to be used but
+ // aren't yet, and if those names aren't imported by other imports, then add
+ // the missing references to those names.
+ static const HintCode UNNECESSARY_IMPORT = HintCode(
+ 'UNNECESSARY_IMPORT',
+ "The import of '{0}' is unnecessary because all of the used elements are also provided by the import of '{1}'.",
+ correction: "Try removing the import directive.",
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when there's a declaration of
+ // `noSuchMethod`, the only thing the declaration does is invoke the
+ // overridden declaration, and the overridden declaration isn't the
+ // declaration in `Object`.
+ //
+ // Overriding the implementation of `Object`'s `noSuchMethod` (no matter what
+ // the implementation does) signals to the analyzer that it shouldn't flag any
+ // inherited abstract methods that aren't implemented in that class. This
+ // works even if the overriding implementation is inherited from a superclass,
+ // so there's no value to declare it again in a subclass.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the declaration of
+ // `noSuchMethod` in `A` makes the declaration of `noSuchMethod` in `B`
+ // unnecessary:
+ //
+ // ```dart
+ // class A {
+ // @override
+ // dynamic noSuchMethod(x) => super.noSuchMethod(x);
+ // }
+ // class B extends A {
+ // @override
+ // dynamic [!noSuchMethod!](y) {
+ // return super.noSuchMethod(y);
+ // }
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Remove the unnecessary declaration:
+ //
+ // ```dart
+ // class A {
+ // @override
+ // dynamic noSuchMethod(x) => super.noSuchMethod(x);
+ // }
+ // class B extends A {}
+ // ```
+ static const HintCode UNNECESSARY_NO_SUCH_METHOD = HintCode(
+ 'UNNECESSARY_NO_SUCH_METHOD',
+ "Unnecessary 'noSuchMethod' declaration.",
+ correction: "Try removing the declaration of 'noSuchMethod'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when it finds an equality comparison
+ // (either `==` or `!=`) with one operand of `null` and the other operand
+ // can't be `null`. Such comparisons are always either `true` or `false`, so
+ // they serve no purpose.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because `x` can never be
+ // `null`, so the comparison always evaluates to `true`:
+ //
+ // ```dart
+ // void f(int x) {
+ // if (x [!!= null!]) {
+ // print(x);
+ // }
+ // }
+ // ```
+ //
+ // The following code produces this diagnostic because `x` can never be
+ // `null`, so the comparison always evaluates to `false`:
+ //
+ // ```dart
+ // void f(int x) {
+ // if (x [!== null!]) {
+ // throw ArgumentError("x can't be null");
+ // }
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the other operand should be able to be `null`, then change the type of
+ // the operand:
+ //
+ // ```dart
+ // void f(int? x) {
+ // if (x != null) {
+ // print(x);
+ // }
+ // }
+ // ```
+ //
+ // If the other operand really can't be `null`, then remove the condition:
+ //
+ // ```dart
+ // void f(int x) {
+ // print(x);
+ // }
+ // ```
+ static const HintCode UNNECESSARY_NULL_COMPARISON_FALSE = HintCode(
+ 'UNNECESSARY_NULL_COMPARISON',
+ "The operand can't be null, so the condition is always false.",
+ correction:
+ "Try removing the condition, an enclosing condition, or the whole conditional statement.",
+ hasPublishedDocs: true,
+ uniqueName: 'UNNECESSARY_NULL_COMPARISON_FALSE',
+ );
+
+ /**
+ * No parameters.
+ */
+ static const HintCode UNNECESSARY_NULL_COMPARISON_TRUE = HintCode(
+ 'UNNECESSARY_NULL_COMPARISON',
+ "The operand can't be null, so the condition is always true.",
+ correction: "Remove the condition.",
+ hasPublishedDocs: true,
+ uniqueName: 'UNNECESSARY_NULL_COMPARISON_TRUE',
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the type
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when either the type `dynamic` or the
+ // type `Null` is followed by a question mark. Both of these types are
+ // inherently nullable so the question mark doesn't change the semantics.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the question mark
+ // following `dynamic` isn't necessary:
+ //
+ // ```dart
+ // dynamic[!?!] x;
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Remove the unneeded question mark:
+ //
+ // ```dart
+ // dynamic x;
+ // ```
+ static const HintCode UNNECESSARY_QUESTION_MARK = HintCode(
+ 'UNNECESSARY_QUESTION_MARK',
+ "The '?' is unnecessary because '{0}' is nullable without it.",
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the value of a type check (using
+ // either `is` or `is!`) is known at compile time.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the test `a is Object?`
+ // is always `true`:
+ //
+ // ```dart
+ // bool f<T>(T a) => [!a is Object?!];
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the type check doesn't check what you intended to check, then change the
+ // test:
+ //
+ // ```dart
+ // bool f<T>(T a) => a is Object;
+ // ```
+ //
+ // If the type check does check what you intended to check, then replace the
+ // type check with its known value or completely remove it:
+ //
+ // ```dart
+ // bool f<T>(T a) => true;
+ // ```
+ static const HintCode UNNECESSARY_TYPE_CHECK_FALSE = HintCode(
+ 'UNNECESSARY_TYPE_CHECK',
+ "Unnecessary type check; the result is always 'false'.",
+ correction: "Try correcting the type check, or removing the type check.",
+ hasPublishedDocs: true,
+ uniqueName: 'UNNECESSARY_TYPE_CHECK_FALSE',
+ );
+
+ /**
+ * No parameters.
+ */
+ static const HintCode UNNECESSARY_TYPE_CHECK_TRUE = HintCode(
+ 'UNNECESSARY_TYPE_CHECK',
+ "Unnecessary type check; the result is always 'true'.",
+ correction: "Try correcting the type check, or removing the type check.",
+ hasPublishedDocs: true,
+ uniqueName: 'UNNECESSARY_TYPE_CHECK_TRUE',
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the exception variable
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a `catch` clause is found, and
+ // neither the exception parameter nor the optional stack trace parameter are
+ // used in the `catch` block.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `e` isn't referenced:
+ //
+ // ```dart
+ // void f() {
+ // try {
+ // int.parse(';');
+ // } on FormatException catch ([!e!]) {
+ // // ignored
+ // }
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Remove the unused `catch` clause:
+ //
+ // ```dart
+ // void f() {
+ // try {
+ // int.parse(';');
+ // } on FormatException {
+ // // ignored
+ // }
+ // }
+ // ```
+ static const HintCode UNUSED_CATCH_CLAUSE = HintCode(
+ 'UNUSED_CATCH_CLAUSE',
+ "The exception variable '{0}' isn't used, so the 'catch' clause can be removed.",
+ correction: "Try removing the catch clause.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the stack trace variable
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the stack trace parameter in a
+ // `catch` clause isn't referenced within the body of the `catch` block.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `stackTrace` isn't
+ // referenced:
+ //
+ // ```dart
+ // void f() {
+ // try {
+ // // ...
+ // } catch (exception, [!stackTrace!]) {
+ // // ...
+ // }
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you need to reference the stack trace parameter, then add a reference to
+ // it. Otherwise, remove it:
+ //
+ // ```dart
+ // void f() {
+ // try {
+ // // ...
+ // } catch (exception) {
+ // // ...
+ // }
+ // }
+ // ```
+ static const HintCode UNUSED_CATCH_STACK = HintCode(
+ 'UNUSED_CATCH_STACK',
+ "The stack trace variable '{0}' isn't used and can be removed.",
+ correction: "Try removing the stack trace variable, or using it.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name that is declared but not referenced
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a private declaration isn't
+ // referenced in the library that contains the declaration. The following
+ // kinds of declarations are analyzed:
+ // - Private top-level declarations, such as classes, enums, mixins, typedefs,
+ // top-level variables, and top-level functions
+ // - Private static and instance methods
+ // - Optional parameters of private functions for which a value is never
+ // passed, even when the parameter doesn't have a private name
+ //
+ // #### Examples
+ //
+ // Assuming that no code in the library references `_C`, the following code
+ // produces this diagnostic:
+ //
+ // ```dart
+ // class [!_C!] {}
+ // ```
+ //
+ // Assuming that no code in the library passes a value for `y` in any
+ // invocation of `_m`, the following code produces this diagnostic:
+ //
+ // ```dart
+ // %language=2.9
+ // class C {
+ // void _m(int x, [int [!y!]]) {}
+ //
+ // void n() => _m(0);
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the declaration isn't needed, then remove it:
+ //
+ // ```dart
+ // class C {
+ // void _m(int x) {}
+ //
+ // void n() => _m(0);
+ // }
+ // ```
+ //
+ // If the declaration is intended to be used, then add the code to use it.
+ static const HintCode UNUSED_ELEMENT = HintCode(
+ 'UNUSED_ELEMENT',
+ "The declaration '{0}' isn't referenced.",
+ correction: "Try removing the declaration of '{0}'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the parameter that is declared but not used
+ */
+ static const HintCode UNUSED_ELEMENT_PARAMETER = HintCode(
+ 'UNUSED_ELEMENT',
+ "A value for optional parameter '{0}' isn't ever given.",
+ correction: "Try removing the unused parameter.",
+ hasPublishedDocs: true,
+ uniqueName: 'UNUSED_ELEMENT_PARAMETER',
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the unused field
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a private field is declared but
+ // never read, even if it's written in one or more places.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because the field
+ // `_originalValue` isn't read anywhere in the library:
+ //
+ // ```dart
+ // class C {
+ // final String [!_originalValue!];
+ // final String _currentValue;
+ //
+ // C(this._originalValue) : _currentValue = _originalValue;
+ //
+ // String get value => _currentValue;
+ // }
+ // ```
+ //
+ // It might appear that the field `_originalValue` is being read in the
+ // initializer (`_currentValue = _originalValue`), but that is actually a
+ // reference to the parameter of the same name, not a reference to the field.
+ //
+ // #### Common fixes
+ //
+ // If the field isn't needed, then remove it.
+ //
+ // If the field was intended to be used, then add the missing code.
+ static const HintCode UNUSED_FIELD = HintCode(
+ 'UNUSED_FIELD',
+ "The value of the field '{0}' isn't used.",
+ correction: "Try removing the field, or using it.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the content of the unused import's uri
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an import isn't needed because
+ // none of the names that are imported are referenced within the importing
+ // library.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because nothing defined in
+ // `dart:async` is referenced in the library:
+ //
+ // ```dart
+ // import [!'dart:async'!];
+ //
+ // void main() {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the import isn't needed, then remove it.
+ //
+ // If some of the imported names are intended to be used, then add the missing
+ // code.
+ static const HintCode UNUSED_IMPORT = HintCode(
+ 'UNUSED_IMPORT',
+ "Unused import: '{0}'.",
+ correction: "Try removing the import directive.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the label that isn't used
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a label that isn't used is
+ // found.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because the label `loop` isn't
+ // referenced anywhere in the method:
+ //
+ // ```dart
+ // void f(int limit) {
+ // [!loop:!] for (int i = 0; i < limit; i++) {
+ // print(i);
+ // }
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the label isn't needed, then remove it:
+ //
+ // ```dart
+ // void f(int limit) {
+ // for (int i = 0; i < limit; i++) {
+ // print(i);
+ // }
+ // }
+ // ```
+ //
+ // If the label is needed, then use it:
+ //
+ // ```dart
+ // void f(int limit) {
+ // loop: for (int i = 0; i < limit; i++) {
+ // print(i);
+ // break loop;
+ // }
+ // }
+ // ```
+ // TODO(brianwilkerson) Highlight the identifier without the colon.
+ static const HintCode UNUSED_LABEL = HintCode(
+ 'UNUSED_LABEL',
+ "The label '{0}' isn't used.",
+ correction:
+ "Try removing the label, or using it in either a 'break' or 'continue' statement.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the unused variable
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a local variable is declared but
+ // never read, even if it's written in one or more places.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because the value of `count` is
+ // never read:
+ //
+ // ```dart
+ // void main() {
+ // int [!count!] = 0;
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the variable isn't needed, then remove it.
+ //
+ // If the variable was intended to be used, then add the missing code.
+ static const HintCode UNUSED_LOCAL_VARIABLE = HintCode(
+ 'UNUSED_LOCAL_VARIABLE',
+ "The value of the local variable '{0}' isn't used.",
+ correction: "Try removing the variable or using it.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the annotated method, property or function
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a function annotated with
+ // `useResult` is invoked, and the value returned by that function isn't used.
+ // The value is considered to be used if a member of the value is invoked, if
+ // the value is passed to another function, or if the value is assigned to a
+ // variable or field.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the invocation of
+ // `c.a()` isn't used, even though the method `a` is annotated with
+ // `useResult`:
+ //
+ // ```dart
+ // import 'package:meta/meta.dart';
+ //
+ // class C {
+ // @useResult
+ // int a() => 0;
+ //
+ // int b() => 0;
+ // }
+ //
+ // void f(C c) {
+ // c.[!a!]();
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you intended to invoke the annotated function, then use the value that
+ // was returned:
+ //
+ // ```dart
+ // import 'package:meta/meta.dart';
+ //
+ // class C {
+ // @useResult
+ // int a() => 0;
+ //
+ // int b() => 0;
+ // }
+ //
+ // void f(C c) {
+ // print(c.a());
+ // }
+ // ```
+ //
+ // If you intended to invoke a different function, then correct the name of
+ // the function being invoked:
+ //
+ // ```dart
+ // import 'package:meta/meta.dart';
+ //
+ // class C {
+ // @useResult
+ // int a() => 0;
+ //
+ // int b() => 0;
+ // }
+ //
+ // void f(C c) {
+ // c.b();
+ // }
+ // ```
+ static const HintCode UNUSED_RESULT = HintCode(
+ 'UNUSED_RESULT',
+ "The value of '{0}' should be used.",
+ correction:
+ "Try using the result by invoking a member, passing it to a function, or returning it from this function.",
+ );
+
+ /**
+ * The result of invoking a method, property, or function annotated with
+ * `@useResult` must be used (assigned, passed to a function as an argument,
+ * or returned by a function).
+ *
+ * Parameters:
+ * 0: the name of the annotated method, property or function
+ * 1: message details
+ */
+ static const HintCode UNUSED_RESULT_WITH_MESSAGE = HintCode(
+ 'UNUSED_RESULT',
+ "'{0}' should be used. {1}.",
+ correction:
+ "Try using the result by invoking a member, passing it to a function, or returning it from this function.",
+ uniqueName: 'UNUSED_RESULT_WITH_MESSAGE',
+ );
+
+ /**
+ * Parameters:
+ * 0: the name that is shown but not used
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a show combinator includes a
+ // name that isn't used within the library. Because it isn't referenced, the
+ // name can be removed.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because the function `max`
+ // isn't used:
+ //
+ // ```dart
+ // import 'dart:math' show min, [!max!];
+ //
+ // var x = min(0, 1);
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Either use the name or remove it:
+ //
+ // ```dart
+ // import 'dart:math' show min;
+ //
+ // var x = min(0, 1);
+ // ```
+ static const HintCode UNUSED_SHOWN_NAME = HintCode(
+ 'UNUSED_SHOWN_NAME',
+ "The name {0} is shown, but isn’t used.",
+ correction: "Try removing the name from the list of shown members.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a library is imported using the
+ // `dart-ext` scheme.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the native library `x`
+ // is being imported using a scheme of `dart-ext`:
+ //
+ // ```dart
+ // [!import 'dart-ext:x';!]
+ // int f() native 'string';
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Rewrite the code to use `dart:ffi` as a way of invoking the contents of the
+ // native library.
+ static const HintCode USE_OF_NATIVE_EXTENSION = HintCode(
+ 'USE_OF_NATIVE_EXTENSION',
+ "Dart native extensions are deprecated and aren’t available in Dart 2.15.",
+ correction: "Try using dart:ffi for C interop.",
+ );
+
+ /// Initialize a newly created error code to have the given [name].
+ const HintCode(
+ String name,
+ String message, {
+ String? correction,
+ bool hasPublishedDocs = false,
+ bool isUnresolvedIdentifier = false,
+ String? uniqueName,
+ }) : super(
+ correction: correction,
+ hasPublishedDocs: hasPublishedDocs,
+ isUnresolvedIdentifier: isUnresolvedIdentifier,
+ message: message,
+ name: name,
+ uniqueName: 'HintCode.${uniqueName ?? name}',
+ );
+
+ @override
+ ErrorSeverity get errorSeverity => ErrorType.HINT.severity;
+
+ @override
+ ErrorType get type => ErrorType.HINT;
+}
diff --git a/pkg/analyzer/lib/src/dart/error/syntactic_errors.analyzer.g.dart b/pkg/analyzer/lib/src/dart/error/syntactic_errors.analyzer.g.dart
new file mode 100644
index 0000000..88cb1ff
--- /dev/null
+++ b/pkg/analyzer/lib/src/dart/error/syntactic_errors.analyzer.g.dart
@@ -0,0 +1,1080 @@
+// 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";
+
+part "syntactic_errors.g.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 ParserErrorCode extends ErrorCode {
+ static const ParserErrorCode ABSTRACT_CLASS_MEMBER = _ABSTRACT_CLASS_MEMBER;
+
+ static const ParserErrorCode ABSTRACT_ENUM = ParserErrorCode(
+ 'ABSTRACT_ENUM',
+ "Enums can't be declared to be 'abstract'.",
+ correction: "Try removing the keyword 'abstract'.",
+ );
+
+ static const ParserErrorCode ABSTRACT_EXTERNAL_FIELD =
+ _ABSTRACT_EXTERNAL_FIELD;
+
+ static const ParserErrorCode ABSTRACT_LATE_FIELD = _ABSTRACT_LATE_FIELD;
+
+ static const ParserErrorCode ABSTRACT_STATIC_FIELD = _ABSTRACT_STATIC_FIELD;
+
+ static const ParserErrorCode ABSTRACT_STATIC_METHOD = ParserErrorCode(
+ 'ABSTRACT_STATIC_METHOD',
+ "Static methods can't be declared to be 'abstract'.",
+ correction: "Try removing the keyword 'abstract'.",
+ );
+
+ static const ParserErrorCode ABSTRACT_TOP_LEVEL_FUNCTION = ParserErrorCode(
+ 'ABSTRACT_TOP_LEVEL_FUNCTION',
+ "Top-level functions can't be declared to be 'abstract'.",
+ correction: "Try removing the keyword 'abstract'.",
+ );
+
+ static const ParserErrorCode ABSTRACT_TOP_LEVEL_VARIABLE = ParserErrorCode(
+ 'ABSTRACT_TOP_LEVEL_VARIABLE',
+ "Top-level variables can't be declared to be 'abstract'.",
+ correction: "Try removing the keyword 'abstract'.",
+ );
+
+ static const ParserErrorCode ABSTRACT_TYPEDEF = ParserErrorCode(
+ 'ABSTRACT_TYPEDEF',
+ "Typedefs can't be declared to be 'abstract'.",
+ correction: "Try removing the keyword 'abstract'.",
+ );
+
+ static const ParserErrorCode ANNOTATION_ON_TYPE_ARGUMENT =
+ _ANNOTATION_ON_TYPE_ARGUMENT;
+
+ static const ParserErrorCode ANNOTATION_WITH_TYPE_ARGUMENTS =
+ _ANNOTATION_WITH_TYPE_ARGUMENTS;
+
+ static const ParserErrorCode ANNOTATION_WITH_TYPE_ARGUMENTS_UNINSTANTIATED =
+ _ANNOTATION_WITH_TYPE_ARGUMENTS_UNINSTANTIATED;
+
+ /**
+ * 16.32 Identifier Reference: It is a compile-time error if any of the
+ * identifiers async, await, or yield is used as an identifier in a function
+ * body marked with either async, async, or sync.
+ */
+ static const ParserErrorCode ASYNC_KEYWORD_USED_AS_IDENTIFIER =
+ ParserErrorCode(
+ 'ASYNC_KEYWORD_USED_AS_IDENTIFIER',
+ "The keywords 'await' and 'yield' can't be used as identifiers in an asynchronous or generator function.",
+ );
+
+ static const ParserErrorCode BINARY_OPERATOR_WRITTEN_OUT =
+ _BINARY_OPERATOR_WRITTEN_OUT;
+
+ static const ParserErrorCode BREAK_OUTSIDE_OF_LOOP = _BREAK_OUTSIDE_OF_LOOP;
+
+ static const ParserErrorCode CATCH_SYNTAX = _CATCH_SYNTAX;
+
+ static const ParserErrorCode CATCH_SYNTAX_EXTRA_PARAMETERS =
+ _CATCH_SYNTAX_EXTRA_PARAMETERS;
+
+ static const ParserErrorCode CLASS_IN_CLASS = _CLASS_IN_CLASS;
+
+ static const ParserErrorCode COLON_IN_PLACE_OF_IN = _COLON_IN_PLACE_OF_IN;
+
+ static const ParserErrorCode CONFLICTING_MODIFIERS = _CONFLICTING_MODIFIERS;
+
+ static const ParserErrorCode CONSTRUCTOR_WITH_RETURN_TYPE =
+ _CONSTRUCTOR_WITH_RETURN_TYPE;
+
+ static const ParserErrorCode CONSTRUCTOR_WITH_TYPE_ARGUMENTS =
+ _CONSTRUCTOR_WITH_TYPE_ARGUMENTS;
+
+ static const ParserErrorCode CONST_AND_FINAL = _CONST_AND_FINAL;
+
+ static const ParserErrorCode CONST_CLASS = _CONST_CLASS;
+
+ static const ParserErrorCode CONST_CONSTRUCTOR_WITH_BODY = ParserErrorCode(
+ 'CONST_CONSTRUCTOR_WITH_BODY',
+ "Const constructors can't have a body.",
+ correction: "Try removing either the 'const' keyword or the body.",
+ );
+
+ static const ParserErrorCode CONST_ENUM = ParserErrorCode(
+ 'CONST_ENUM',
+ "Enums can't be declared to be 'const'.",
+ correction: "Try removing the 'const' keyword.",
+ );
+
+ static const ParserErrorCode CONST_FACTORY = _CONST_FACTORY;
+
+ static const ParserErrorCode CONST_METHOD = _CONST_METHOD;
+
+ static const ParserErrorCode CONST_TYPEDEF = ParserErrorCode(
+ 'CONST_TYPEDEF',
+ "Type aliases can't be declared to be 'const'.",
+ correction: "Try removing the 'const' keyword.",
+ );
+
+ static const ParserErrorCode CONTINUE_OUTSIDE_OF_LOOP =
+ _CONTINUE_OUTSIDE_OF_LOOP;
+
+ static const ParserErrorCode CONTINUE_WITHOUT_LABEL_IN_CASE =
+ _CONTINUE_WITHOUT_LABEL_IN_CASE;
+
+ static const ParserErrorCode COVARIANT_AND_STATIC = _COVARIANT_AND_STATIC;
+
+ static const ParserErrorCode COVARIANT_CONSTRUCTOR = ParserErrorCode(
+ 'COVARIANT_CONSTRUCTOR',
+ "A constructor can't be declared to be 'covariant'.",
+ correction: "Try removing the keyword 'covariant'.",
+ );
+
+ static const ParserErrorCode COVARIANT_MEMBER = _COVARIANT_MEMBER;
+
+ static const ParserErrorCode COVARIANT_TOP_LEVEL_DECLARATION =
+ ParserErrorCode(
+ 'COVARIANT_TOP_LEVEL_DECLARATION',
+ "Top-level declarations can't be declared to be covariant.",
+ correction: "Try removing the keyword 'covariant'.",
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a function type associated with
+ // a parameter includes optional parameters that have a default value. This
+ // isn't allowed because the default values of parameters aren't part of the
+ // function's type, and therefore including them doesn't provide any value.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the parameter `p` has a
+ // default value even though it's part of the type of the parameter `g`:
+ //
+ // ```dart
+ // void f(void Function([int p [!=!] 0]) g) {
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Remove the default value from the function-type's parameter:
+ //
+ // ```dart
+ // void f(void Function([int p]) g) {
+ // }
+ // ```
+ static const ParserErrorCode DEFAULT_VALUE_IN_FUNCTION_TYPE = ParserErrorCode(
+ 'DEFAULT_VALUE_IN_FUNCTION_TYPE',
+ "Parameters in a function type can't have default values.",
+ correction: "Try removing the default value.",
+ hasPublishedDocs: true,
+ );
+
+ static const ParserErrorCode DEFERRED_AFTER_PREFIX = _DEFERRED_AFTER_PREFIX;
+
+ static const ParserErrorCode DIRECTIVE_AFTER_DECLARATION =
+ _DIRECTIVE_AFTER_DECLARATION;
+
+ /**
+ * Parameters:
+ * 0: the modifier that was duplicated
+ */
+ static const ParserErrorCode DUPLICATED_MODIFIER = _DUPLICATED_MODIFIER;
+
+ static const ParserErrorCode DUPLICATE_DEFERRED = _DUPLICATE_DEFERRED;
+
+ /**
+ * Parameters:
+ * 0: the label that was duplicated
+ */
+ static const ParserErrorCode DUPLICATE_LABEL_IN_SWITCH_STATEMENT =
+ _DUPLICATE_LABEL_IN_SWITCH_STATEMENT;
+
+ static const ParserErrorCode DUPLICATE_PREFIX = _DUPLICATE_PREFIX;
+
+ static const ParserErrorCode EMPTY_ENUM_BODY = ParserErrorCode(
+ 'EMPTY_ENUM_BODY',
+ "An enum must declare at least one constant name.",
+ correction: "Try declaring a constant.",
+ );
+
+ static const ParserErrorCode ENUM_IN_CLASS = _ENUM_IN_CLASS;
+
+ static const ParserErrorCode EQUALITY_CANNOT_BE_EQUALITY_OPERAND =
+ _EQUALITY_CANNOT_BE_EQUALITY_OPERAND;
+
+ static const ParserErrorCode EXPECTED_BODY = _EXPECTED_BODY;
+
+ static const ParserErrorCode EXPECTED_CASE_OR_DEFAULT = ParserErrorCode(
+ 'EXPECTED_CASE_OR_DEFAULT',
+ "Expected 'case' or 'default'.",
+ correction: "Try placing this code inside a case clause.",
+ );
+
+ static const ParserErrorCode EXPECTED_CLASS_MEMBER = ParserErrorCode(
+ 'EXPECTED_CLASS_MEMBER',
+ "Expected a class member.",
+ correction: "Try placing this code inside a class member.",
+ );
+
+ static const ParserErrorCode EXPECTED_ELSE_OR_COMMA = _EXPECTED_ELSE_OR_COMMA;
+
+ static const ParserErrorCode EXPECTED_EXECUTABLE = ParserErrorCode(
+ 'EXPECTED_EXECUTABLE',
+ "Expected a method, getter, setter or operator declaration.",
+ correction:
+ "This appears to be incomplete code. Try removing it or completing it.",
+ );
+
+ static const ParserErrorCode EXPECTED_IDENTIFIER_BUT_GOT_KEYWORD =
+ _EXPECTED_IDENTIFIER_BUT_GOT_KEYWORD;
+
+ static const ParserErrorCode EXPECTED_INSTEAD = _EXPECTED_INSTEAD;
+
+ static const ParserErrorCode EXPECTED_LIST_OR_MAP_LITERAL = ParserErrorCode(
+ 'EXPECTED_LIST_OR_MAP_LITERAL',
+ "Expected a list or map literal.",
+ correction:
+ "Try inserting a list or map literal, or remove the type arguments.",
+ );
+
+ static const ParserErrorCode EXPECTED_STRING_LITERAL = ParserErrorCode(
+ 'EXPECTED_STRING_LITERAL',
+ "Expected a string literal.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the token that was expected but not found
+ */
+ static const ParserErrorCode EXPECTED_TOKEN = ParserErrorCode(
+ 'EXPECTED_TOKEN',
+ "Expected to find '{0}'.",
+ );
+
+ static const ParserErrorCode EXPECTED_TYPE_NAME = ParserErrorCode(
+ 'EXPECTED_TYPE_NAME',
+ "Expected a type name.",
+ );
+
+ static const ParserErrorCode EXPERIMENT_NOT_ENABLED = _EXPERIMENT_NOT_ENABLED;
+
+ static const ParserErrorCode EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE =
+ _EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE;
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an abstract declaration is
+ // declared in an extension. Extensions can declare only concrete members.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because the method `a` doesn't
+ // have a body:
+ //
+ // ```dart
+ // extension E on String {
+ // int [!a!]();
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Either provide an implementation for the member or remove it.
+ static const ParserErrorCode EXTENSION_DECLARES_ABSTRACT_MEMBER =
+ _EXTENSION_DECLARES_ABSTRACT_MEMBER;
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a constructor declaration is
+ // found in an extension. It isn't valid to define a constructor because
+ // extensions aren't classes, and it isn't possible to create an instance of
+ // an extension.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because there is a constructor
+ // declaration in `E`:
+ //
+ // ```dart
+ // extension E on String {
+ // [!E!]() : super();
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Remove the constructor or replace it with a static method.
+ static const ParserErrorCode EXTENSION_DECLARES_CONSTRUCTOR =
+ _EXTENSION_DECLARES_CONSTRUCTOR;
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an instance field declaration is
+ // found in an extension. It isn't valid to define an instance field because
+ // extensions can only add behavior, not state.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `s` is an instance
+ // field:
+ //
+ // ```dart
+ // %language=2.9
+ // extension E on String {
+ // String [!s!];
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Remove the field, make it a static field, or convert it to be a getter,
+ // setter, or method.
+ static const ParserErrorCode EXTENSION_DECLARES_INSTANCE_FIELD =
+ _EXTENSION_DECLARES_INSTANCE_FIELD;
+
+ static const ParserErrorCode EXTERNAL_CLASS = _EXTERNAL_CLASS;
+
+ static const ParserErrorCode EXTERNAL_CONSTRUCTOR_WITH_BODY =
+ _EXTERNAL_CONSTRUCTOR_WITH_BODY;
+
+ static const ParserErrorCode EXTERNAL_CONSTRUCTOR_WITH_INITIALIZER =
+ _EXTERNAL_CONSTRUCTOR_WITH_INITIALIZER;
+
+ static const ParserErrorCode EXTERNAL_ENUM = _EXTERNAL_ENUM;
+
+ static const ParserErrorCode EXTERNAL_FACTORY_REDIRECTION =
+ _EXTERNAL_FACTORY_REDIRECTION;
+
+ static const ParserErrorCode EXTERNAL_FACTORY_WITH_BODY =
+ _EXTERNAL_FACTORY_WITH_BODY;
+
+ static const ParserErrorCode EXTERNAL_FIELD = _EXTERNAL_FIELD;
+
+ static const ParserErrorCode EXTERNAL_GETTER_WITH_BODY = ParserErrorCode(
+ 'EXTERNAL_GETTER_WITH_BODY',
+ "External getters can't have a body.",
+ correction:
+ "Try removing the body of the getter, or removing the keyword 'external'.",
+ );
+
+ static const ParserErrorCode EXTERNAL_LATE_FIELD = _EXTERNAL_LATE_FIELD;
+
+ static const ParserErrorCode EXTERNAL_METHOD_WITH_BODY =
+ _EXTERNAL_METHOD_WITH_BODY;
+
+ static const ParserErrorCode EXTERNAL_OPERATOR_WITH_BODY = ParserErrorCode(
+ 'EXTERNAL_OPERATOR_WITH_BODY',
+ "External operators can't have a body.",
+ correction:
+ "Try removing the body of the operator, or removing the keyword 'external'.",
+ );
+
+ static const ParserErrorCode EXTERNAL_SETTER_WITH_BODY = ParserErrorCode(
+ 'EXTERNAL_SETTER_WITH_BODY',
+ "External setters can't have a body.",
+ correction:
+ "Try removing the body of the setter, or removing the keyword 'external'.",
+ );
+
+ static const ParserErrorCode EXTERNAL_TYPEDEF = _EXTERNAL_TYPEDEF;
+
+ static const ParserErrorCode EXTRANEOUS_MODIFIER = _EXTRANEOUS_MODIFIER;
+
+ static const ParserErrorCode FACTORY_TOP_LEVEL_DECLARATION =
+ _FACTORY_TOP_LEVEL_DECLARATION;
+
+ static const ParserErrorCode FACTORY_WITHOUT_BODY = ParserErrorCode(
+ 'FACTORY_WITHOUT_BODY',
+ "A non-redirecting 'factory' constructor must have a body.",
+ correction: "Try adding a body to the constructor.",
+ );
+
+ static const ParserErrorCode FACTORY_WITH_INITIALIZERS = ParserErrorCode(
+ 'FACTORY_WITH_INITIALIZERS',
+ "A 'factory' constructor can't have initializers.",
+ correction:
+ "Try removing the 'factory' keyword to make this a generative constructor, or removing the initializers.",
+ );
+
+ static const ParserErrorCode FIELD_INITIALIZED_OUTSIDE_DECLARING_CLASS =
+ _FIELD_INITIALIZED_OUTSIDE_DECLARING_CLASS;
+
+ static const ParserErrorCode FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR =
+ _FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR;
+
+ static const ParserErrorCode FINAL_AND_COVARIANT = _FINAL_AND_COVARIANT;
+
+ static const ParserErrorCode FINAL_AND_COVARIANT_LATE_WITH_INITIALIZER =
+ _FINAL_AND_COVARIANT_LATE_WITH_INITIALIZER;
+
+ static const ParserErrorCode FINAL_AND_VAR = _FINAL_AND_VAR;
+
+ static const ParserErrorCode FINAL_CLASS = ParserErrorCode(
+ 'FINAL_CLASS',
+ "Classes can't be declared to be 'final'.",
+ correction: "Try removing the keyword 'final'.",
+ );
+
+ static const ParserErrorCode FINAL_CONSTRUCTOR = ParserErrorCode(
+ 'FINAL_CONSTRUCTOR',
+ "A constructor can't be declared to be 'final'.",
+ correction: "Try removing the keyword 'final'.",
+ );
+
+ static const ParserErrorCode FINAL_ENUM = ParserErrorCode(
+ 'FINAL_ENUM',
+ "Enums can't be declared to be 'final'.",
+ correction: "Try removing the keyword 'final'.",
+ );
+
+ static const ParserErrorCode FINAL_METHOD = ParserErrorCode(
+ 'FINAL_METHOD',
+ "Getters, setters and methods can't be declared to be 'final'.",
+ correction: "Try removing the keyword 'final'.",
+ );
+
+ static const ParserErrorCode FINAL_TYPEDEF = ParserErrorCode(
+ 'FINAL_TYPEDEF',
+ "Typedefs can't be declared to be 'final'.",
+ correction: "Try removing the keyword 'final'.",
+ );
+
+ static const ParserErrorCode FUNCTION_TYPED_PARAMETER_VAR = ParserErrorCode(
+ 'FUNCTION_TYPED_PARAMETER_VAR',
+ "Function-typed parameters can't specify 'const', 'final' or 'var' in place of a return type.",
+ correction: "Try replacing the keyword with a return type.",
+ );
+
+ static const ParserErrorCode GETTER_CONSTRUCTOR = _GETTER_CONSTRUCTOR;
+
+ static const ParserErrorCode GETTER_IN_FUNCTION = ParserErrorCode(
+ 'GETTER_IN_FUNCTION',
+ "Getters can't be defined within methods or functions.",
+ correction:
+ "Try moving the getter outside the method or function, or converting the getter to a function.",
+ );
+
+ static const ParserErrorCode GETTER_WITH_PARAMETERS = ParserErrorCode(
+ 'GETTER_WITH_PARAMETERS',
+ "Getters must be declared without a parameter list.",
+ correction:
+ "Try removing the parameter list, or removing the keyword 'get' to define a method rather than a getter.",
+ );
+
+ static const ParserErrorCode ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE =
+ _ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE;
+
+ static const ParserErrorCode IMPLEMENTS_BEFORE_EXTENDS =
+ _IMPLEMENTS_BEFORE_EXTENDS;
+
+ static const ParserErrorCode IMPLEMENTS_BEFORE_ON = _IMPLEMENTS_BEFORE_ON;
+
+ static const ParserErrorCode IMPLEMENTS_BEFORE_WITH = _IMPLEMENTS_BEFORE_WITH;
+
+ static const ParserErrorCode IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE =
+ _IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE;
+
+ static const ParserErrorCode INITIALIZED_VARIABLE_IN_FOR_EACH =
+ _INITIALIZED_VARIABLE_IN_FOR_EACH;
+
+ static const ParserErrorCode INVALID_AWAIT_IN_FOR = _INVALID_AWAIT_IN_FOR;
+
+ /**
+ * Parameters:
+ * 0: the invalid escape sequence
+ */
+ static const ParserErrorCode INVALID_CODE_POINT = ParserErrorCode(
+ 'INVALID_CODE_POINT',
+ "The escape sequence '{0}' isn't a valid code point.",
+ );
+
+ static const ParserErrorCode INVALID_COMMENT_REFERENCE = ParserErrorCode(
+ 'INVALID_COMMENT_REFERENCE',
+ "Comment references should contain a possibly prefixed identifier and can start with 'new', but shouldn't contain anything else.",
+ );
+
+ static const ParserErrorCode INVALID_CONSTRUCTOR_NAME =
+ _INVALID_CONSTRUCTOR_NAME;
+
+ static const ParserErrorCode INVALID_GENERIC_FUNCTION_TYPE = ParserErrorCode(
+ 'INVALID_GENERIC_FUNCTION_TYPE',
+ "Invalid generic function type.",
+ correction:
+ "Try using a generic function type (returnType 'Function(' parameters ')').",
+ );
+
+ static const ParserErrorCode INVALID_HEX_ESCAPE = _INVALID_HEX_ESCAPE;
+
+ static const ParserErrorCode INVALID_INITIALIZER = _INVALID_INITIALIZER;
+
+ static const ParserErrorCode INVALID_LITERAL_IN_CONFIGURATION =
+ ParserErrorCode(
+ 'INVALID_LITERAL_IN_CONFIGURATION',
+ "The literal in a configuration can't contain interpolation.",
+ correction: "Try removing the interpolation expressions.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the operator that is invalid
+ */
+ static const ParserErrorCode INVALID_OPERATOR = _INVALID_OPERATOR;
+
+ /**
+ * Parameters:
+ * 0: the operator being applied to 'super'
+ *
+ * Only generated by the old parser.
+ * Replaced by INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER.
+ */
+ static const ParserErrorCode INVALID_OPERATOR_FOR_SUPER = ParserErrorCode(
+ 'INVALID_OPERATOR_FOR_SUPER',
+ "The operator '{0}' can't be used with 'super'.",
+ );
+
+ static const ParserErrorCode INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER =
+ _INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER;
+
+ static const ParserErrorCode INVALID_STAR_AFTER_ASYNC = ParserErrorCode(
+ 'INVALID_STAR_AFTER_ASYNC',
+ "The modifier 'async*' isn't allowed for an expression function body.",
+ correction: "Try converting the body to a block.",
+ );
+
+ static const ParserErrorCode INVALID_SUPER_IN_INITIALIZER =
+ _INVALID_SUPER_IN_INITIALIZER;
+
+ static const ParserErrorCode INVALID_SYNC = ParserErrorCode(
+ 'INVALID_SYNC',
+ "The modifier 'sync' isn't allowed for an expression function body.",
+ correction: "Try converting the body to a block.",
+ );
+
+ static const ParserErrorCode INVALID_THIS_IN_INITIALIZER =
+ _INVALID_THIS_IN_INITIALIZER;
+
+ static const ParserErrorCode INVALID_UNICODE_ESCAPE = _INVALID_UNICODE_ESCAPE;
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a member declared inside an
+ // extension uses the keyword `covariant` in the declaration of a parameter.
+ // Extensions aren't classes and don't have subclasses, so the keyword serves
+ // no purpose.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `i` is marked as being
+ // covariant:
+ //
+ // ```dart
+ // extension E on String {
+ // void a([!covariant!] int i) {}
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Remove the `covariant` keyword:
+ //
+ // ```dart
+ // extension E on String {
+ // void a(int i) {}
+ // }
+ // ```
+ static const ParserErrorCode INVALID_USE_OF_COVARIANT_IN_EXTENSION =
+ _INVALID_USE_OF_COVARIANT_IN_EXTENSION;
+
+ static const ParserErrorCode LIBRARY_DIRECTIVE_NOT_FIRST =
+ _LIBRARY_DIRECTIVE_NOT_FIRST;
+
+ static const ParserErrorCode LITERAL_WITH_CLASS = _LITERAL_WITH_CLASS;
+
+ static const ParserErrorCode LITERAL_WITH_CLASS_AND_NEW =
+ _LITERAL_WITH_CLASS_AND_NEW;
+
+ static const ParserErrorCode LITERAL_WITH_NEW = _LITERAL_WITH_NEW;
+
+ static const ParserErrorCode LOCAL_FUNCTION_DECLARATION_MODIFIER =
+ ParserErrorCode(
+ 'LOCAL_FUNCTION_DECLARATION_MODIFIER',
+ "Local function declarations can't specify any modifiers.",
+ correction: "Try removing the modifier.",
+ );
+
+ static const ParserErrorCode MEMBER_WITH_CLASS_NAME = _MEMBER_WITH_CLASS_NAME;
+
+ static const ParserErrorCode MISSING_ASSIGNABLE_SELECTOR =
+ _MISSING_ASSIGNABLE_SELECTOR;
+
+ static const ParserErrorCode MISSING_ASSIGNMENT_IN_INITIALIZER =
+ _MISSING_ASSIGNMENT_IN_INITIALIZER;
+
+ static const ParserErrorCode MISSING_CATCH_OR_FINALLY =
+ _MISSING_CATCH_OR_FINALLY;
+
+ static const ParserErrorCode MISSING_CLOSING_PARENTHESIS = ParserErrorCode(
+ 'MISSING_CLOSING_PARENTHESIS',
+ "The closing parenthesis is missing.",
+ correction: "Try adding the closing parenthesis.",
+ );
+
+ static const ParserErrorCode MISSING_CONST_FINAL_VAR_OR_TYPE =
+ _MISSING_CONST_FINAL_VAR_OR_TYPE;
+
+ static const ParserErrorCode MISSING_ENUM_BODY = ParserErrorCode(
+ 'MISSING_ENUM_BODY',
+ "An enum definition must have a body with at least one constant name.",
+ correction: "Try adding a body and defining at least one constant.",
+ );
+
+ static const ParserErrorCode MISSING_EXPRESSION_IN_INITIALIZER =
+ ParserErrorCode(
+ 'MISSING_EXPRESSION_IN_INITIALIZER',
+ "Expected an expression after the assignment operator.",
+ correction:
+ "Try adding the value to be assigned, or remove the assignment operator.",
+ );
+
+ static const ParserErrorCode MISSING_EXPRESSION_IN_THROW =
+ _MISSING_EXPRESSION_IN_THROW;
+
+ static const ParserErrorCode MISSING_FUNCTION_BODY = ParserErrorCode(
+ 'MISSING_FUNCTION_BODY',
+ "A function body must be provided.",
+ correction: "Try adding a function body.",
+ );
+
+ static const ParserErrorCode MISSING_FUNCTION_KEYWORD = ParserErrorCode(
+ 'MISSING_FUNCTION_KEYWORD',
+ "Function types must have the keyword 'Function' before the parameter list.",
+ correction: "Try adding the keyword 'Function'.",
+ );
+
+ static const ParserErrorCode MISSING_FUNCTION_PARAMETERS = ParserErrorCode(
+ 'MISSING_FUNCTION_PARAMETERS',
+ "Functions must have an explicit list of parameters.",
+ correction: "Try adding a parameter list.",
+ );
+
+ static const ParserErrorCode MISSING_GET = ParserErrorCode(
+ 'MISSING_GET',
+ "Getters must have the keyword 'get' before the getter name.",
+ correction: "Try adding the keyword 'get'.",
+ );
+
+ static const ParserErrorCode MISSING_IDENTIFIER = ParserErrorCode(
+ 'MISSING_IDENTIFIER',
+ "Expected an identifier.",
+ );
+
+ static const ParserErrorCode MISSING_INITIALIZER = _MISSING_INITIALIZER;
+
+ static const ParserErrorCode MISSING_KEYWORD_OPERATOR =
+ _MISSING_KEYWORD_OPERATOR;
+
+ static const ParserErrorCode MISSING_METHOD_PARAMETERS = ParserErrorCode(
+ 'MISSING_METHOD_PARAMETERS',
+ "Methods must have an explicit list of parameters.",
+ correction: "Try adding a parameter list.",
+ );
+
+ static const ParserErrorCode MISSING_NAME_FOR_NAMED_PARAMETER =
+ ParserErrorCode(
+ 'MISSING_NAME_FOR_NAMED_PARAMETER',
+ "Named parameters in a function type must have a name",
+ correction:
+ "Try providing a name for the parameter or removing the curly braces.",
+ );
+
+ static const ParserErrorCode MISSING_NAME_IN_LIBRARY_DIRECTIVE =
+ ParserErrorCode(
+ 'MISSING_NAME_IN_LIBRARY_DIRECTIVE',
+ "Library directives must include a library name.",
+ correction:
+ "Try adding a library name after the keyword 'library', or remove the library directive if the library doesn't have any parts.",
+ );
+
+ static const ParserErrorCode MISSING_NAME_IN_PART_OF_DIRECTIVE =
+ ParserErrorCode(
+ 'MISSING_NAME_IN_PART_OF_DIRECTIVE',
+ "Part-of directives must include a library name.",
+ correction: "Try adding a library name after the 'of'.",
+ );
+
+ static const ParserErrorCode MISSING_PREFIX_IN_DEFERRED_IMPORT =
+ _MISSING_PREFIX_IN_DEFERRED_IMPORT;
+
+ static const ParserErrorCode MISSING_STAR_AFTER_SYNC = ParserErrorCode(
+ 'MISSING_STAR_AFTER_SYNC',
+ "The modifier 'sync' must be followed by a star ('*').",
+ correction: "Try removing the modifier, or add a star.",
+ );
+
+ static const ParserErrorCode MISSING_STATEMENT = _MISSING_STATEMENT;
+
+ /**
+ * Parameters:
+ * 0: the terminator that is missing
+ */
+ static const ParserErrorCode MISSING_TERMINATOR_FOR_PARAMETER_GROUP =
+ ParserErrorCode(
+ 'MISSING_TERMINATOR_FOR_PARAMETER_GROUP',
+ "There is no '{0}' to close the parameter group.",
+ correction: "Try inserting a '{0}' at the end of the group.",
+ );
+
+ static const ParserErrorCode MISSING_TYPEDEF_PARAMETERS = ParserErrorCode(
+ 'MISSING_TYPEDEF_PARAMETERS',
+ "Typedefs must have an explicit list of parameters.",
+ correction: "Try adding a parameter list.",
+ );
+
+ static const ParserErrorCode MISSING_VARIABLE_IN_FOR_EACH = ParserErrorCode(
+ 'MISSING_VARIABLE_IN_FOR_EACH',
+ "A loop variable must be declared in a for-each loop before the 'in', but none was found.",
+ correction: "Try declaring a loop variable.",
+ );
+
+ static const ParserErrorCode MIXED_PARAMETER_GROUPS = ParserErrorCode(
+ 'MIXED_PARAMETER_GROUPS',
+ "Can't have both positional and named parameters in a single parameter list.",
+ correction: "Try choosing a single style of optional parameters.",
+ );
+
+ static const ParserErrorCode MIXIN_DECLARES_CONSTRUCTOR =
+ _MIXIN_DECLARES_CONSTRUCTOR;
+
+ static const ParserErrorCode MODIFIER_OUT_OF_ORDER = _MODIFIER_OUT_OF_ORDER;
+
+ static const ParserErrorCode MULTIPLE_EXTENDS_CLAUSES =
+ _MULTIPLE_EXTENDS_CLAUSES;
+
+ static const ParserErrorCode MULTIPLE_IMPLEMENTS_CLAUSES = ParserErrorCode(
+ 'MULTIPLE_IMPLEMENTS_CLAUSES',
+ "Each class or mixin definition can have at most one implements clause.",
+ correction:
+ "Try combining all of the implements clauses into a single clause.",
+ );
+
+ static const ParserErrorCode MULTIPLE_LIBRARY_DIRECTIVES =
+ _MULTIPLE_LIBRARY_DIRECTIVES;
+
+ static const ParserErrorCode MULTIPLE_NAMED_PARAMETER_GROUPS =
+ ParserErrorCode(
+ 'MULTIPLE_NAMED_PARAMETER_GROUPS',
+ "Can't have multiple groups of named parameters in a single parameter list.",
+ correction: "Try combining all of the groups into a single group.",
+ );
+
+ static const ParserErrorCode MULTIPLE_ON_CLAUSES = _MULTIPLE_ON_CLAUSES;
+
+ static const ParserErrorCode MULTIPLE_PART_OF_DIRECTIVES =
+ _MULTIPLE_PART_OF_DIRECTIVES;
+
+ static const ParserErrorCode MULTIPLE_POSITIONAL_PARAMETER_GROUPS =
+ ParserErrorCode(
+ 'MULTIPLE_POSITIONAL_PARAMETER_GROUPS',
+ "Can't have multiple groups of positional parameters in a single parameter list.",
+ correction: "Try combining all of the groups into a single group.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the number of variables being declared
+ */
+ static const ParserErrorCode MULTIPLE_VARIABLES_IN_FOR_EACH = ParserErrorCode(
+ 'MULTIPLE_VARIABLES_IN_FOR_EACH',
+ "A single loop variable must be declared in a for-each loop before the 'in', but {0} were found.",
+ correction:
+ "Try moving all but one of the declarations inside the loop body.",
+ );
+
+ static const ParserErrorCode MULTIPLE_VARIANCE_MODIFIERS =
+ _MULTIPLE_VARIANCE_MODIFIERS;
+
+ static const ParserErrorCode MULTIPLE_WITH_CLAUSES = _MULTIPLE_WITH_CLAUSES;
+
+ static const ParserErrorCode NAMED_FUNCTION_EXPRESSION = ParserErrorCode(
+ 'NAMED_FUNCTION_EXPRESSION',
+ "Function expressions can't be named.",
+ correction:
+ "Try removing the name, or moving the function expression to a function declaration statement.",
+ );
+
+ static const ParserErrorCode NAMED_FUNCTION_TYPE = ParserErrorCode(
+ 'NAMED_FUNCTION_TYPE',
+ "Function types can't be named.",
+ correction: "Try replacing the name with the keyword 'Function'.",
+ );
+
+ static const ParserErrorCode NAMED_PARAMETER_OUTSIDE_GROUP = ParserErrorCode(
+ 'NAMED_PARAMETER_OUTSIDE_GROUP',
+ "Named parameters must be enclosed in curly braces ('{' and '}').",
+ correction: "Try surrounding the named parameters in curly braces.",
+ );
+
+ static const ParserErrorCode NATIVE_CLAUSE_IN_NON_SDK_CODE = ParserErrorCode(
+ 'NATIVE_CLAUSE_IN_NON_SDK_CODE',
+ "Native clause can only be used in the SDK and code that is loaded through native extensions.",
+ correction: "Try removing the native clause.",
+ );
+
+ static const ParserErrorCode NATIVE_CLAUSE_SHOULD_BE_ANNOTATION =
+ _NATIVE_CLAUSE_SHOULD_BE_ANNOTATION;
+
+ static const ParserErrorCode NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE =
+ ParserErrorCode(
+ 'NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE',
+ "Native functions can only be declared in the SDK and code that is loaded through native extensions.",
+ correction: "Try removing the word 'native'.",
+ );
+
+ static const ParserErrorCode NON_CONSTRUCTOR_FACTORY = ParserErrorCode(
+ 'NON_CONSTRUCTOR_FACTORY',
+ "Only a constructor can be declared to be a factory.",
+ correction: "Try removing the keyword 'factory'.",
+ );
+
+ static const ParserErrorCode NON_IDENTIFIER_LIBRARY_NAME = ParserErrorCode(
+ 'NON_IDENTIFIER_LIBRARY_NAME',
+ "The name of a library must be an identifier.",
+ correction: "Try using an identifier as the name of the library.",
+ );
+
+ static const ParserErrorCode NON_PART_OF_DIRECTIVE_IN_PART = ParserErrorCode(
+ 'NON_PART_OF_DIRECTIVE_IN_PART',
+ "The part-of directive must be the only directive in a part.",
+ correction:
+ "Try removing the other directives, or moving them to the library for which this is a part.",
+ );
+
+ static const ParserErrorCode NON_STRING_LITERAL_AS_URI = ParserErrorCode(
+ 'NON_STRING_LITERAL_AS_URI',
+ "The URI must be a string literal.",
+ correction: "Try enclosing the URI in either single or double quotes.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the operator that the user is trying to define
+ */
+ static const ParserErrorCode NON_USER_DEFINABLE_OPERATOR = ParserErrorCode(
+ 'NON_USER_DEFINABLE_OPERATOR',
+ "The operator '{0}' isn't user definable.",
+ );
+
+ static const ParserErrorCode NORMAL_BEFORE_OPTIONAL_PARAMETERS =
+ ParserErrorCode(
+ 'NORMAL_BEFORE_OPTIONAL_PARAMETERS',
+ "Normal parameters must occur before optional parameters.",
+ correction:
+ "Try moving all of the normal parameters before the optional parameters.",
+ );
+
+ static const ParserErrorCode NULL_AWARE_CASCADE_OUT_OF_ORDER =
+ _NULL_AWARE_CASCADE_OUT_OF_ORDER;
+
+ static const ParserErrorCode POSITIONAL_AFTER_NAMED_ARGUMENT =
+ ParserErrorCode(
+ 'POSITIONAL_AFTER_NAMED_ARGUMENT',
+ "Positional arguments must occur before named arguments.",
+ correction:
+ "Try moving all of the positional arguments before the named arguments.",
+ );
+
+ static const ParserErrorCode POSITIONAL_PARAMETER_OUTSIDE_GROUP =
+ ParserErrorCode(
+ 'POSITIONAL_PARAMETER_OUTSIDE_GROUP',
+ "Positional parameters must be enclosed in square brackets ('[' and ']').",
+ correction: "Try surrounding the positional parameters in square brackets.",
+ );
+
+ static const ParserErrorCode PREFIX_AFTER_COMBINATOR =
+ _PREFIX_AFTER_COMBINATOR;
+
+ static const ParserErrorCode REDIRECTING_CONSTRUCTOR_WITH_BODY =
+ _REDIRECTING_CONSTRUCTOR_WITH_BODY;
+
+ static const ParserErrorCode REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR =
+ _REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR;
+
+ static const ParserErrorCode SETTER_CONSTRUCTOR = _SETTER_CONSTRUCTOR;
+
+ static const ParserErrorCode SETTER_IN_FUNCTION = ParserErrorCode(
+ 'SETTER_IN_FUNCTION',
+ "Setters can't be defined within methods or functions.",
+ correction: "Try moving the setter outside the method or function.",
+ );
+
+ static const ParserErrorCode STACK_OVERFLOW = _STACK_OVERFLOW;
+
+ static const ParserErrorCode STATIC_CONSTRUCTOR = _STATIC_CONSTRUCTOR;
+
+ static const ParserErrorCode STATIC_GETTER_WITHOUT_BODY = ParserErrorCode(
+ 'STATIC_GETTER_WITHOUT_BODY',
+ "A 'static' getter must have a body.",
+ correction:
+ "Try adding a body to the getter, or removing the keyword 'static'.",
+ );
+
+ static const ParserErrorCode STATIC_OPERATOR = _STATIC_OPERATOR;
+
+ static const ParserErrorCode STATIC_SETTER_WITHOUT_BODY = ParserErrorCode(
+ 'STATIC_SETTER_WITHOUT_BODY',
+ "A 'static' setter must have a body.",
+ correction:
+ "Try adding a body to the setter, or removing the keyword 'static'.",
+ );
+
+ static const ParserErrorCode STATIC_TOP_LEVEL_DECLARATION = ParserErrorCode(
+ 'STATIC_TOP_LEVEL_DECLARATION',
+ "Top-level declarations can't be declared to be static.",
+ correction: "Try removing the keyword 'static'.",
+ );
+
+ static const ParserErrorCode SWITCH_HAS_CASE_AFTER_DEFAULT_CASE =
+ _SWITCH_HAS_CASE_AFTER_DEFAULT_CASE;
+
+ static const ParserErrorCode SWITCH_HAS_MULTIPLE_DEFAULT_CASES =
+ _SWITCH_HAS_MULTIPLE_DEFAULT_CASES;
+
+ static const ParserErrorCode TOP_LEVEL_OPERATOR = _TOP_LEVEL_OPERATOR;
+
+ static const ParserErrorCode TYPEDEF_IN_CLASS = _TYPEDEF_IN_CLASS;
+
+ static const ParserErrorCode TYPE_ARGUMENTS_ON_TYPE_VARIABLE =
+ _TYPE_ARGUMENTS_ON_TYPE_VARIABLE;
+
+ static const ParserErrorCode TYPE_BEFORE_FACTORY = _TYPE_BEFORE_FACTORY;
+
+ static const ParserErrorCode TYPE_PARAMETER_ON_CONSTRUCTOR =
+ _TYPE_PARAMETER_ON_CONSTRUCTOR;
+
+ /**
+ * 7.1.1 Operators: Type parameters are not syntactically supported on an
+ * operator.
+ */
+ static const ParserErrorCode TYPE_PARAMETER_ON_OPERATOR = ParserErrorCode(
+ 'TYPE_PARAMETER_ON_OPERATOR',
+ "Types parameters aren't allowed when defining an operator.",
+ correction: "Try removing the type parameters.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the starting character that was missing
+ */
+ static const ParserErrorCode UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP =
+ ParserErrorCode(
+ 'UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP',
+ "There is no '{0}' to open a parameter group.",
+ correction: "Try inserting the '{0}' at the appropriate location.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the unexpected text that was found
+ */
+ static const ParserErrorCode UNEXPECTED_TOKEN = ParserErrorCode(
+ 'UNEXPECTED_TOKEN',
+ "Unexpected text '{0}'.",
+ correction: "Try removing the text.",
+ );
+
+ static const ParserErrorCode VAR_AND_TYPE = _VAR_AND_TYPE;
+
+ static const ParserErrorCode VAR_AS_TYPE_NAME = _VAR_AS_TYPE_NAME;
+
+ static const ParserErrorCode VAR_CLASS = ParserErrorCode(
+ 'VAR_CLASS',
+ "Classes can't be declared to be 'var'.",
+ correction: "Try removing the keyword 'var'.",
+ );
+
+ static const ParserErrorCode VAR_ENUM = ParserErrorCode(
+ 'VAR_ENUM',
+ "Enums can't be declared to be 'var'.",
+ correction: "Try removing the keyword 'var'.",
+ );
+
+ static const ParserErrorCode VAR_RETURN_TYPE = _VAR_RETURN_TYPE;
+
+ static const ParserErrorCode VAR_TYPEDEF = ParserErrorCode(
+ 'VAR_TYPEDEF',
+ "Typedefs can't be declared to be 'var'.",
+ correction:
+ "Try removing the keyword 'var', or replacing it with the name of the return type.",
+ );
+
+ static const ParserErrorCode VOID_WITH_TYPE_ARGUMENTS =
+ _VOID_WITH_TYPE_ARGUMENTS;
+
+ static const ParserErrorCode WITH_BEFORE_EXTENDS = _WITH_BEFORE_EXTENDS;
+
+ static const ParserErrorCode WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER =
+ ParserErrorCode(
+ 'WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER',
+ "The default value of a positional parameter should be preceded by '='.",
+ correction: "Try replacing the ':' with '='.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the terminator that was expected
+ * 1: the terminator that was found
+ */
+ static const ParserErrorCode WRONG_TERMINATOR_FOR_PARAMETER_GROUP =
+ ParserErrorCode(
+ 'WRONG_TERMINATOR_FOR_PARAMETER_GROUP',
+ "Expected '{0}' to close parameter group.",
+ correction: "Try replacing '{0}' with '{1}'.",
+ );
+
+ /// Initialize a newly created error code to have the given [name].
+ const ParserErrorCode(
+ String name,
+ String message, {
+ String? correction,
+ bool hasPublishedDocs = false,
+ bool isUnresolvedIdentifier = false,
+ String? uniqueName,
+ }) : super(
+ correction: correction,
+ hasPublishedDocs: hasPublishedDocs,
+ isUnresolvedIdentifier: isUnresolvedIdentifier,
+ message: message,
+ name: name,
+ uniqueName: 'ParserErrorCode.${uniqueName ?? name}',
+ );
+
+ @override
+ ErrorSeverity get errorSeverity => ErrorSeverity.ERROR;
+
+ @override
+ ErrorType get type => ErrorType.SYNTACTIC_ERROR;
+}
diff --git a/pkg/analyzer/lib/src/dart/error/syntactic_errors.dart b/pkg/analyzer/lib/src/dart/error/syntactic_errors.dart
index 7aea6d5..6d60a5f 100644
--- a/pkg/analyzer/lib/src/dart/error/syntactic_errors.dart
+++ b/pkg/analyzer/lib/src/dart/error/syntactic_errors.dart
@@ -2,958 +2,6 @@
// 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.
-// 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
-
-/**
- * The errors produced during syntactic analysis (scanning and parsing).
- */
-import 'package:analyzer/error/error.dart';
-
export 'package:_fe_analyzer_shared/src/scanner/errors.dart'
show ScannerErrorCode;
-
-part 'syntactic_errors.g.dart';
-
-/**
- * The error codes used for errors detected by the parser. The convention for
- * this class is for the name of the error code to indicate the problem that
- * caused the error to be generated and for the error message to explain what
- * is wrong and, when appropriate, how the problem can be corrected.
- */
-class ParserErrorCode extends ErrorCode {
- static const ParserErrorCode ABSTRACT_CLASS_MEMBER = _ABSTRACT_CLASS_MEMBER;
-
- static const ParserErrorCode ABSTRACT_ENUM = ParserErrorCode(
- 'ABSTRACT_ENUM', "Enums can't be declared to be 'abstract'.",
- correction: "Try removing the keyword 'abstract'.");
-
- static const ParserErrorCode ABSTRACT_EXTERNAL_FIELD =
- _ABSTRACT_EXTERNAL_FIELD;
-
- static const ParserErrorCode ABSTRACT_LATE_FIELD = _ABSTRACT_LATE_FIELD;
-
- static const ParserErrorCode ABSTRACT_STATIC_FIELD = _ABSTRACT_STATIC_FIELD;
-
- static const ParserErrorCode ABSTRACT_STATIC_METHOD = ParserErrorCode(
- 'ABSTRACT_STATIC_METHOD',
- "Static methods can't be declared to be 'abstract'.",
- correction: "Try removing the keyword 'abstract'.");
-
- static const ParserErrorCode ABSTRACT_TOP_LEVEL_FUNCTION = ParserErrorCode(
- 'ABSTRACT_TOP_LEVEL_FUNCTION',
- "Top-level functions can't be declared to be 'abstract'.",
- correction: "Try removing the keyword 'abstract'.");
-
- static const ParserErrorCode ABSTRACT_TOP_LEVEL_VARIABLE = ParserErrorCode(
- 'ABSTRACT_TOP_LEVEL_VARIABLE',
- "Top-level variables can't be declared to be 'abstract'.",
- correction: "Try removing the keyword 'abstract'.");
-
- static const ParserErrorCode ABSTRACT_TYPEDEF = ParserErrorCode(
- 'ABSTRACT_TYPEDEF', "Typedefs can't be declared to be 'abstract'.",
- correction: "Try removing the keyword 'abstract'.");
-
- static const ParserErrorCode ANNOTATION_ON_TYPE_ARGUMENT =
- _ANNOTATION_ON_TYPE_ARGUMENT;
-
- static const ParserErrorCode ANNOTATION_WITH_TYPE_ARGUMENTS =
- _ANNOTATION_WITH_TYPE_ARGUMENTS;
-
- static const ParserErrorCode ANNOTATION_WITH_TYPE_ARGUMENTS_UNINSTANTIATED =
- _ANNOTATION_WITH_TYPE_ARGUMENTS_UNINSTANTIATED;
-
- /**
- * 16.32 Identifier Reference: It is a compile-time error if any of the
- * identifiers async, await, or yield is used as an identifier in a function
- * body marked with either async, async*, or sync*.
- */
- static const ParserErrorCode ASYNC_KEYWORD_USED_AS_IDENTIFIER =
- ParserErrorCode(
- 'ASYNC_KEYWORD_USED_AS_IDENTIFIER',
- "The keywords 'await' and 'yield' can't be used as "
- "identifiers in an asynchronous or generator function.");
-
- static const ParserErrorCode BINARY_OPERATOR_WRITTEN_OUT =
- _BINARY_OPERATOR_WRITTEN_OUT;
-
- static const ParserErrorCode BREAK_OUTSIDE_OF_LOOP = _BREAK_OUTSIDE_OF_LOOP;
-
- static const ParserErrorCode CATCH_SYNTAX = _CATCH_SYNTAX;
-
- static const ParserErrorCode CATCH_SYNTAX_EXTRA_PARAMETERS =
- _CATCH_SYNTAX_EXTRA_PARAMETERS;
-
- static const ParserErrorCode CLASS_IN_CLASS = _CLASS_IN_CLASS;
-
- static const ParserErrorCode COLON_IN_PLACE_OF_IN = _COLON_IN_PLACE_OF_IN;
-
- static const ParserErrorCode CONFLICTING_MODIFIERS = _CONFLICTING_MODIFIERS;
-
- static const ParserErrorCode CONST_AND_FINAL = _CONST_AND_FINAL;
-
- static const ParserErrorCode CONST_CLASS = _CONST_CLASS;
-
- static const ParserErrorCode CONST_CONSTRUCTOR_WITH_BODY = ParserErrorCode(
- 'CONST_CONSTRUCTOR_WITH_BODY', "Const constructors can't have a body.",
- correction: "Try removing either the 'const' keyword or the body.");
-
- static const ParserErrorCode CONST_ENUM = ParserErrorCode(
- 'CONST_ENUM', "Enums can't be declared to be 'const'.",
- correction: "Try removing the 'const' keyword.");
-
- static const ParserErrorCode CONST_FACTORY = _CONST_FACTORY;
-
- static const ParserErrorCode CONST_METHOD = _CONST_METHOD;
-
- static const ParserErrorCode CONST_TYPEDEF = ParserErrorCode(
- 'CONST_TYPEDEF', "Type aliases can't be declared to be 'const'.",
- correction: "Try removing the 'const' keyword.");
-
- static const ParserErrorCode CONSTRUCTOR_WITH_RETURN_TYPE =
- _CONSTRUCTOR_WITH_RETURN_TYPE;
-
- static const ParserErrorCode CONSTRUCTOR_WITH_TYPE_ARGUMENTS =
- _CONSTRUCTOR_WITH_TYPE_ARGUMENTS;
-
- static const ParserErrorCode CONTINUE_OUTSIDE_OF_LOOP =
- _CONTINUE_OUTSIDE_OF_LOOP;
-
- static const ParserErrorCode CONTINUE_WITHOUT_LABEL_IN_CASE =
- _CONTINUE_WITHOUT_LABEL_IN_CASE;
-
- static const ParserErrorCode COVARIANT_AND_STATIC = _COVARIANT_AND_STATIC;
-
- static const ParserErrorCode COVARIANT_CONSTRUCTOR = ParserErrorCode(
- 'COVARIANT_CONSTRUCTOR',
- "A constructor can't be declared to be 'covariant'.",
- correction: "Try removing the keyword 'covariant'.");
-
- static const ParserErrorCode COVARIANT_MEMBER = _COVARIANT_MEMBER;
-
- static const ParserErrorCode COVARIANT_TOP_LEVEL_DECLARATION =
- ParserErrorCode('COVARIANT_TOP_LEVEL_DECLARATION',
- "Top-level declarations can't be declared to be covariant.",
- correction: "Try removing the keyword 'covariant'.");
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a function type associated with
- // a parameter includes optional parameters that have a default value. This
- // isn't allowed because the default values of parameters aren't part of the
- // function's type, and therefore including them doesn't provide any value.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the parameter `p` has a
- // default value even though it's part of the type of the parameter `g`:
- //
- // ```dart
- // void f(void Function([int p [!=!] 0]) g) {
- // }
- // ```
- //
- // #### Common fixes
- //
- // Remove the default value from the function-type's parameter:
- //
- // ```dart
- // void f(void Function([int p]) g) {
- // }
- // ```
- static const ParserErrorCode DEFAULT_VALUE_IN_FUNCTION_TYPE = ParserErrorCode(
- 'DEFAULT_VALUE_IN_FUNCTION_TYPE',
- "Parameters in a function type can't have default values.",
- correction: "Try removing the default value.",
- hasPublishedDocs: true);
-
- static const ParserErrorCode DEFERRED_AFTER_PREFIX = _DEFERRED_AFTER_PREFIX;
-
- static const ParserErrorCode DIRECTIVE_AFTER_DECLARATION =
- _DIRECTIVE_AFTER_DECLARATION;
-
- static const ParserErrorCode DUPLICATE_DEFERRED = _DUPLICATE_DEFERRED;
-
- /**
- * Parameters:
- * 0: the label that was duplicated
- */
- static const ParserErrorCode DUPLICATE_LABEL_IN_SWITCH_STATEMENT =
- _DUPLICATE_LABEL_IN_SWITCH_STATEMENT;
-
- static const ParserErrorCode DUPLICATE_PREFIX = _DUPLICATE_PREFIX;
-
- /**
- * Parameters:
- * 0: the modifier that was duplicated
- */
- static const ParserErrorCode DUPLICATED_MODIFIER = _DUPLICATED_MODIFIER;
-
- static const ParserErrorCode EMPTY_ENUM_BODY = ParserErrorCode(
- 'EMPTY_ENUM_BODY', "An enum must declare at least one constant name.",
- correction: "Try declaring a constant.");
-
- static const ParserErrorCode ENUM_IN_CLASS = _ENUM_IN_CLASS;
-
- static const ParserErrorCode EQUALITY_CANNOT_BE_EQUALITY_OPERAND =
- _EQUALITY_CANNOT_BE_EQUALITY_OPERAND;
-
- static const ParserErrorCode EXPECTED_BODY = _EXPECTED_BODY;
-
- static const ParserErrorCode EXPECTED_CASE_OR_DEFAULT = ParserErrorCode(
- 'EXPECTED_CASE_OR_DEFAULT', "Expected 'case' or 'default'.",
- correction: "Try placing this code inside a case clause.");
-
- static const ParserErrorCode EXPECTED_CLASS_MEMBER = ParserErrorCode(
- 'EXPECTED_CLASS_MEMBER', "Expected a class member.",
- correction: "Try placing this code inside a class member.");
-
- static const ParserErrorCode EXPECTED_ELSE_OR_COMMA = _EXPECTED_ELSE_OR_COMMA;
-
- static const ParserErrorCode EXPECTED_EXECUTABLE = ParserErrorCode(
- 'EXPECTED_EXECUTABLE',
- "Expected a method, getter, setter or operator declaration.",
- correction:
- "This appears to be incomplete code. Try removing it or completing it.");
-
- static const ParserErrorCode EXPECTED_IDENTIFIER_BUT_GOT_KEYWORD =
- _EXPECTED_IDENTIFIER_BUT_GOT_KEYWORD;
-
- static const ParserErrorCode EXPECTED_INSTEAD = _EXPECTED_INSTEAD;
-
- static const ParserErrorCode EXPECTED_LIST_OR_MAP_LITERAL = ParserErrorCode(
- 'EXPECTED_LIST_OR_MAP_LITERAL', "Expected a list or map literal.",
- correction:
- "Try inserting a list or map literal, or remove the type arguments.");
-
- static const ParserErrorCode EXPECTED_STRING_LITERAL =
- ParserErrorCode('EXPECTED_STRING_LITERAL', "Expected a string literal.");
-
- /**
- * Parameters:
- * 0: the token that was expected but not found
- */
- static const ParserErrorCode EXPECTED_TOKEN =
- ParserErrorCode('EXPECTED_TOKEN', "Expected to find '{0}'.");
-
- static const ParserErrorCode EXPECTED_TYPE_NAME =
- ParserErrorCode('EXPECTED_TYPE_NAME', "Expected a type name.");
-
- static const ParserErrorCode EXPERIMENT_NOT_ENABLED = _EXPERIMENT_NOT_ENABLED;
-
- static const ParserErrorCode EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE =
- _EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE;
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an abstract declaration is
- // declared in an extension. Extensions can declare only concrete members.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because the method `a` doesn't
- // have a body:
- //
- // ```dart
- // extension E on String {
- // int [!a!]();
- // }
- // ```
- //
- // #### Common fixes
- //
- // Either provide an implementation for the member or remove it.
- static const ParserErrorCode EXTENSION_DECLARES_ABSTRACT_MEMBER =
- _EXTENSION_DECLARES_ABSTRACT_MEMBER;
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a constructor declaration is
- // found in an extension. It isn't valid to define a constructor because
- // extensions aren't classes, and it isn't possible to create an instance of
- // an extension.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because there is a constructor
- // declaration in `E`:
- //
- // ```dart
- // extension E on String {
- // [!E!]() : super();
- // }
- // ```
- //
- // #### Common fixes
- //
- // Remove the constructor or replace it with a static method.
- static const ParserErrorCode EXTENSION_DECLARES_CONSTRUCTOR =
- _EXTENSION_DECLARES_CONSTRUCTOR;
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an instance field declaration is
- // found in an extension. It isn't valid to define an instance field because
- // extensions can only add behavior, not state.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `s` is an instance
- // field:
- //
- // ```dart
- // %language=2.9
- // extension E on String {
- // String [!s!];
- // }
- // ```
- //
- // #### Common fixes
- //
- // Remove the field, make it a static field, or convert it to be a getter,
- // setter, or method.
- static const ParserErrorCode EXTENSION_DECLARES_INSTANCE_FIELD =
- _EXTENSION_DECLARES_INSTANCE_FIELD;
-
- static const ParserErrorCode EXTERNAL_CLASS = _EXTERNAL_CLASS;
-
- static const ParserErrorCode EXTERNAL_CONSTRUCTOR_WITH_BODY =
- _EXTERNAL_CONSTRUCTOR_WITH_BODY;
-
- static const ParserErrorCode EXTERNAL_CONSTRUCTOR_WITH_INITIALIZER =
- _EXTERNAL_CONSTRUCTOR_WITH_INITIALIZER;
-
- static const ParserErrorCode EXTERNAL_ENUM = _EXTERNAL_ENUM;
-
- static const ParserErrorCode EXTERNAL_FACTORY_REDIRECTION =
- _EXTERNAL_FACTORY_REDIRECTION;
-
- static const ParserErrorCode EXTERNAL_FACTORY_WITH_BODY =
- _EXTERNAL_FACTORY_WITH_BODY;
-
- static const ParserErrorCode EXTERNAL_FIELD = _EXTERNAL_FIELD;
-
- static const ParserErrorCode EXTERNAL_GETTER_WITH_BODY = ParserErrorCode(
- 'EXTERNAL_GETTER_WITH_BODY', "External getters can't have a body.",
- correction: "Try removing the body of the getter, or "
- "removing the keyword 'external'.");
-
- static const ParserErrorCode EXTERNAL_LATE_FIELD = _EXTERNAL_LATE_FIELD;
-
- static const ParserErrorCode EXTERNAL_METHOD_WITH_BODY =
- _EXTERNAL_METHOD_WITH_BODY;
-
- static const ParserErrorCode EXTERNAL_OPERATOR_WITH_BODY = ParserErrorCode(
- 'EXTERNAL_OPERATOR_WITH_BODY', "External operators can't have a body.",
- correction: "Try removing the body of the operator, or "
- "removing the keyword 'external'.");
-
- static const ParserErrorCode EXTERNAL_SETTER_WITH_BODY = ParserErrorCode(
- 'EXTERNAL_SETTER_WITH_BODY', "External setters can't have a body.",
- correction: "Try removing the body of the setter, or "
- "removing the keyword 'external'.");
-
- static const ParserErrorCode EXTERNAL_TYPEDEF = _EXTERNAL_TYPEDEF;
-
- static const ParserErrorCode EXTRANEOUS_MODIFIER = _EXTRANEOUS_MODIFIER;
-
- static const ParserErrorCode FACTORY_TOP_LEVEL_DECLARATION =
- _FACTORY_TOP_LEVEL_DECLARATION;
-
- static const ParserErrorCode FACTORY_WITH_INITIALIZERS = ParserErrorCode(
- 'FACTORY_WITH_INITIALIZERS',
- "A 'factory' constructor can't have initializers.",
- correction:
- "Try removing the 'factory' keyword to make this a generative constructor, or "
- "removing the initializers.");
-
- static const ParserErrorCode FACTORY_WITHOUT_BODY = ParserErrorCode(
- 'FACTORY_WITHOUT_BODY',
- "A non-redirecting 'factory' constructor must have a body.",
- correction: "Try adding a body to the constructor.");
-
- static const ParserErrorCode FIELD_INITIALIZED_OUTSIDE_DECLARING_CLASS =
- _FIELD_INITIALIZED_OUTSIDE_DECLARING_CLASS;
-
- static const ParserErrorCode FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR =
- _FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR;
-
- static const ParserErrorCode FINAL_AND_COVARIANT = _FINAL_AND_COVARIANT;
-
- static const ParserErrorCode FINAL_AND_COVARIANT_LATE_WITH_INITIALIZER =
- _FINAL_AND_COVARIANT_LATE_WITH_INITIALIZER;
-
- static const ParserErrorCode FINAL_AND_VAR = _FINAL_AND_VAR;
-
- static const ParserErrorCode FINAL_CLASS = ParserErrorCode(
- 'FINAL_CLASS', "Classes can't be declared to be 'final'.",
- correction: "Try removing the keyword 'final'.");
-
- static const ParserErrorCode FINAL_CONSTRUCTOR = ParserErrorCode(
- 'FINAL_CONSTRUCTOR', "A constructor can't be declared to be 'final'.",
- correction: "Try removing the keyword 'final'.");
-
- static const ParserErrorCode FINAL_ENUM = ParserErrorCode(
- 'FINAL_ENUM', "Enums can't be declared to be 'final'.",
- correction: "Try removing the keyword 'final'.");
-
- static const ParserErrorCode FINAL_METHOD = ParserErrorCode('FINAL_METHOD',
- "Getters, setters and methods can't be declared to be 'final'.",
- correction: "Try removing the keyword 'final'.");
-
- static const ParserErrorCode FINAL_TYPEDEF = ParserErrorCode(
- 'FINAL_TYPEDEF', "Typedefs can't be declared to be 'final'.",
- correction: "Try removing the keyword 'final'.");
-
- static const ParserErrorCode FUNCTION_TYPED_PARAMETER_VAR = ParserErrorCode(
- 'FUNCTION_TYPED_PARAMETER_VAR',
- "Function-typed parameters can't specify 'const', 'final' or 'var' in place of a return type.",
- correction: "Try replacing the keyword with a return type.");
-
- static const ParserErrorCode GETTER_CONSTRUCTOR = _GETTER_CONSTRUCTOR;
-
- static const ParserErrorCode GETTER_IN_FUNCTION = ParserErrorCode(
- 'GETTER_IN_FUNCTION',
- "Getters can't be defined within methods or functions.",
- correction: "Try moving the getter outside the method or function, or "
- "converting the getter to a function.");
-
- static const ParserErrorCode GETTER_WITH_PARAMETERS = ParserErrorCode(
- 'GETTER_WITH_PARAMETERS',
- "Getters must be declared without a parameter list.",
- correction: "Try removing the parameter list, or "
- "removing the keyword 'get' to define a method rather than a getter.");
-
- static const ParserErrorCode ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE =
- _ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE;
-
- static const ParserErrorCode IMPLEMENTS_BEFORE_EXTENDS =
- _IMPLEMENTS_BEFORE_EXTENDS;
-
- static const ParserErrorCode IMPLEMENTS_BEFORE_ON = _IMPLEMENTS_BEFORE_ON;
-
- static const ParserErrorCode IMPLEMENTS_BEFORE_WITH = _IMPLEMENTS_BEFORE_WITH;
-
- static const ParserErrorCode IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE =
- _IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE;
-
- static const ParserErrorCode INITIALIZED_VARIABLE_IN_FOR_EACH =
- _INITIALIZED_VARIABLE_IN_FOR_EACH;
-
- static const ParserErrorCode INVALID_AWAIT_IN_FOR = _INVALID_AWAIT_IN_FOR;
-
- /**
- * Parameters:
- * 0: the invalid escape sequence
- */
- static const ParserErrorCode INVALID_CODE_POINT = ParserErrorCode(
- 'INVALID_CODE_POINT',
- "The escape sequence '{0}' isn't a valid code point.");
-
- static const ParserErrorCode INVALID_COMMENT_REFERENCE = ParserErrorCode(
- 'INVALID_COMMENT_REFERENCE',
- "Comment references should contain a possibly prefixed identifier and "
- "can start with 'new', but shouldn't contain anything else.");
-
- static const ParserErrorCode INVALID_CONSTRUCTOR_NAME =
- _INVALID_CONSTRUCTOR_NAME;
-
- static const ParserErrorCode INVALID_GENERIC_FUNCTION_TYPE = ParserErrorCode(
- 'INVALID_GENERIC_FUNCTION_TYPE', "Invalid generic function type.",
- correction:
- "Try using a generic function type (returnType 'Function(' parameters ')').");
-
- static const ParserErrorCode INVALID_HEX_ESCAPE = _INVALID_HEX_ESCAPE;
-
- static const ParserErrorCode INVALID_INITIALIZER = _INVALID_INITIALIZER;
-
- static const ParserErrorCode INVALID_LITERAL_IN_CONFIGURATION =
- ParserErrorCode('INVALID_LITERAL_IN_CONFIGURATION',
- "The literal in a configuration can't contain interpolation.",
- correction: "Try removing the interpolation expressions.");
-
- /**
- * Parameters:
- * 0: the operator that is invalid
- */
- static const ParserErrorCode INVALID_OPERATOR = _INVALID_OPERATOR;
-
- /**
- * Parameters:
- * 0: the operator being applied to 'super'
- *
- * Only generated by the old parser.
- * Replaced by INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER.
- */
- static const ParserErrorCode INVALID_OPERATOR_FOR_SUPER = ParserErrorCode(
- 'INVALID_OPERATOR_FOR_SUPER',
- "The operator '{0}' can't be used with 'super'.");
-
- static const ParserErrorCode INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER =
- _INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER;
-
- static const ParserErrorCode INVALID_STAR_AFTER_ASYNC = ParserErrorCode(
- 'INVALID_STAR_AFTER_ASYNC',
- "The modifier 'async*' isn't allowed for an expression function body.",
- correction: "Try converting the body to a block.");
-
- static const ParserErrorCode INVALID_SUPER_IN_INITIALIZER =
- _INVALID_SUPER_IN_INITIALIZER;
-
- static const ParserErrorCode INVALID_SYNC = ParserErrorCode('INVALID_SYNC',
- "The modifier 'sync' isn't allowed for an expression function body.",
- correction: "Try converting the body to a block.");
-
- static const ParserErrorCode INVALID_THIS_IN_INITIALIZER =
- _INVALID_THIS_IN_INITIALIZER;
-
- static const ParserErrorCode INVALID_UNICODE_ESCAPE = _INVALID_UNICODE_ESCAPE;
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a member declared inside an
- // extension uses the keyword `covariant` in the declaration of a parameter.
- // Extensions aren't classes and don't have subclasses, so the keyword serves
- // no purpose.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `i` is marked as being
- // covariant:
- //
- // ```dart
- // extension E on String {
- // void a([!covariant!] int i) {}
- // }
- // ```
- //
- // #### Common fixes
- //
- // Remove the `covariant` keyword:
- //
- // ```dart
- // extension E on String {
- // void a(int i) {}
- // }
- // ```
- static const ParserErrorCode INVALID_USE_OF_COVARIANT_IN_EXTENSION =
- _INVALID_USE_OF_COVARIANT_IN_EXTENSION;
-
- static const ParserErrorCode LIBRARY_DIRECTIVE_NOT_FIRST =
- _LIBRARY_DIRECTIVE_NOT_FIRST;
-
- static const ParserErrorCode LITERAL_WITH_CLASS_AND_NEW =
- _LITERAL_WITH_CLASS_AND_NEW;
-
- static const ParserErrorCode LITERAL_WITH_CLASS = _LITERAL_WITH_CLASS;
-
- static const ParserErrorCode LITERAL_WITH_NEW = _LITERAL_WITH_NEW;
-
- static const ParserErrorCode LOCAL_FUNCTION_DECLARATION_MODIFIER =
- ParserErrorCode('LOCAL_FUNCTION_DECLARATION_MODIFIER',
- "Local function declarations can't specify any modifiers.",
- correction: "Try removing the modifier.");
-
- static const ParserErrorCode MEMBER_WITH_CLASS_NAME = _MEMBER_WITH_CLASS_NAME;
-
- static const ParserErrorCode MISSING_ASSIGNABLE_SELECTOR =
- _MISSING_ASSIGNABLE_SELECTOR;
-
- static const ParserErrorCode MISSING_ASSIGNMENT_IN_INITIALIZER =
- _MISSING_ASSIGNMENT_IN_INITIALIZER;
-
- static const ParserErrorCode MISSING_CATCH_OR_FINALLY =
- _MISSING_CATCH_OR_FINALLY;
-
- static const ParserErrorCode MISSING_CLOSING_PARENTHESIS = ParserErrorCode(
- 'MISSING_CLOSING_PARENTHESIS', "The closing parenthesis is missing.",
- correction: "Try adding the closing parenthesis.");
-
- static const ParserErrorCode MISSING_CONST_FINAL_VAR_OR_TYPE =
- _MISSING_CONST_FINAL_VAR_OR_TYPE;
-
- static const ParserErrorCode MISSING_ENUM_BODY = ParserErrorCode(
- 'MISSING_ENUM_BODY',
- "An enum definition must have a body with at least one constant name.",
- correction: "Try adding a body and defining at least one constant.");
-
- static const ParserErrorCode MISSING_EXPRESSION_IN_INITIALIZER =
- ParserErrorCode('MISSING_EXPRESSION_IN_INITIALIZER',
- "Expected an expression after the assignment operator.",
- correction: "Try adding the value to be assigned, or "
- "remove the assignment operator.");
-
- static const ParserErrorCode MISSING_EXPRESSION_IN_THROW =
- _MISSING_EXPRESSION_IN_THROW;
-
- static const ParserErrorCode MISSING_FUNCTION_BODY = ParserErrorCode(
- 'MISSING_FUNCTION_BODY', "A function body must be provided.",
- correction: "Try adding a function body.");
-
- static const ParserErrorCode MISSING_FUNCTION_KEYWORD = ParserErrorCode(
- 'MISSING_FUNCTION_KEYWORD',
- "Function types must have the keyword 'Function' before the parameter list.",
- correction: "Try adding the keyword 'Function'.");
-
- static const ParserErrorCode MISSING_FUNCTION_PARAMETERS = ParserErrorCode(
- 'MISSING_FUNCTION_PARAMETERS',
- "Functions must have an explicit list of parameters.",
- correction: "Try adding a parameter list.");
-
- static const ParserErrorCode MISSING_GET = ParserErrorCode('MISSING_GET',
- "Getters must have the keyword 'get' before the getter name.",
- correction: "Try adding the keyword 'get'.");
-
- static const ParserErrorCode MISSING_IDENTIFIER =
- ParserErrorCode('MISSING_IDENTIFIER', "Expected an identifier.");
-
- static const ParserErrorCode MISSING_INITIALIZER = _MISSING_INITIALIZER;
-
- static const ParserErrorCode MISSING_KEYWORD_OPERATOR =
- _MISSING_KEYWORD_OPERATOR;
-
- static const ParserErrorCode MISSING_METHOD_PARAMETERS = ParserErrorCode(
- 'MISSING_METHOD_PARAMETERS',
- "Methods must have an explicit list of parameters.",
- correction: "Try adding a parameter list.");
-
- static const ParserErrorCode MISSING_NAME_FOR_NAMED_PARAMETER = ParserErrorCode(
- 'MISSING_NAME_FOR_NAMED_PARAMETER',
- "Named parameters in a function type must have a name",
- correction:
- "Try providing a name for the parameter or removing the curly braces.");
-
- static const ParserErrorCode MISSING_NAME_IN_LIBRARY_DIRECTIVE = ParserErrorCode(
- 'MISSING_NAME_IN_LIBRARY_DIRECTIVE',
- "Library directives must include a library name.",
- correction: "Try adding a library name after the keyword 'library', or "
- "remove the library directive if the library doesn't have any parts.");
-
- static const ParserErrorCode MISSING_NAME_IN_PART_OF_DIRECTIVE =
- ParserErrorCode('MISSING_NAME_IN_PART_OF_DIRECTIVE',
- "Part-of directives must include a library name.",
- correction: "Try adding a library name after the 'of'.");
-
- static const ParserErrorCode MISSING_PREFIX_IN_DEFERRED_IMPORT =
- _MISSING_PREFIX_IN_DEFERRED_IMPORT;
-
- static const ParserErrorCode MISSING_STAR_AFTER_SYNC = ParserErrorCode(
- 'MISSING_STAR_AFTER_SYNC',
- "The modifier 'sync' must be followed by a star ('*').",
- correction: "Try removing the modifier, or add a star.");
-
- static const ParserErrorCode MISSING_STATEMENT = _MISSING_STATEMENT;
-
- /**
- * Parameters:
- * 0: the terminator that is missing
- */
- static const ParserErrorCode MISSING_TERMINATOR_FOR_PARAMETER_GROUP =
- ParserErrorCode('MISSING_TERMINATOR_FOR_PARAMETER_GROUP',
- "There is no '{0}' to close the parameter group.",
- correction: "Try inserting a '{0}' at the end of the group.");
-
- static const ParserErrorCode MISSING_TYPEDEF_PARAMETERS = ParserErrorCode(
- 'MISSING_TYPEDEF_PARAMETERS',
- "Typedefs must have an explicit list of parameters.",
- correction: "Try adding a parameter list.");
-
- static const ParserErrorCode MISSING_VARIABLE_IN_FOR_EACH = ParserErrorCode(
- 'MISSING_VARIABLE_IN_FOR_EACH',
- "A loop variable must be declared in a for-each loop before the 'in', but none was found.",
- correction: "Try declaring a loop variable.");
-
- static const ParserErrorCode MIXED_PARAMETER_GROUPS = ParserErrorCode(
- 'MIXED_PARAMETER_GROUPS',
- "Can't have both positional and named parameters in a single parameter list.",
- correction: "Try choosing a single style of optional parameters.");
-
- static const ParserErrorCode MIXIN_DECLARES_CONSTRUCTOR =
- _MIXIN_DECLARES_CONSTRUCTOR;
-
- static const ParserErrorCode MODIFIER_OUT_OF_ORDER = _MODIFIER_OUT_OF_ORDER;
-
- static const ParserErrorCode MULTIPLE_EXTENDS_CLAUSES =
- _MULTIPLE_EXTENDS_CLAUSES;
-
- static const ParserErrorCode MULTIPLE_IMPLEMENTS_CLAUSES = ParserErrorCode(
- 'MULTIPLE_IMPLEMENTS_CLAUSES',
- "Each class or mixin definition can have at most one implements clause.",
- correction:
- "Try combining all of the implements clauses into a single clause.");
-
- static const ParserErrorCode MULTIPLE_LIBRARY_DIRECTIVES =
- _MULTIPLE_LIBRARY_DIRECTIVES;
-
- static const ParserErrorCode MULTIPLE_NAMED_PARAMETER_GROUPS = ParserErrorCode(
- 'MULTIPLE_NAMED_PARAMETER_GROUPS',
- "Can't have multiple groups of named parameters in a single parameter list.",
- correction: "Try combining all of the groups into a single group.");
-
- static const ParserErrorCode MULTIPLE_ON_CLAUSES = _MULTIPLE_ON_CLAUSES;
-
- static const ParserErrorCode MULTIPLE_PART_OF_DIRECTIVES =
- _MULTIPLE_PART_OF_DIRECTIVES;
-
- static const ParserErrorCode MULTIPLE_POSITIONAL_PARAMETER_GROUPS =
- ParserErrorCode('MULTIPLE_POSITIONAL_PARAMETER_GROUPS',
- "Can't have multiple groups of positional parameters in a single parameter list.",
- correction: "Try combining all of the groups into a single group.");
-
- /**
- * Parameters:
- * 0: the number of variables being declared
- */
- static const ParserErrorCode MULTIPLE_VARIABLES_IN_FOR_EACH = ParserErrorCode(
- 'MULTIPLE_VARIABLES_IN_FOR_EACH',
- "A single loop variable must be declared in a for-each loop before "
- "the 'in', but {0} were found.",
- correction:
- "Try moving all but one of the declarations inside the loop body.");
-
- static const ParserErrorCode MULTIPLE_VARIANCE_MODIFIERS =
- _MULTIPLE_VARIANCE_MODIFIERS;
-
- static const ParserErrorCode MULTIPLE_WITH_CLAUSES = _MULTIPLE_WITH_CLAUSES;
-
- static const ParserErrorCode NAMED_FUNCTION_EXPRESSION = ParserErrorCode(
- 'NAMED_FUNCTION_EXPRESSION', "Function expressions can't be named.",
- correction: "Try removing the name, or "
- "moving the function expression to a function declaration statement.");
-
- static const ParserErrorCode NAMED_FUNCTION_TYPE = ParserErrorCode(
- 'NAMED_FUNCTION_TYPE', "Function types can't be named.",
- correction: "Try replacing the name with the keyword 'Function'.");
-
- static const ParserErrorCode NAMED_PARAMETER_OUTSIDE_GROUP = ParserErrorCode(
- 'NAMED_PARAMETER_OUTSIDE_GROUP',
- "Named parameters must be enclosed in curly braces ('{' and '}').",
- correction: "Try surrounding the named parameters in curly braces.");
-
- static const ParserErrorCode NATIVE_CLAUSE_IN_NON_SDK_CODE = ParserErrorCode(
- 'NATIVE_CLAUSE_IN_NON_SDK_CODE',
- "Native clause can only be used in the SDK and code that is loaded "
- "through native extensions.",
- correction: "Try removing the native clause.");
-
- static const ParserErrorCode NATIVE_CLAUSE_SHOULD_BE_ANNOTATION =
- _NATIVE_CLAUSE_SHOULD_BE_ANNOTATION;
-
- static const ParserErrorCode NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE =
- ParserErrorCode(
- 'NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE',
- "Native functions can only be declared in the SDK and code that is "
- "loaded through native extensions.",
- correction: "Try removing the word 'native'.");
-
- static const ParserErrorCode NON_CONSTRUCTOR_FACTORY = ParserErrorCode(
- 'NON_CONSTRUCTOR_FACTORY',
- "Only a constructor can be declared to be a factory.",
- correction: "Try removing the keyword 'factory'.");
-
- static const ParserErrorCode NON_IDENTIFIER_LIBRARY_NAME = ParserErrorCode(
- 'NON_IDENTIFIER_LIBRARY_NAME',
- "The name of a library must be an identifier.",
- correction: "Try using an identifier as the name of the library.");
-
- static const ParserErrorCode NON_PART_OF_DIRECTIVE_IN_PART = ParserErrorCode(
- 'NON_PART_OF_DIRECTIVE_IN_PART',
- "The part-of directive must be the only directive in a part.",
- correction: "Try removing the other directives, or "
- "moving them to the library for which this is a part.");
-
- static const ParserErrorCode NON_STRING_LITERAL_AS_URI = ParserErrorCode(
- 'NON_STRING_LITERAL_AS_URI', "The URI must be a string literal.",
- correction: "Try enclosing the URI in either single or double quotes.");
-
- /**
- * Parameters:
- * 0: the operator that the user is trying to define
- */
- static const ParserErrorCode NON_USER_DEFINABLE_OPERATOR = ParserErrorCode(
- 'NON_USER_DEFINABLE_OPERATOR',
- "The operator '{0}' isn't user definable.");
-
- static const ParserErrorCode NORMAL_BEFORE_OPTIONAL_PARAMETERS = ParserErrorCode(
- 'NORMAL_BEFORE_OPTIONAL_PARAMETERS',
- "Normal parameters must occur before optional parameters.",
- correction:
- "Try moving all of the normal parameters before the optional parameters.");
-
- static const ErrorCode NULL_AWARE_CASCADE_OUT_OF_ORDER =
- _NULL_AWARE_CASCADE_OUT_OF_ORDER;
-
- static const ParserErrorCode POSITIONAL_AFTER_NAMED_ARGUMENT = ParserErrorCode(
- 'POSITIONAL_AFTER_NAMED_ARGUMENT',
- "Positional arguments must occur before named arguments.",
- correction:
- "Try moving all of the positional arguments before the named arguments.");
-
- static const ParserErrorCode POSITIONAL_PARAMETER_OUTSIDE_GROUP = ParserErrorCode(
- 'POSITIONAL_PARAMETER_OUTSIDE_GROUP',
- "Positional parameters must be enclosed in square brackets ('[' and ']').",
- correction:
- "Try surrounding the positional parameters in square brackets.");
-
- static const ParserErrorCode PREFIX_AFTER_COMBINATOR =
- _PREFIX_AFTER_COMBINATOR;
-
- static const ParserErrorCode REDIRECTING_CONSTRUCTOR_WITH_BODY =
- _REDIRECTING_CONSTRUCTOR_WITH_BODY;
-
- static const ParserErrorCode REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR =
- _REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR;
-
- static const ParserErrorCode SETTER_CONSTRUCTOR = _SETTER_CONSTRUCTOR;
-
- static const ParserErrorCode SETTER_IN_FUNCTION = ParserErrorCode(
- 'SETTER_IN_FUNCTION',
- "Setters can't be defined within methods or functions.",
- correction: "Try moving the setter outside the method or function.");
-
- static const ParserErrorCode STACK_OVERFLOW = _STACK_OVERFLOW;
-
- static const ParserErrorCode STATIC_CONSTRUCTOR = _STATIC_CONSTRUCTOR;
-
- static const ParserErrorCode STATIC_GETTER_WITHOUT_BODY = ParserErrorCode(
- 'STATIC_GETTER_WITHOUT_BODY', "A 'static' getter must have a body.",
- correction:
- "Try adding a body to the getter, or removing the keyword 'static'.");
-
- static const ParserErrorCode STATIC_OPERATOR = _STATIC_OPERATOR;
-
- static const ParserErrorCode STATIC_SETTER_WITHOUT_BODY = ParserErrorCode(
- 'STATIC_SETTER_WITHOUT_BODY', "A 'static' setter must have a body.",
- correction:
- "Try adding a body to the setter, or removing the keyword 'static'.");
-
- static const ParserErrorCode STATIC_TOP_LEVEL_DECLARATION = ParserErrorCode(
- 'STATIC_TOP_LEVEL_DECLARATION',
- "Top-level declarations can't be declared to be static.",
- correction: "Try removing the keyword 'static'.");
-
- static const ParserErrorCode SWITCH_HAS_CASE_AFTER_DEFAULT_CASE =
- _SWITCH_HAS_CASE_AFTER_DEFAULT_CASE;
-
- static const ParserErrorCode SWITCH_HAS_MULTIPLE_DEFAULT_CASES =
- _SWITCH_HAS_MULTIPLE_DEFAULT_CASES;
-
- static const ParserErrorCode TOP_LEVEL_OPERATOR = _TOP_LEVEL_OPERATOR;
-
- static const ParserErrorCode TYPE_ARGUMENTS_ON_TYPE_VARIABLE =
- _TYPE_ARGUMENTS_ON_TYPE_VARIABLE;
-
- static const ParserErrorCode TYPE_BEFORE_FACTORY = _TYPE_BEFORE_FACTORY;
-
- static const ParserErrorCode TYPE_PARAMETER_ON_CONSTRUCTOR =
- _TYPE_PARAMETER_ON_CONSTRUCTOR;
-
- /**
- * 7.1.1 Operators: Type parameters are not syntactically supported on an
- * operator.
- */
- static const ParserErrorCode TYPE_PARAMETER_ON_OPERATOR = ParserErrorCode(
- 'TYPE_PARAMETER_ON_OPERATOR',
- "Types parameters aren't allowed when defining an operator.",
- correction: "Try removing the type parameters.");
-
- static const ParserErrorCode TYPEDEF_IN_CLASS = _TYPEDEF_IN_CLASS;
-
- /**
- * Parameters:
- * 0: the starting character that was missing
- */
- static const ParserErrorCode UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP =
- ParserErrorCode('UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP',
- "There is no '{0}' to open a parameter group.",
- correction: "Try inserting the '{0}' at the appropriate location.");
-
- /**
- * Parameters:
- * 0: the unexpected text that was found
- */
- static const ParserErrorCode UNEXPECTED_TOKEN = ParserErrorCode(
- 'UNEXPECTED_TOKEN', "Unexpected text '{0}'.",
- correction: "Try removing the text.");
-
- static const ParserErrorCode VAR_AND_TYPE = _VAR_AND_TYPE;
-
- static const ParserErrorCode VAR_AS_TYPE_NAME = _VAR_AS_TYPE_NAME;
-
- static const ParserErrorCode VAR_CLASS = ParserErrorCode(
- 'VAR_CLASS', "Classes can't be declared to be 'var'.",
- correction: "Try removing the keyword 'var'.");
-
- static const ParserErrorCode VAR_ENUM = ParserErrorCode(
- 'VAR_ENUM', "Enums can't be declared to be 'var'.",
- correction: "Try removing the keyword 'var'.");
-
- static const ParserErrorCode VAR_RETURN_TYPE = _VAR_RETURN_TYPE;
-
- static const ParserErrorCode VAR_TYPEDEF =
- ParserErrorCode('VAR_TYPEDEF', "Typedefs can't be declared to be 'var'.",
- correction: "Try removing the keyword 'var', or "
- "replacing it with the name of the return type.");
-
- static const ParserErrorCode VOID_WITH_TYPE_ARGUMENTS =
- _VOID_WITH_TYPE_ARGUMENTS;
-
- static const ParserErrorCode WITH_BEFORE_EXTENDS = _WITH_BEFORE_EXTENDS;
-
- static const ParserErrorCode WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER =
- ParserErrorCode('WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER',
- "The default value of a positional parameter should be preceded by '='.",
- correction: "Try replacing the ':' with '='.");
-
- /**
- * Parameters:
- * 0: the terminator that was expected
- * 1: the terminator that was found
- */
- static const ParserErrorCode WRONG_TERMINATOR_FOR_PARAMETER_GROUP =
- ParserErrorCode('WRONG_TERMINATOR_FOR_PARAMETER_GROUP',
- "Expected '{0}' to close parameter group.",
- correction: "Try replacing '{0}' with '{1}'.");
-
- /**
- * Initialize a newly created error code to have the given [name]. The message
- * associated with the error will be created from the given [message]
- * template. The correction associated with the error will be created from the
- * given [correction] template.
- */
- const ParserErrorCode(
- String name,
- String message, {
- String? correction,
- bool hasPublishedDocs = false,
- String? uniqueName,
- }) : super(
- correction: correction,
- hasPublishedDocs: hasPublishedDocs,
- message: message,
- name: name,
- uniqueName: uniqueName ?? 'ParserErrorCode.$name',
- );
-
- @override
- ErrorSeverity get errorSeverity => ErrorSeverity.ERROR;
-
- @override
- ErrorType get type => ErrorType.SYNTACTIC_ERROR;
-}
+export 'package:analyzer/src/dart/error/syntactic_errors.analyzer.g.dart';
diff --git a/pkg/analyzer/lib/src/dart/error/syntactic_errors.g.dart b/pkg/analyzer/lib/src/dart/error/syntactic_errors.g.dart
index ed43512..4db09fe 100644
--- a/pkg/analyzer/lib/src/dart/error/syntactic_errors.g.dart
+++ b/pkg/analyzer/lib/src/dart/error/syntactic_errors.g.dart
@@ -4,7 +4,7 @@
// Instead modify 'pkg/front_end/messages.yaml' and run
// 'dart pkg/analyzer/tool/messages/generate.dart' to update.
-part of 'syntactic_errors.dart';
+part of 'syntactic_errors.analyzer.g.dart';
final fastaAnalyzerErrorCodes = <ErrorCode?>[
null,
@@ -129,554 +129,723 @@
];
const ParserErrorCode _ABSTRACT_CLASS_MEMBER = ParserErrorCode(
- 'ABSTRACT_CLASS_MEMBER',
- "Members of classes can't be declared to be 'abstract'.",
- correction:
- "Try removing the 'abstract' keyword. You can add the 'abstract' keyword before the class declaration.");
+ 'ABSTRACT_CLASS_MEMBER',
+ "Members of classes can't be declared to be 'abstract'.",
+ correction:
+ "Try removing the 'abstract' keyword. You can add the 'abstract' keyword before the class declaration.",
+);
const ParserErrorCode _ABSTRACT_EXTERNAL_FIELD = ParserErrorCode(
- 'ABSTRACT_EXTERNAL_FIELD',
- "Fields can't be declared both 'abstract' and 'external'.",
- correction: "Try removing the 'abstract' or 'external' keyword.");
+ 'ABSTRACT_EXTERNAL_FIELD',
+ "Fields can't be declared both 'abstract' and 'external'.",
+ correction: "Try removing the 'abstract' or 'external' keyword.",
+);
const ParserErrorCode _ABSTRACT_LATE_FIELD = ParserErrorCode(
- 'ABSTRACT_LATE_FIELD', "Abstract fields cannot be late.",
- correction: "Try removing the 'abstract' or 'late' keyword.");
+ 'ABSTRACT_LATE_FIELD',
+ "Abstract fields cannot be late.",
+ correction: "Try removing the 'abstract' or 'late' keyword.",
+);
const ParserErrorCode _ABSTRACT_STATIC_FIELD = ParserErrorCode(
- 'ABSTRACT_STATIC_FIELD', "Static fields can't be declared 'abstract'.",
- correction: "Try removing the 'abstract' or 'static' keyword.");
+ 'ABSTRACT_STATIC_FIELD',
+ "Static fields can't be declared 'abstract'.",
+ correction: "Try removing the 'abstract' or 'static' keyword.",
+);
const ParserErrorCode _ANNOTATION_ON_TYPE_ARGUMENT = ParserErrorCode(
- 'ANNOTATION_ON_TYPE_ARGUMENT',
- "Type arguments can't have annotations because they aren't declarations.");
+ 'ANNOTATION_ON_TYPE_ARGUMENT',
+ "Type arguments can't have annotations because they aren't declarations.",
+);
const ParserErrorCode _ANNOTATION_WITH_TYPE_ARGUMENTS = ParserErrorCode(
- 'ANNOTATION_WITH_TYPE_ARGUMENTS',
- "An annotation can't use type arguments.");
+ 'ANNOTATION_WITH_TYPE_ARGUMENTS',
+ "An annotation can't use type arguments.",
+);
const ParserErrorCode _ANNOTATION_WITH_TYPE_ARGUMENTS_UNINSTANTIATED =
- ParserErrorCode('ANNOTATION_WITH_TYPE_ARGUMENTS_UNINSTANTIATED',
- "An annotation with type arguments must be followed by an argument list.");
+ ParserErrorCode(
+ 'ANNOTATION_WITH_TYPE_ARGUMENTS_UNINSTANTIATED',
+ "An annotation with type arguments must be followed by an argument list.",
+);
const ParserErrorCode _BINARY_OPERATOR_WRITTEN_OUT = ParserErrorCode(
- 'BINARY_OPERATOR_WRITTEN_OUT',
- "Binary operator '{0}' is written as '{1}' instead of the written out word.",
- correction: "Try replacing '{0}' with '{1}'.");
+ 'BINARY_OPERATOR_WRITTEN_OUT',
+ "Binary operator '{0}' is written as '{1}' instead of the written out word.",
+ correction: "Try replacing '{0}' with '{1}'.",
+);
const ParserErrorCode _BREAK_OUTSIDE_OF_LOOP = ParserErrorCode(
- 'BREAK_OUTSIDE_OF_LOOP',
- "A break statement can't be used outside of a loop or switch statement.",
- correction: "Try removing the break statement.");
+ 'BREAK_OUTSIDE_OF_LOOP',
+ "A break statement can't be used outside of a loop or switch statement.",
+ correction: "Try removing the break statement.",
+);
-const ParserErrorCode _CATCH_SYNTAX = ParserErrorCode('CATCH_SYNTAX',
- "'catch' must be followed by '(identifier)' or '(identifier, identifier)'.",
- correction:
- "No types are needed, the first is given by 'on', the second is always 'StackTrace'.");
+const ParserErrorCode _CATCH_SYNTAX = ParserErrorCode(
+ 'CATCH_SYNTAX',
+ "'catch' must be followed by '(identifier)' or '(identifier, identifier)'.",
+ correction:
+ "No types are needed, the first is given by 'on', the second is always 'StackTrace'.",
+);
const ParserErrorCode _CATCH_SYNTAX_EXTRA_PARAMETERS = ParserErrorCode(
- 'CATCH_SYNTAX_EXTRA_PARAMETERS',
- "'catch' must be followed by '(identifier)' or '(identifier, identifier)'.",
- correction:
- "No types are needed, the first is given by 'on', the second is always 'StackTrace'.");
+ 'CATCH_SYNTAX_EXTRA_PARAMETERS',
+ "'catch' must be followed by '(identifier)' or '(identifier, identifier)'.",
+ correction:
+ "No types are needed, the first is given by 'on', the second is always 'StackTrace'.",
+);
const ParserErrorCode _CLASS_IN_CLASS = ParserErrorCode(
- 'CLASS_IN_CLASS', "Classes can't be declared inside other classes.",
- correction: "Try moving the class to the top-level.");
+ 'CLASS_IN_CLASS',
+ "Classes can't be declared inside other classes.",
+ correction: "Try moving the class to the top-level.",
+);
const ParserErrorCode _COLON_IN_PLACE_OF_IN = ParserErrorCode(
- 'COLON_IN_PLACE_OF_IN', "For-in loops use 'in' rather than a colon.",
- correction: "Try replacing the colon with the keyword 'in'.");
+ 'COLON_IN_PLACE_OF_IN',
+ "For-in loops use 'in' rather than a colon.",
+ correction: "Try replacing the colon with the keyword 'in'.",
+);
const ParserErrorCode _CONFLICTING_MODIFIERS = ParserErrorCode(
- 'CONFLICTING_MODIFIERS',
- "Members can't be declared to be both '{0}' and '{1}'.",
- correction: "Try removing one of the keywords.");
+ 'CONFLICTING_MODIFIERS',
+ "Members can't be declared to be both '{0}' and '{1}'.",
+ correction: "Try removing one of the keywords.",
+);
const ParserErrorCode _CONSTRUCTOR_WITH_RETURN_TYPE = ParserErrorCode(
- 'CONSTRUCTOR_WITH_RETURN_TYPE', "Constructors can't have a return type.",
- correction: "Try removing the return type.");
+ 'CONSTRUCTOR_WITH_RETURN_TYPE',
+ "Constructors can't have a return type.",
+ correction: "Try removing the return type.",
+);
const ParserErrorCode _CONSTRUCTOR_WITH_TYPE_ARGUMENTS = ParserErrorCode(
- 'CONSTRUCTOR_WITH_TYPE_ARGUMENTS',
- "A constructor invocation can't have type arguments after the constructor name.",
- correction:
- "Try removing the type arguments or placing them after the class name.");
+ 'CONSTRUCTOR_WITH_TYPE_ARGUMENTS',
+ "A constructor invocation can't have type arguments after the constructor name.",
+ correction:
+ "Try removing the type arguments or placing them after the class name.",
+);
-const ParserErrorCode _CONST_AND_FINAL = ParserErrorCode('CONST_AND_FINAL',
- "Members can't be declared to be both 'const' and 'final'.",
- correction: "Try removing either the 'const' or 'final' keyword.");
+const ParserErrorCode _CONST_AND_FINAL = ParserErrorCode(
+ 'CONST_AND_FINAL',
+ "Members can't be declared to be both 'const' and 'final'.",
+ correction: "Try removing either the 'const' or 'final' keyword.",
+);
const ParserErrorCode _CONST_CLASS = ParserErrorCode(
- 'CONST_CLASS', "Classes can't be declared to be 'const'.",
- correction:
- "Try removing the 'const' keyword. If you're trying to indicate that instances of the class can be constants, place the 'const' keyword on the class' constructor(s).");
+ 'CONST_CLASS',
+ "Classes can't be declared to be 'const'.",
+ correction:
+ "Try removing the 'const' keyword. If you're trying to indicate that instances of the class can be constants, place the 'const' keyword on the class' constructor(s).",
+);
-const ParserErrorCode _CONST_FACTORY = ParserErrorCode('CONST_FACTORY',
- "Only redirecting factory constructors can be declared to be 'const'.",
- correction:
- "Try removing the 'const' keyword, or replacing the body with '=' followed by a valid target.");
+const ParserErrorCode _CONST_FACTORY = ParserErrorCode(
+ 'CONST_FACTORY',
+ "Only redirecting factory constructors can be declared to be 'const'.",
+ correction:
+ "Try removing the 'const' keyword, or replacing the body with '=' followed by a valid target.",
+);
-const ParserErrorCode _CONST_METHOD = ParserErrorCode('CONST_METHOD',
- "Getters, setters and methods can't be declared to be 'const'.",
- correction: "Try removing the 'const' keyword.");
+const ParserErrorCode _CONST_METHOD = ParserErrorCode(
+ 'CONST_METHOD',
+ "Getters, setters and methods can't be declared to be 'const'.",
+ correction: "Try removing the 'const' keyword.",
+);
const ParserErrorCode _CONTINUE_OUTSIDE_OF_LOOP = ParserErrorCode(
- 'CONTINUE_OUTSIDE_OF_LOOP',
- "A continue statement can't be used outside of a loop or switch statement.",
- correction: "Try removing the continue statement.");
+ 'CONTINUE_OUTSIDE_OF_LOOP',
+ "A continue statement can't be used outside of a loop or switch statement.",
+ correction: "Try removing the continue statement.",
+);
const ParserErrorCode _CONTINUE_WITHOUT_LABEL_IN_CASE = ParserErrorCode(
- 'CONTINUE_WITHOUT_LABEL_IN_CASE',
- "A continue statement in a switch statement must have a label as a target.",
- correction:
- "Try adding a label associated with one of the case clauses to the continue statement.");
+ 'CONTINUE_WITHOUT_LABEL_IN_CASE',
+ "A continue statement in a switch statement must have a label as a target.",
+ correction:
+ "Try adding a label associated with one of the case clauses to the continue statement.",
+);
const ParserErrorCode _COVARIANT_AND_STATIC = ParserErrorCode(
- 'COVARIANT_AND_STATIC',
- "Members can't be declared to be both 'covariant' and 'static'.",
- correction: "Try removing either the 'covariant' or 'static' keyword.");
+ 'COVARIANT_AND_STATIC',
+ "Members can't be declared to be both 'covariant' and 'static'.",
+ correction: "Try removing either the 'covariant' or 'static' keyword.",
+);
-const ParserErrorCode _COVARIANT_MEMBER = ParserErrorCode('COVARIANT_MEMBER',
- "Getters, setters and methods can't be declared to be 'covariant'.",
- correction: "Try removing the 'covariant' keyword.");
+const ParserErrorCode _COVARIANT_MEMBER = ParserErrorCode(
+ 'COVARIANT_MEMBER',
+ "Getters, setters and methods can't be declared to be 'covariant'.",
+ correction: "Try removing the 'covariant' keyword.",
+);
const ParserErrorCode _DEFERRED_AFTER_PREFIX = ParserErrorCode(
- 'DEFERRED_AFTER_PREFIX',
- "The deferred keyword should come immediately before the prefix ('as' clause).",
- correction: "Try moving the deferred keyword before the prefix.");
+ 'DEFERRED_AFTER_PREFIX',
+ "The deferred keyword should come immediately before the prefix ('as' clause).",
+ correction: "Try moving the deferred keyword before the prefix.",
+);
const ParserErrorCode _DIRECTIVE_AFTER_DECLARATION = ParserErrorCode(
- 'DIRECTIVE_AFTER_DECLARATION',
- "Directives must appear before any declarations.",
- correction: "Try moving the directive before any declarations.");
+ 'DIRECTIVE_AFTER_DECLARATION',
+ "Directives must appear before any declarations.",
+ correction: "Try moving the directive before any declarations.",
+);
const ParserErrorCode _DUPLICATED_MODIFIER = ParserErrorCode(
- 'DUPLICATED_MODIFIER', "The modifier '{0}' was already specified.",
- correction: "Try removing all but one occurrence of the modifier.");
+ 'DUPLICATED_MODIFIER',
+ "The modifier '{0}' was already specified.",
+ correction: "Try removing all but one occurrence of the modifier.",
+);
const ParserErrorCode _DUPLICATE_DEFERRED = ParserErrorCode(
- 'DUPLICATE_DEFERRED',
- "An import directive can only have one 'deferred' keyword.",
- correction: "Try removing all but one 'deferred' keyword.");
+ 'DUPLICATE_DEFERRED',
+ "An import directive can only have one 'deferred' keyword.",
+ correction: "Try removing all but one 'deferred' keyword.",
+);
const ParserErrorCode _DUPLICATE_LABEL_IN_SWITCH_STATEMENT = ParserErrorCode(
- 'DUPLICATE_LABEL_IN_SWITCH_STATEMENT',
- "The label '{0}' was already used in this switch statement.",
- correction: "Try choosing a different name for this label.");
+ 'DUPLICATE_LABEL_IN_SWITCH_STATEMENT',
+ "The label '{0}' was already used in this switch statement.",
+ correction: "Try choosing a different name for this label.",
+);
-const ParserErrorCode _DUPLICATE_PREFIX = ParserErrorCode('DUPLICATE_PREFIX',
- "An import directive can only have one prefix ('as' clause).",
- correction: "Try removing all but one prefix.");
+const ParserErrorCode _DUPLICATE_PREFIX = ParserErrorCode(
+ 'DUPLICATE_PREFIX',
+ "An import directive can only have one prefix ('as' clause).",
+ correction: "Try removing all but one prefix.",
+);
const ParserErrorCode _ENUM_IN_CLASS = ParserErrorCode(
- 'ENUM_IN_CLASS', "Enums can't be declared inside classes.",
- correction: "Try moving the enum to the top-level.");
+ 'ENUM_IN_CLASS',
+ "Enums can't be declared inside classes.",
+ correction: "Try moving the enum to the top-level.",
+);
const ParserErrorCode _EQUALITY_CANNOT_BE_EQUALITY_OPERAND = ParserErrorCode(
- 'EQUALITY_CANNOT_BE_EQUALITY_OPERAND',
- "A comparison expression can't be an operand of another comparison expression.",
- correction: "Try putting parentheses around one of the comparisons.");
+ 'EQUALITY_CANNOT_BE_EQUALITY_OPERAND',
+ "A comparison expression can't be an operand of another comparison expression.",
+ correction: "Try putting parentheses around one of the comparisons.",
+);
const ParserErrorCode _EXPECTED_BODY = ParserErrorCode(
- 'EXPECTED_BODY', "A {0} must have a body, even if it is empty.",
- correction: "Try adding an empty body.");
+ 'EXPECTED_BODY',
+ "A {0} must have a body, even if it is empty.",
+ correction: "Try adding an empty body.",
+);
-const ParserErrorCode _EXPECTED_ELSE_OR_COMMA =
- ParserErrorCode('EXPECTED_ELSE_OR_COMMA', "Expected 'else' or comma.");
+const ParserErrorCode _EXPECTED_ELSE_OR_COMMA = ParserErrorCode(
+ 'EXPECTED_ELSE_OR_COMMA',
+ "Expected 'else' or comma.",
+);
const ParserErrorCode _EXPECTED_IDENTIFIER_BUT_GOT_KEYWORD = ParserErrorCode(
- 'EXPECTED_IDENTIFIER_BUT_GOT_KEYWORD',
- "'{0}' can't be used as an identifier because it's a keyword.",
- correction: "Try renaming this to be an identifier that isn't a keyword.");
+ 'EXPECTED_IDENTIFIER_BUT_GOT_KEYWORD',
+ "'{0}' can't be used as an identifier because it's a keyword.",
+ correction: "Try renaming this to be an identifier that isn't a keyword.",
+);
-const ParserErrorCode _EXPECTED_INSTEAD =
- ParserErrorCode('EXPECTED_INSTEAD', "Expected '{0}' instead of this.");
+const ParserErrorCode _EXPECTED_INSTEAD = ParserErrorCode(
+ 'EXPECTED_INSTEAD',
+ "Expected '{0}' instead of this.",
+);
const ParserErrorCode _EXPERIMENT_NOT_ENABLED = ParserErrorCode(
- 'EXPERIMENT_NOT_ENABLED',
- "This requires the '{0}' language feature to be enabled.",
- correction:
- "Try updating your pubspec.yaml to set the minimum SDK constraint to {1} or higher, and running 'pub get'.");
+ 'EXPERIMENT_NOT_ENABLED',
+ "This requires the '{0}' language feature to be enabled.",
+ correction:
+ "Try updating your pubspec.yaml to set the minimum SDK constraint to {1} or higher, and running 'pub get'.",
+);
const ParserErrorCode _EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE = ParserErrorCode(
- 'EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE',
- "Export directives must precede part directives.",
- correction: "Try moving the export directives before the part directives.");
+ 'EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE',
+ "Export directives must precede part directives.",
+ correction: "Try moving the export directives before the part directives.",
+);
const ParserErrorCode _EXTENSION_DECLARES_ABSTRACT_MEMBER = ParserErrorCode(
- 'EXTENSION_DECLARES_ABSTRACT_MEMBER',
- "Extensions can't declare abstract members.",
- correction: "Try providing an implementation for the member.",
- hasPublishedDocs: true);
+ 'EXTENSION_DECLARES_ABSTRACT_MEMBER',
+ "Extensions can't declare abstract members.",
+ correction: "Try providing an implementation for the member.",
+ hasPublishedDocs: true,
+);
const ParserErrorCode _EXTENSION_DECLARES_CONSTRUCTOR = ParserErrorCode(
- 'EXTENSION_DECLARES_CONSTRUCTOR', "Extensions can't declare constructors.",
- correction: "Try removing the constructor declaration.",
- hasPublishedDocs: true);
+ 'EXTENSION_DECLARES_CONSTRUCTOR',
+ "Extensions can't declare constructors.",
+ correction: "Try removing the constructor declaration.",
+ hasPublishedDocs: true,
+);
const ParserErrorCode _EXTENSION_DECLARES_INSTANCE_FIELD = ParserErrorCode(
- 'EXTENSION_DECLARES_INSTANCE_FIELD',
- "Extensions can't declare instance fields",
- correction:
- "Try removing the field declaration or making it a static field",
- hasPublishedDocs: true);
+ 'EXTENSION_DECLARES_INSTANCE_FIELD',
+ "Extensions can't declare instance fields",
+ correction: "Try removing the field declaration or making it a static field",
+ hasPublishedDocs: true,
+);
const ParserErrorCode _EXTERNAL_CLASS = ParserErrorCode(
- 'EXTERNAL_CLASS', "Classes can't be declared to be 'external'.",
- correction: "Try removing the keyword 'external'.");
+ 'EXTERNAL_CLASS',
+ "Classes can't be declared to be 'external'.",
+ correction: "Try removing the keyword 'external'.",
+);
const ParserErrorCode _EXTERNAL_CONSTRUCTOR_WITH_BODY = ParserErrorCode(
- 'EXTERNAL_CONSTRUCTOR_WITH_BODY',
- "External constructors can't have a body.",
- correction:
- "Try removing the body of the constructor, or removing the keyword 'external'.");
+ 'EXTERNAL_CONSTRUCTOR_WITH_BODY',
+ "External constructors can't have a body.",
+ correction:
+ "Try removing the body of the constructor, or removing the keyword 'external'.",
+);
const ParserErrorCode _EXTERNAL_CONSTRUCTOR_WITH_INITIALIZER = ParserErrorCode(
- 'EXTERNAL_CONSTRUCTOR_WITH_INITIALIZER',
- "An external constructor can't have any initializers.");
+ 'EXTERNAL_CONSTRUCTOR_WITH_INITIALIZER',
+ "An external constructor can't have any initializers.",
+);
const ParserErrorCode _EXTERNAL_ENUM = ParserErrorCode(
- 'EXTERNAL_ENUM', "Enums can't be declared to be 'external'.",
- correction: "Try removing the keyword 'external'.");
+ 'EXTERNAL_ENUM',
+ "Enums can't be declared to be 'external'.",
+ correction: "Try removing the keyword 'external'.",
+);
const ParserErrorCode _EXTERNAL_FACTORY_REDIRECTION = ParserErrorCode(
- 'EXTERNAL_FACTORY_REDIRECTION', "A redirecting factory can't be external.",
- correction: "Try removing the 'external' modifier.");
+ 'EXTERNAL_FACTORY_REDIRECTION',
+ "A redirecting factory can't be external.",
+ correction: "Try removing the 'external' modifier.",
+);
const ParserErrorCode _EXTERNAL_FACTORY_WITH_BODY = ParserErrorCode(
- 'EXTERNAL_FACTORY_WITH_BODY', "External factories can't have a body.",
- correction:
- "Try removing the body of the factory, or removing the keyword 'external'.");
+ 'EXTERNAL_FACTORY_WITH_BODY',
+ "External factories can't have a body.",
+ correction:
+ "Try removing the body of the factory, or removing the keyword 'external'.",
+);
const ParserErrorCode _EXTERNAL_FIELD = ParserErrorCode(
- 'EXTERNAL_FIELD', "Fields can't be declared to be 'external'.",
- correction:
- "Try removing the keyword 'external', or replacing the field by an external getter and/or setter.");
+ 'EXTERNAL_FIELD',
+ "Fields can't be declared to be 'external'.",
+ correction:
+ "Try removing the keyword 'external', or replacing the field by an external getter and/or setter.",
+);
const ParserErrorCode _EXTERNAL_LATE_FIELD = ParserErrorCode(
- 'EXTERNAL_LATE_FIELD', "External fields cannot be late.",
- correction: "Try removing the 'external' or 'late' keyword.");
+ 'EXTERNAL_LATE_FIELD',
+ "External fields cannot be late.",
+ correction: "Try removing the 'external' or 'late' keyword.",
+);
const ParserErrorCode _EXTERNAL_METHOD_WITH_BODY = ParserErrorCode(
- 'EXTERNAL_METHOD_WITH_BODY',
- "An external or native method can't have a body.");
+ 'EXTERNAL_METHOD_WITH_BODY',
+ "An external or native method can't have a body.",
+);
const ParserErrorCode _EXTERNAL_TYPEDEF = ParserErrorCode(
- 'EXTERNAL_TYPEDEF', "Typedefs can't be declared to be 'external'.",
- correction: "Try removing the keyword 'external'.");
+ 'EXTERNAL_TYPEDEF',
+ "Typedefs can't be declared to be 'external'.",
+ correction: "Try removing the keyword 'external'.",
+);
const ParserErrorCode _EXTRANEOUS_MODIFIER = ParserErrorCode(
- 'EXTRANEOUS_MODIFIER', "Can't have modifier '{0}' here.",
- correction: "Try removing '{0}'.");
+ 'EXTRANEOUS_MODIFIER',
+ "Can't have modifier '{0}' here.",
+ correction: "Try removing '{0}'.",
+);
const ParserErrorCode _FACTORY_TOP_LEVEL_DECLARATION = ParserErrorCode(
- 'FACTORY_TOP_LEVEL_DECLARATION',
- "Top-level declarations can't be declared to be 'factory'.",
- correction: "Try removing the keyword 'factory'.");
+ 'FACTORY_TOP_LEVEL_DECLARATION',
+ "Top-level declarations can't be declared to be 'factory'.",
+ correction: "Try removing the keyword 'factory'.",
+);
-const ParserErrorCode _FIELD_INITIALIZED_OUTSIDE_DECLARING_CLASS = ParserErrorCode(
- 'FIELD_INITIALIZED_OUTSIDE_DECLARING_CLASS',
- "A field can only be initialized in its declaring class",
- correction:
- "Try passing a value into the superclass constructor, or moving the initialization into the constructor body.");
+const ParserErrorCode _FIELD_INITIALIZED_OUTSIDE_DECLARING_CLASS =
+ ParserErrorCode(
+ 'FIELD_INITIALIZED_OUTSIDE_DECLARING_CLASS',
+ "A field can only be initialized in its declaring class",
+ correction:
+ "Try passing a value into the superclass constructor, or moving the initialization into the constructor body.",
+);
const ParserErrorCode _FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR = ParserErrorCode(
- 'FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR',
- "Field formal parameters can only be used in a constructor.",
- correction: "Try removing 'this.'.");
+ 'FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR',
+ "Field formal parameters can only be used in a constructor.",
+ correction: "Try removing 'this.'.",
+);
const ParserErrorCode _FINAL_AND_COVARIANT = ParserErrorCode(
- 'FINAL_AND_COVARIANT',
- "Members can't be declared to be both 'final' and 'covariant'.",
- correction: "Try removing either the 'final' or 'covariant' keyword.");
+ 'FINAL_AND_COVARIANT',
+ "Members can't be declared to be both 'final' and 'covariant'.",
+ correction: "Try removing either the 'final' or 'covariant' keyword.",
+);
-const ParserErrorCode _FINAL_AND_COVARIANT_LATE_WITH_INITIALIZER = ParserErrorCode(
- 'FINAL_AND_COVARIANT_LATE_WITH_INITIALIZER',
- "Members marked 'late' with an initializer can't be declared to be both 'final' and 'covariant'.",
- correction:
- "Try removing either the 'final' or 'covariant' keyword, or removing the initializer.");
+const ParserErrorCode _FINAL_AND_COVARIANT_LATE_WITH_INITIALIZER =
+ ParserErrorCode(
+ 'FINAL_AND_COVARIANT_LATE_WITH_INITIALIZER',
+ "Members marked 'late' with an initializer can't be declared to be both 'final' and 'covariant'.",
+ correction:
+ "Try removing either the 'final' or 'covariant' keyword, or removing the initializer.",
+);
const ParserErrorCode _FINAL_AND_VAR = ParserErrorCode(
- 'FINAL_AND_VAR', "Members can't be declared to be both 'final' and 'var'.",
- correction: "Try removing the keyword 'var'.");
+ 'FINAL_AND_VAR',
+ "Members can't be declared to be both 'final' and 'var'.",
+ correction: "Try removing the keyword 'var'.",
+);
const ParserErrorCode _GETTER_CONSTRUCTOR = ParserErrorCode(
- 'GETTER_CONSTRUCTOR', "Constructors can't be a getter.",
- correction: "Try removing 'get'.");
+ 'GETTER_CONSTRUCTOR',
+ "Constructors can't be a getter.",
+ correction: "Try removing 'get'.",
+);
const ParserErrorCode _ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE = ParserErrorCode(
- 'ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE',
- "Illegal assignment to non-assignable expression.");
+ 'ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE',
+ "Illegal assignment to non-assignable expression.",
+);
const ParserErrorCode _IMPLEMENTS_BEFORE_EXTENDS = ParserErrorCode(
- 'IMPLEMENTS_BEFORE_EXTENDS',
- "The extends clause must be before the implements clause.",
- correction: "Try moving the extends clause before the implements clause.");
+ 'IMPLEMENTS_BEFORE_EXTENDS',
+ "The extends clause must be before the implements clause.",
+ correction: "Try moving the extends clause before the implements clause.",
+);
const ParserErrorCode _IMPLEMENTS_BEFORE_ON = ParserErrorCode(
- 'IMPLEMENTS_BEFORE_ON',
- "The on clause must be before the implements clause.",
- correction: "Try moving the on clause before the implements clause.");
+ 'IMPLEMENTS_BEFORE_ON',
+ "The on clause must be before the implements clause.",
+ correction: "Try moving the on clause before the implements clause.",
+);
const ParserErrorCode _IMPLEMENTS_BEFORE_WITH = ParserErrorCode(
- 'IMPLEMENTS_BEFORE_WITH',
- "The with clause must be before the implements clause.",
- correction: "Try moving the with clause before the implements clause.");
+ 'IMPLEMENTS_BEFORE_WITH',
+ "The with clause must be before the implements clause.",
+ correction: "Try moving the with clause before the implements clause.",
+);
const ParserErrorCode _IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE = ParserErrorCode(
- 'IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE',
- "Import directives must precede part directives.",
- correction: "Try moving the import directives before the part directives.");
+ 'IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE',
+ "Import directives must precede part directives.",
+ correction: "Try moving the import directives before the part directives.",
+);
const ParserErrorCode _INITIALIZED_VARIABLE_IN_FOR_EACH = ParserErrorCode(
- 'INITIALIZED_VARIABLE_IN_FOR_EACH',
- "The loop variable in a for-each loop can't be initialized.",
- correction:
- "Try removing the initializer, or using a different kind of loop.");
+ 'INITIALIZED_VARIABLE_IN_FOR_EACH',
+ "The loop variable in a for-each loop can't be initialized.",
+ correction:
+ "Try removing the initializer, or using a different kind of loop.",
+);
const ParserErrorCode _INVALID_AWAIT_IN_FOR = ParserErrorCode(
- 'INVALID_AWAIT_IN_FOR',
- "The keyword 'await' isn't allowed for a normal 'for' statement.",
- correction: "Try removing the keyword, or use a for-each statement.");
+ 'INVALID_AWAIT_IN_FOR',
+ "The keyword 'await' isn't allowed for a normal 'for' statement.",
+ correction: "Try removing the keyword, or use a for-each statement.",
+);
const ParserErrorCode _INVALID_CONSTRUCTOR_NAME = ParserErrorCode(
- 'INVALID_CONSTRUCTOR_NAME',
- "The name of a constructor must match the name of the enclosing class.");
+ 'INVALID_CONSTRUCTOR_NAME',
+ "The name of a constructor must match the name of the enclosing class.",
+);
const ParserErrorCode _INVALID_HEX_ESCAPE = ParserErrorCode(
- 'INVALID_HEX_ESCAPE',
- "An escape sequence starting with '\\x' must be followed by 2 hexadecimal digits.");
+ 'INVALID_HEX_ESCAPE',
+ "An escape sequence starting with '\\x' must be followed by 2 hexadecimal digits.",
+);
const ParserErrorCode _INVALID_INITIALIZER = ParserErrorCode(
- 'INVALID_INITIALIZER', "Not a valid initializer.",
- correction: "To initialize a field, use the syntax 'name = value'.");
+ 'INVALID_INITIALIZER',
+ "Not a valid initializer.",
+ correction: "To initialize a field, use the syntax 'name = value'.",
+);
const ParserErrorCode _INVALID_OPERATOR = ParserErrorCode(
- 'INVALID_OPERATOR', "The string '{0}' isn't a user-definable operator.");
+ 'INVALID_OPERATOR',
+ "The string '{0}' isn't a user-definable operator.",
+);
const ParserErrorCode _INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER =
- ParserErrorCode('INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER',
- "The operator '?.' cannot be used with 'super' because 'super' cannot be null.",
- correction: "Try replacing '?.' with '.'");
+ ParserErrorCode(
+ 'INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER',
+ "The operator '?.' cannot be used with 'super' because 'super' cannot be null.",
+ correction: "Try replacing '?.' with '.'",
+);
const ParserErrorCode _INVALID_SUPER_IN_INITIALIZER = ParserErrorCode(
- 'INVALID_SUPER_IN_INITIALIZER',
- "Can only use 'super' in an initializer for calling the superclass constructor (e.g. 'super()' or 'super.namedConstructor()')");
+ 'INVALID_SUPER_IN_INITIALIZER',
+ "Can only use 'super' in an initializer for calling the superclass constructor (e.g. 'super()' or 'super.namedConstructor()')",
+);
const ParserErrorCode _INVALID_THIS_IN_INITIALIZER = ParserErrorCode(
- 'INVALID_THIS_IN_INITIALIZER',
- "Can only use 'this' in an initializer for field initialization (e.g. 'this.x = something') and constructor redirection (e.g. 'this()' or 'this.namedConstructor())");
+ 'INVALID_THIS_IN_INITIALIZER',
+ "Can only use 'this' in an initializer for field initialization (e.g. 'this.x = something') and constructor redirection (e.g. 'this()' or 'this.namedConstructor())",
+);
const ParserErrorCode _INVALID_UNICODE_ESCAPE = ParserErrorCode(
- 'INVALID_UNICODE_ESCAPE',
- "An escape sequence starting with '\\u' must be followed by 4 hexadecimal digits or from 1 to 6 digits between '{' and '}'.");
+ 'INVALID_UNICODE_ESCAPE',
+ "An escape sequence starting with '\\u' must be followed by 4 hexadecimal digits or from 1 to 6 digits between '{' and '}'.",
+);
const ParserErrorCode _INVALID_USE_OF_COVARIANT_IN_EXTENSION = ParserErrorCode(
- 'INVALID_USE_OF_COVARIANT_IN_EXTENSION',
- "Can't have modifier '{0}' in an extension.",
- correction: "Try removing '{0}'.",
- hasPublishedDocs: true);
+ 'INVALID_USE_OF_COVARIANT_IN_EXTENSION',
+ "Can't have modifier '{0}' in an extension.",
+ correction: "Try removing '{0}'.",
+ hasPublishedDocs: true,
+);
const ParserErrorCode _LIBRARY_DIRECTIVE_NOT_FIRST = ParserErrorCode(
- 'LIBRARY_DIRECTIVE_NOT_FIRST',
- "The library directive must appear before all other directives.",
- correction:
- "Try moving the library directive before any other directives.");
+ 'LIBRARY_DIRECTIVE_NOT_FIRST',
+ "The library directive must appear before all other directives.",
+ correction: "Try moving the library directive before any other directives.",
+);
const ParserErrorCode _LITERAL_WITH_CLASS = ParserErrorCode(
- 'LITERAL_WITH_CLASS', "A {0} literal can't be prefixed by '{1}'.",
- correction: "Try removing '{1}'");
+ 'LITERAL_WITH_CLASS',
+ "A {0} literal can't be prefixed by '{1}'.",
+ correction: "Try removing '{1}'",
+);
const ParserErrorCode _LITERAL_WITH_CLASS_AND_NEW = ParserErrorCode(
- 'LITERAL_WITH_CLASS_AND_NEW',
- "A {0} literal can't be prefixed by 'new {1}'.",
- correction: "Try removing 'new' and '{1}'");
+ 'LITERAL_WITH_CLASS_AND_NEW',
+ "A {0} literal can't be prefixed by 'new {1}'.",
+ correction: "Try removing 'new' and '{1}'",
+);
const ParserErrorCode _LITERAL_WITH_NEW = ParserErrorCode(
- 'LITERAL_WITH_NEW', "A literal can't be prefixed by 'new'.",
- correction: "Try removing 'new'");
+ 'LITERAL_WITH_NEW',
+ "A literal can't be prefixed by 'new'.",
+ correction: "Try removing 'new'",
+);
const ParserErrorCode _MEMBER_WITH_CLASS_NAME = ParserErrorCode(
- 'MEMBER_WITH_CLASS_NAME',
- "A class member can't have the same name as the enclosing class.",
- correction: "Try renaming the member.");
+ 'MEMBER_WITH_CLASS_NAME',
+ "A class member can't have the same name as the enclosing class.",
+ correction: "Try renaming the member.",
+);
const ParserErrorCode _MISSING_ASSIGNABLE_SELECTOR = ParserErrorCode(
- 'MISSING_ASSIGNABLE_SELECTOR',
- "Missing selector such as '.identifier' or '[0]'.",
- correction: "Try adding a selector.");
+ 'MISSING_ASSIGNABLE_SELECTOR',
+ "Missing selector such as '.identifier' or '[0]'.",
+ correction: "Try adding a selector.",
+);
const ParserErrorCode _MISSING_ASSIGNMENT_IN_INITIALIZER = ParserErrorCode(
- 'MISSING_ASSIGNMENT_IN_INITIALIZER',
- "Expected an assignment after the field name.",
- correction: "To initialize a field, use the syntax 'name = value'.");
+ 'MISSING_ASSIGNMENT_IN_INITIALIZER',
+ "Expected an assignment after the field name.",
+ correction: "To initialize a field, use the syntax 'name = value'.",
+);
const ParserErrorCode _MISSING_CATCH_OR_FINALLY = ParserErrorCode(
- 'MISSING_CATCH_OR_FINALLY',
- "A try block must be followed by an 'on', 'catch', or 'finally' clause.",
- correction:
- "Try adding either a catch or finally clause, or remove the try statement.");
+ 'MISSING_CATCH_OR_FINALLY',
+ "A try block must be followed by an 'on', 'catch', or 'finally' clause.",
+ correction:
+ "Try adding either a catch or finally clause, or remove the try statement.",
+);
const ParserErrorCode _MISSING_CONST_FINAL_VAR_OR_TYPE = ParserErrorCode(
- 'MISSING_CONST_FINAL_VAR_OR_TYPE',
- "Variables must be declared using the keywords 'const', 'final', 'var' or a type name.",
- correction:
- "Try adding the name of the type of the variable or the keyword 'var'.");
+ 'MISSING_CONST_FINAL_VAR_OR_TYPE',
+ "Variables must be declared using the keywords 'const', 'final', 'var' or a type name.",
+ correction:
+ "Try adding the name of the type of the variable or the keyword 'var'.",
+);
const ParserErrorCode _MISSING_EXPRESSION_IN_THROW = ParserErrorCode(
- 'MISSING_EXPRESSION_IN_THROW', "Missing expression after 'throw'.",
- correction:
- "Add an expression after 'throw' or use 'rethrow' to throw a caught exception");
+ 'MISSING_EXPRESSION_IN_THROW',
+ "Missing expression after 'throw'.",
+ correction:
+ "Add an expression after 'throw' or use 'rethrow' to throw a caught exception",
+);
-const ParserErrorCode _MISSING_INITIALIZER =
- ParserErrorCode('MISSING_INITIALIZER', "Expected an initializer.");
+const ParserErrorCode _MISSING_INITIALIZER = ParserErrorCode(
+ 'MISSING_INITIALIZER',
+ "Expected an initializer.",
+);
const ParserErrorCode _MISSING_KEYWORD_OPERATOR = ParserErrorCode(
- 'MISSING_KEYWORD_OPERATOR',
- "Operator declarations must be preceded by the keyword 'operator'.",
- correction: "Try adding the keyword 'operator'.");
+ 'MISSING_KEYWORD_OPERATOR',
+ "Operator declarations must be preceded by the keyword 'operator'.",
+ correction: "Try adding the keyword 'operator'.",
+);
const ParserErrorCode _MISSING_PREFIX_IN_DEFERRED_IMPORT = ParserErrorCode(
- 'MISSING_PREFIX_IN_DEFERRED_IMPORT',
- "Deferred imports should have a prefix.",
- correction: "Try adding a prefix to the import by adding an 'as' clause.");
+ 'MISSING_PREFIX_IN_DEFERRED_IMPORT',
+ "Deferred imports should have a prefix.",
+ correction: "Try adding a prefix to the import by adding an 'as' clause.",
+);
-const ParserErrorCode _MISSING_STATEMENT =
- ParserErrorCode('MISSING_STATEMENT', "Expected a statement.");
+const ParserErrorCode _MISSING_STATEMENT = ParserErrorCode(
+ 'MISSING_STATEMENT',
+ "Expected a statement.",
+);
const ParserErrorCode _MIXIN_DECLARES_CONSTRUCTOR = ParserErrorCode(
- 'MIXIN_DECLARES_CONSTRUCTOR', "Mixins can't declare constructors.");
+ 'MIXIN_DECLARES_CONSTRUCTOR',
+ "Mixins can't declare constructors.",
+);
const ParserErrorCode _MODIFIER_OUT_OF_ORDER = ParserErrorCode(
- 'MODIFIER_OUT_OF_ORDER',
- "The modifier '{0}' should be before the modifier '{1}'.",
- correction: "Try re-ordering the modifiers.");
+ 'MODIFIER_OUT_OF_ORDER',
+ "The modifier '{0}' should be before the modifier '{1}'.",
+ correction: "Try re-ordering the modifiers.",
+);
const ParserErrorCode _MULTIPLE_EXTENDS_CLAUSES = ParserErrorCode(
- 'MULTIPLE_EXTENDS_CLAUSES',
- "Each class definition can have at most one extends clause.",
- correction:
- "Try choosing one superclass and define your class to implement (or mix in) the others.");
+ 'MULTIPLE_EXTENDS_CLAUSES',
+ "Each class definition can have at most one extends clause.",
+ correction:
+ "Try choosing one superclass and define your class to implement (or mix in) the others.",
+);
const ParserErrorCode _MULTIPLE_LIBRARY_DIRECTIVES = ParserErrorCode(
- 'MULTIPLE_LIBRARY_DIRECTIVES',
- "Only one library directive may be declared in a file.",
- correction: "Try removing all but one of the library directives.");
+ 'MULTIPLE_LIBRARY_DIRECTIVES',
+ "Only one library directive may be declared in a file.",
+ correction: "Try removing all but one of the library directives.",
+);
const ParserErrorCode _MULTIPLE_ON_CLAUSES = ParserErrorCode(
- 'MULTIPLE_ON_CLAUSES',
- "Each mixin definition can have at most one on clause.",
- correction: "Try combining all of the on clauses into a single clause.");
+ 'MULTIPLE_ON_CLAUSES',
+ "Each mixin definition can have at most one on clause.",
+ correction: "Try combining all of the on clauses into a single clause.",
+);
const ParserErrorCode _MULTIPLE_PART_OF_DIRECTIVES = ParserErrorCode(
- 'MULTIPLE_PART_OF_DIRECTIVES',
- "Only one part-of directive may be declared in a file.",
- correction: "Try removing all but one of the part-of directives.");
+ 'MULTIPLE_PART_OF_DIRECTIVES',
+ "Only one part-of directive may be declared in a file.",
+ correction: "Try removing all but one of the part-of directives.",
+);
const ParserErrorCode _MULTIPLE_VARIANCE_MODIFIERS = ParserErrorCode(
- 'MULTIPLE_VARIANCE_MODIFIERS',
- "Each type parameter can have at most one variance modifier.",
- correction: "Use at most one of the 'in', 'out', or 'inout' modifiers.");
+ 'MULTIPLE_VARIANCE_MODIFIERS',
+ "Each type parameter can have at most one variance modifier.",
+ correction: "Use at most one of the 'in', 'out', or 'inout' modifiers.",
+);
const ParserErrorCode _MULTIPLE_WITH_CLAUSES = ParserErrorCode(
- 'MULTIPLE_WITH_CLAUSES',
- "Each class definition can have at most one with clause.",
- correction: "Try combining all of the with clauses into a single clause.");
+ 'MULTIPLE_WITH_CLAUSES',
+ "Each class definition can have at most one with clause.",
+ correction: "Try combining all of the with clauses into a single clause.",
+);
const ParserErrorCode _NATIVE_CLAUSE_SHOULD_BE_ANNOTATION = ParserErrorCode(
- 'NATIVE_CLAUSE_SHOULD_BE_ANNOTATION',
- "Native clause in this form is deprecated.",
- correction:
- "Try removing this native clause and adding @native() or @native('native-name') before the declaration.");
+ 'NATIVE_CLAUSE_SHOULD_BE_ANNOTATION',
+ "Native clause in this form is deprecated.",
+ correction:
+ "Try removing this native clause and adding @native() or @native('native-name') before the declaration.",
+);
const ParserErrorCode _NULL_AWARE_CASCADE_OUT_OF_ORDER = ParserErrorCode(
- 'NULL_AWARE_CASCADE_OUT_OF_ORDER',
- "The '?..' cascade operator must be first in the cascade sequence.",
- correction:
- "Try moving the '?..' operator to be the first cascade operator in the sequence.");
+ 'NULL_AWARE_CASCADE_OUT_OF_ORDER',
+ "The '?..' cascade operator must be first in the cascade sequence.",
+ correction:
+ "Try moving the '?..' operator to be the first cascade operator in the sequence.",
+);
const ParserErrorCode _PREFIX_AFTER_COMBINATOR = ParserErrorCode(
- 'PREFIX_AFTER_COMBINATOR',
- "The prefix ('as' clause) should come before any show/hide combinators.",
- correction: "Try moving the prefix before the combinators.");
+ 'PREFIX_AFTER_COMBINATOR',
+ "The prefix ('as' clause) should come before any show/hide combinators.",
+ correction: "Try moving the prefix before the combinators.",
+);
const ParserErrorCode _REDIRECTING_CONSTRUCTOR_WITH_BODY = ParserErrorCode(
- 'REDIRECTING_CONSTRUCTOR_WITH_BODY',
- "Redirecting constructors can't have a body.",
- correction:
- "Try removing the body, or not making this a redirecting constructor.");
+ 'REDIRECTING_CONSTRUCTOR_WITH_BODY',
+ "Redirecting constructors can't have a body.",
+ correction:
+ "Try removing the body, or not making this a redirecting constructor.",
+);
const ParserErrorCode _REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR = ParserErrorCode(
- 'REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR',
- "Only factory constructor can specify '=' redirection.",
- correction:
- "Try making this a factory constructor, or remove the redirection.");
+ 'REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR',
+ "Only factory constructor can specify '=' redirection.",
+ correction:
+ "Try making this a factory constructor, or remove the redirection.",
+);
const ParserErrorCode _SETTER_CONSTRUCTOR = ParserErrorCode(
- 'SETTER_CONSTRUCTOR', "Constructors can't be a setter.",
- correction: "Try removing 'set'.");
+ 'SETTER_CONSTRUCTOR',
+ "Constructors can't be a setter.",
+ correction: "Try removing 'set'.",
+);
const ParserErrorCode _STACK_OVERFLOW = ParserErrorCode(
- 'STACK_OVERFLOW', "The file has too many nested expressions or statements.",
- correction: "Try simplifying the code.");
+ 'STACK_OVERFLOW',
+ "The file has too many nested expressions or statements.",
+ correction: "Try simplifying the code.",
+);
const ParserErrorCode _STATIC_CONSTRUCTOR = ParserErrorCode(
- 'STATIC_CONSTRUCTOR', "Constructors can't be static.",
- correction: "Try removing the keyword 'static'.");
+ 'STATIC_CONSTRUCTOR',
+ "Constructors can't be static.",
+ correction: "Try removing the keyword 'static'.",
+);
const ParserErrorCode _STATIC_OPERATOR = ParserErrorCode(
- 'STATIC_OPERATOR', "Operators can't be static.",
- correction: "Try removing the keyword 'static'.");
+ 'STATIC_OPERATOR',
+ "Operators can't be static.",
+ correction: "Try removing the keyword 'static'.",
+);
const ParserErrorCode _SWITCH_HAS_CASE_AFTER_DEFAULT_CASE = ParserErrorCode(
- 'SWITCH_HAS_CASE_AFTER_DEFAULT_CASE',
- "The default case should be the last case in a switch statement.",
- correction: "Try moving the default case after the other case clauses.");
+ 'SWITCH_HAS_CASE_AFTER_DEFAULT_CASE',
+ "The default case should be the last case in a switch statement.",
+ correction: "Try moving the default case after the other case clauses.",
+);
const ParserErrorCode _SWITCH_HAS_MULTIPLE_DEFAULT_CASES = ParserErrorCode(
- 'SWITCH_HAS_MULTIPLE_DEFAULT_CASES',
- "The 'default' case can only be declared once.",
- correction: "Try removing all but one default case.");
+ 'SWITCH_HAS_MULTIPLE_DEFAULT_CASES',
+ "The 'default' case can only be declared once.",
+ correction: "Try removing all but one default case.",
+);
const ParserErrorCode _TOP_LEVEL_OPERATOR = ParserErrorCode(
- 'TOP_LEVEL_OPERATOR', "Operators must be declared within a class.",
- correction:
- "Try removing the operator, moving it to a class, or converting it to be a function.");
+ 'TOP_LEVEL_OPERATOR',
+ "Operators must be declared within a class.",
+ correction:
+ "Try removing the operator, moving it to a class, or converting it to be a function.",
+);
const ParserErrorCode _TYPEDEF_IN_CLASS = ParserErrorCode(
- 'TYPEDEF_IN_CLASS', "Typedefs can't be declared inside classes.",
- correction: "Try moving the typedef to the top-level.");
+ 'TYPEDEF_IN_CLASS',
+ "Typedefs can't be declared inside classes.",
+ correction: "Try moving the typedef to the top-level.",
+);
const ParserErrorCode _TYPE_ARGUMENTS_ON_TYPE_VARIABLE = ParserErrorCode(
- 'TYPE_ARGUMENTS_ON_TYPE_VARIABLE',
- "Can't use type arguments with type variable '{0}'.",
- correction: "Try removing the type arguments.");
+ 'TYPE_ARGUMENTS_ON_TYPE_VARIABLE',
+ "Can't use type arguments with type variable '{0}'.",
+ correction: "Try removing the type arguments.",
+);
const ParserErrorCode _TYPE_BEFORE_FACTORY = ParserErrorCode(
- 'TYPE_BEFORE_FACTORY', "Factory constructors cannot have a return type.",
- correction: "Try removing the type appearing before 'factory'.");
+ 'TYPE_BEFORE_FACTORY',
+ "Factory constructors cannot have a return type.",
+ correction: "Try removing the type appearing before 'factory'.",
+);
const ParserErrorCode _TYPE_PARAMETER_ON_CONSTRUCTOR = ParserErrorCode(
- 'TYPE_PARAMETER_ON_CONSTRUCTOR', "Constructors can't have type parameters.",
- correction: "Try removing the type parameters.");
+ 'TYPE_PARAMETER_ON_CONSTRUCTOR',
+ "Constructors can't have type parameters.",
+ correction: "Try removing the type parameters.",
+);
-const ParserErrorCode _VAR_AND_TYPE = ParserErrorCode('VAR_AND_TYPE',
- "Variables can't be declared using both 'var' and a type name.",
- correction: "Try removing 'var.'");
+const ParserErrorCode _VAR_AND_TYPE = ParserErrorCode(
+ 'VAR_AND_TYPE',
+ "Variables can't be declared using both 'var' and a type name.",
+ correction: "Try removing 'var.'",
+);
const ParserErrorCode _VAR_AS_TYPE_NAME = ParserErrorCode(
- 'VAR_AS_TYPE_NAME', "The keyword 'var' can't be used as a type name.");
+ 'VAR_AS_TYPE_NAME',
+ "The keyword 'var' can't be used as a type name.",
+);
const ParserErrorCode _VAR_RETURN_TYPE = ParserErrorCode(
- 'VAR_RETURN_TYPE', "The return type can't be 'var'.",
- correction:
- "Try removing the keyword 'var', or replacing it with the name of the return type.");
+ 'VAR_RETURN_TYPE',
+ "The return type can't be 'var'.",
+ correction:
+ "Try removing the keyword 'var', or replacing it with the name of the return type.",
+);
const ParserErrorCode _VOID_WITH_TYPE_ARGUMENTS = ParserErrorCode(
- 'VOID_WITH_TYPE_ARGUMENTS', "Type 'void' can't have type arguments.",
- correction: "Try removing the type arguments.");
+ 'VOID_WITH_TYPE_ARGUMENTS',
+ "Type 'void' can't have type arguments.",
+ correction: "Try removing the type arguments.",
+);
const ParserErrorCode _WITH_BEFORE_EXTENDS = ParserErrorCode(
- 'WITH_BEFORE_EXTENDS', "The extends clause must be before the with clause.",
- correction: "Try moving the extends clause before the with clause.");
+ 'WITH_BEFORE_EXTENDS',
+ "The extends clause must be before the with clause.",
+ correction: "Try moving the extends clause before the with clause.",
+);
diff --git a/pkg/analyzer/lib/src/error/codes.dart b/pkg/analyzer/lib/src/error/codes.dart
index 0b43ce7..1687c1d 100644
--- a/pkg/analyzer/lib/src/error/codes.dart
+++ b/pkg/analyzer/lib/src/error/codes.dart
@@ -2,15800 +2,8 @@
// 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.
-import 'package:analyzer/error/error.dart';
-import 'package:analyzer/src/error/analyzer_error_code.dart';
-
export 'package:analyzer/src/analysis_options/error/option_codes.dart';
export 'package:analyzer/src/dart/error/hint_codes.dart';
export 'package:analyzer/src/dart/error/lint_codes.dart';
export 'package:analyzer/src/dart/error/todo_codes.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
-
-/**
- * The error codes used for compile time errors. The convention for this class
- * is for the name of the error code to indicate the problem that caused the
- * error to be generated and for the error message to explain what is wrong and,
- * when appropriate, how the problem can be corrected.
- */
-class CompileTimeErrorCode extends AnalyzerErrorCode {
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a field that has the `abstract`
- // modifier also has an initializer.
- //
- // #### Example
- //
- // 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.",
- correction: "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.",
- correction: "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.
- //
- // #### Examples
- //
- // 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}'.",
- correction: "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 name of the first declaring extension
- * 2: the name of the second declaring extension
- */
- // #### 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.
- //
- // #### Examples
- //
- // 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 extensions {1}, and "
- "none are more specific.",
- correction:
- "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.
- //
- // #### Examples
- //
- // 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}.",
- correction: "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.
- //
- // #### Examples
- //
- // 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.",
- correction:
- "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.
- //
- // #### Examples
- //
- // 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.",
- correction:
- "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.
- //
- // #### Examples
- //
- // 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.",
- correction: "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`.
- //
- // #### Examples
- //
- // 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.",
- correction: "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.
- //
- // #### Examples
- //
- // 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.",
- correction: "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.
- //
- // #### Examples
- //
- // 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}'.",
- correction:
- "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.
- //
- // #### Examples
- //
- // 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.",
- correction:
- "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.",
- correction:
- "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.",
- correction:
- "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.
- //
- // #### Example
- //
- // 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 change the
- // return type so that it's valid to return `null`:
- //
- // ```dart
- // class C<T> {
- // T? m(T t) {
- // print(t);
- // }
- // }
- // ```
- 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 is a potentially non-nullable type.",
- correction:
- "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.",
- correction: "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.",
- correction: "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.
- //
- // #### Examples
- //
- // 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.",
- correction: "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_TYPE_NAME =
- CompileTimeErrorCode('BUILT_IN_IDENTIFIER_IN_DECLARATION',
- "The built-in identifier '{0}' can't be used as a type name.",
- correction: "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.",
- correction: "Try choosing a different name for the type parameter.",
- hasPublishedDocs: true,
- uniqueName: 'BUILT_IN_IDENTIFIER_AS_TYPE_PARAMETER_NAME');
-
- /**
- * 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.",
- correction: "Try choosing a different name for the typedef.",
- hasPublishedDocs: true,
- uniqueName: 'BUILT_IN_IDENTIFIER_AS_TYPEDEF_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`.
- //
- // #### Examples
- //
- // 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'.",
- correction: "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.
- //
- // #### Examples
- //
- // 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.",
- correction: "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.",
- correction:
- "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.",
- correction: "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}.",
- correction: "Try invoking a different constructor, or defining a "
- "constructor named '{1}'.",
- uniqueName: 'CLASS_INSTANTIATION_ACCESS_TO_UNKNOWN_MEMBER');
-
- /**
- * 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.
- //
- // #### Examples
- //
- // 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.",
- correction: "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.
- //
- // #### Example
- //
- // 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.",
- correction: "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.",
- correction: "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.",
- correction: "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.",
- correction: "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.",
- correction: "Try converting the getter to a method, or "
- "renaming the field to a name that doesn't conflict.");
-
- /**
- * 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}");
-
- /**
- * 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.",
- correction: "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.",
- correction:
- "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.",
- correction: "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_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.",
- correction: "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.",
- correction: "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_MIXIN =
- CompileTimeErrorCode(
- 'CONFLICTING_TYPE_VARIABLE_AND_MEMBER',
- "'{0}' can't be used to name both a type variable and a member in "
- "this mixin.",
- correction: "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_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.",
- correction: "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_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.",
- correction: "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}'.",
- correction: "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.",
- correction: "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.",
- correction: "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.",
- correction: "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}.",
- correction: "Try removing the 'const' keyword or removing the 'with' "
- "clause from the class declaration, or removing the field from "
- "the mixin class.",
- uniqueName: 'CONST_CONSTRUCTOR_WITH_MIXIN_WITH_FIELD',
- );
-
- /**
- * 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}.",
- correction: "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}'.",
- correction: "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).
- //
- // #### Examples
- //
- // 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.",
- correction: "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'.",
- correction: "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.",
- correction: "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.
- //
- // #### Examples
- //
- // 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.",
- correction:
- "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.",
- correction:
- "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.
- //
- // #### Examples
- //
- // 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.",
- correction: "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.",
- correction: "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.
- //
- // #### Examples
- //
- // 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.",
- correction: "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.",
- correction: "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.
- //
- // #### Examples
- //
- // 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.
- //
- // #### Examples
- //
- // 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`.
- //
- // #### Examples
- //
- // 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.",
- correction: "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.
- //
- // #### Examples
- //
- // 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.",
- correction: "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.",
- correction: "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.",
- correction: "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.",
- correction: "Try replacing the type parameter with a different type.",
- uniqueName: 'CONST_WITH_TYPE_PARAMETERS_CONSTRUCTOR_TEAROFF',
- hasPublishedDocs: true);
-
- /**
- * 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.",
- correction: "Try replacing the type parameter with a different type.",
- uniqueName: 'CONST_WITH_TYPE_PARAMETERS_FUNCTION_TEAROFF',
- hasPublishedDocs: true);
-
- /**
- * 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}'.",
- correction: "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.",
- correction: "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");
-
- /**
- * 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.",
- correction: "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.",
- correction: "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.
- //
- // #### Examples
- //
- // 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.",
- correction: "Try removing either the default value or the 'required' "
- "modifier.");
-
- /**
- * 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.",
- correction:
- "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.",
- correction:
- "Ensure that it is assigned on necessary execution paths.",
- hasPublishedDocs: true);
-
- /**
- * 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.",
- correction: "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.",
- correction: "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.
- //
- // #### Examples
- //
- // 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.",
- correction: "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 field
- // 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 field 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.",
- correction: "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.
- //
- // #### Examples
- //
- // 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.",
- correction: "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}'.",
- correction:
- "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.",
- correction: "Try renaming the constant.");
-
- /**
- * 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.
- //
- // #### Examples
- //
- // 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.",
- correction: "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.
- //
- // #### Examples
- //
- // 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.",
- correction: "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.",
- correction: "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.",
- correction: "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 map literal has either one or
- // more than two type arguments.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the map literal has
- // three type arguments when it can have either two or zero:
- //
- // ```dart
- // var m = [!<int, String, int>!]{};
- // ```
- //
- // #### Common fixes
- //
- // Remove all except two of the type arguments:
- //
- // ```dart
- // var m = <int, String>{};
- // ```
- static const CompileTimeErrorCode EXPECTED_TWO_MAP_TYPE_ARGUMENTS =
- CompileTimeErrorCode('EXPECTED_TWO_MAP_TYPE_ARGUMENTS',
- "Map literals require two type arguments or none, but {0} found.",
- correction: "Try adjusting the number of type arguments.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the uri pointing to a library
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when it finds an export whose `dart:`
- // URI references an internal library.
- //
- // #### Example
- //
- // The following code produces this diagnostic because `_interceptors` is an
- // internal library:
- //
- // ```dart
- // export [!'dart:_interceptors'!];
- // ```
- //
- // #### Common fixes
- //
- // Remove the export directive.
- static const CompileTimeErrorCode EXPORT_INTERNAL_LIBRARY =
- CompileTimeErrorCode('EXPORT_INTERNAL_LIBRARY',
- "The library '{0}' is internal and can't be exported.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of a symbol defined in a legacy library
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a library that was opted in to
- // null safety exports another library, and the exported library is opted out
- // of null safety.
- //
- // #### Example
- //
- // Given a library that is opted out of null safety:
- //
- // ```dart
- // %uri="lib/optedOut.dart"
- // // @dart = 2.8
- // String s;
- // ```
- //
- // The following code produces this diagnostic because it's exporting symbols
- // from an opted-out library:
- //
- // ```dart
- // export [!'optedOut.dart'!];
- //
- // class C {}
- // ```
- //
- // #### Common fixes
- //
- // If you're able to do so, migrate the exported library so that it doesn't
- // need to opt out:
- //
- // ```dart
- // String? s;
- // ```
- //
- // If you can't migrate the library, then remove the export:
- //
- // ```dart
- // class C {}
- // ```
- //
- // If the exported library (the one that is opted out) itself exports an
- // opted-in library, then it's valid for your library to indirectly export the
- // symbols from the opted-in library. You can do so by adding a hide
- // combinator to the export directive in your library that hides all of the
- // names declared in the opted-out library.
- static const CompileTimeErrorCode EXPORT_LEGACY_SYMBOL = CompileTimeErrorCode(
- 'EXPORT_LEGACY_SYMBOL',
- "The symbol '{0}' is defined in a legacy library, and can't be "
- "re-exported from a library with null safety enabled.",
- correction: "Try removing the export or migrating the legacy library.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the uri pointing to a non-library declaration
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an export directive references a
- // part rather than a library.
- //
- // #### 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
- // a part, and only libraries can be exported:
- //
- // ```dart
- // library lib;
- //
- // export [!'part.dart'!];
- // ```
- //
- // #### Common fixes
- //
- // Either remove the export directive, or change the URI to be the URI of the
- // library containing the part.
- static const CompileTimeErrorCode EXPORT_OF_NON_LIBRARY =
- CompileTimeErrorCode('EXPORT_OF_NON_LIBRARY',
- "The exported library '{0}' can't have a part-of directive.",
- correction: "Try exporting the library that the part is a part of.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the analyzer finds an
- // expression, rather than a map entry, in what appears to be a map literal.
- //
- // #### Examples
- //
- // The following code produces this diagnostic:
- //
- // ```dart
- // var map = <String, int>{'a': 0, 'b': 1, [!'c'!]};
- // ```
- //
- // #### Common fixes
- //
- // If the expression is intended to compute either a key or a value in an
- // entry, fix the issue by replacing the expression with the key or the value.
- // For example:
- //
- // ```dart
- // var map = <String, int>{'a': 0, 'b': 1, 'c': 2};
- // ```
- static const CompileTimeErrorCode EXPRESSION_IN_MAP = CompileTimeErrorCode(
- 'EXPRESSION_IN_MAP', "Expressions can't be used in a map literal.",
- correction: "Try removing the expression or converting it to be a map "
- "entry.",
- hasPublishedDocs: true);
-
- /**
- * 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.",
- correction: "Try specifying a different superclass, or "
- "removing the extends clause.",
- hasPublishedDocs: true,
- uniqueName: 'EXTENDS_DEFERRED_CLASS');
-
- /**
- * Parameters:
- * 0: the name of the disallowed type
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when one of the restricted classes is
- // used in either an `extends`, `implements`, `with`, or `on` clause. The
- // classes `bool`, `double`, `FutureOr`, `int`, `Null`, `num`, and `String`
- // are all restricted in this way, to allow for more efficient
- // implementations.
- //
- // #### Example
- //
- // The following code produces this diagnostic because `String` is used in an
- // `extends` clause:
- //
- // ```dart
- // class A extends [!String!] {}
- // ```
- //
- // The following code produces this diagnostic because `String` is used in an
- // `implements` clause:
- //
- // ```dart
- // class B implements [!String!] {}
- // ```
- //
- // The following code produces this diagnostic because `String` is used in a
- // `with` clause:
- //
- // ```dart
- // class C with [!String!] {}
- // ```
- //
- // The following code produces this diagnostic because `String` is used in an
- // `on` clause:
- //
- // ```dart
- // mixin M on [!String!] {}
- // ```
- //
- // #### Common fixes
- //
- // If a different type should be specified, then replace the type:
- //
- // ```dart
- // class A extends Object {}
- // ```
- //
- // If there isn't a different type that would be appropriate, then remove the
- // type, and possibly the whole clause:
- //
- // ```dart
- // class B {}
- // ```
- static const CompileTimeErrorCode EXTENDS_DISALLOWED_CLASS =
- // TODO(scheglov) We might want to restore specific code with FrontEnd.
- // https://github.com/dart-lang/sdk/issues/31821
- CompileTimeErrorCode(
- 'SUBTYPE_OF_DISALLOWED_TYPE',
- "Classes can't extend '{0}'.",
- correction: "Try specifying a different superclass, or "
- "removing the extends clause.",
- hasPublishedDocs: true,
- uniqueName: 'EXTENDS_DISALLOWED_CLASS',
- );
-
- /**
- * Parameters:
- * 0: the name in the extends clause
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an `extends` clause contains a
- // name that is declared to be something other than a class.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `f` is declared to be a
- // function:
- //
- // ```dart
- // void f() {}
- //
- // class C extends [!f!] {}
- // ```
- //
- // #### Common fixes
- //
- // If you want the class to extend a class other than `Object`, then replace
- // the name in the `extends` clause with the name of that class:
- //
- // ```dart
- // void f() {}
- //
- // class C extends B {}
- //
- // class B {}
- // ```
- //
- // If you want the class to extend `Object`, then remove the `extends` clause:
- //
- // ```dart
- // void f() {}
- //
- // class C {}
- // ```
- static const CompileTimeErrorCode EXTENDS_NON_CLASS = CompileTimeErrorCode(
- 'EXTENDS_NON_CLASS', "Classes can only extend other classes.",
- correction:
- "Try specifying a different superclass, or removing the extends "
- "clause.",
- hasPublishedDocs: true,
- isUnresolvedIdentifier: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a type alias that expands to a
- // type parameter is used in an `extends`, `implements`, `with`, or `on`
- // clause.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the type alias `T`,
- // which expands to the type parameter `S`, is used in the `extends` clause of
- // the class `C`:
- //
- // ```dart
- // typedef T<S> = S;
- //
- // class C extends [!T!]<Object> {}
- // ```
- //
- // #### Common fixes
- //
- // Use the value of the type argument directly:
- //
- // ```dart
- // typedef T<S> = S;
- //
- // class C extends Object {}
- // ```
- static const CompileTimeErrorCode
- EXTENDS_TYPE_ALIAS_EXPANDS_TO_TYPE_PARAMETER = CompileTimeErrorCode(
- 'SUPERTYPE_EXPANDS_TO_TYPE_PARAMETER',
- "A type alias that expands to a type parameter can't be used as a "
- "superclass.",
- correction:
- "Try specifying a different superclass, or removing the extends "
- "clause.",
- hasPublishedDocs: true,
- uniqueName: 'EXTENDS_TYPE_ALIAS_EXPANDS_TO_TYPE_PARAMETER');
-
- /**
- * Parameters:
- * 0: the name of the extension
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the name of an extension is used
- // in an expression other than in an extension override or to qualify an
- // access to a static member of the extension. Because classes define a type,
- // the name of a class can be used to refer to the instance of `Type`
- // representing the type of the class. Extensions, on the other hand, don't
- // define a type and can't be used as a type literal.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `E` is an extension:
- //
- // ```dart
- // extension E on int {
- // static String m() => '';
- // }
- //
- // var x = [!E!];
- // ```
- //
- // #### Common fixes
- //
- // Replace the name of the extension with a name that can be referenced, such
- // as a static member defined on the extension:
- //
- // ```dart
- // extension E on int {
- // static String m() => '';
- // }
- //
- // var x = E.m();
- // ```
- static const CompileTimeErrorCode EXTENSION_AS_EXPRESSION =
- CompileTimeErrorCode('EXTENSION_AS_EXPRESSION',
- "Extension '{0}' can't be used as an expression.",
- correction: "Try replacing it with a valid expression.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the extension defining the conflicting member
- * 1: the name of the conflicting static member
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an extension declaration
- // contains both an instance member and a static member that have the same
- // name. The instance member and the static member can't have the same name
- // because it's unclear which member is being referenced by an unqualified use
- // of the name within the body of the extension.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because the name `a` is being
- // used for two different members:
- //
- // ```dart
- // extension E on Object {
- // int get a => 0;
- // static int [!a!]() => 0;
- // }
- // ```
- //
- // #### Common fixes
- //
- // Rename or remove one of the members:
- //
- // ```dart
- // extension E on Object {
- // int get a => 0;
- // static int b() => 0;
- // }
- // ```
- static const CompileTimeErrorCode EXTENSION_CONFLICTING_STATIC_AND_INSTANCE =
- CompileTimeErrorCode(
- 'EXTENSION_CONFLICTING_STATIC_AND_INSTANCE',
- "Extension '{0}' can't define static member '{1}' and an instance "
- "member with the same name.",
- correction:
- "Try renaming the member to a name that doesn't conflict.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an extension declaration
- // declares a member with the same name as a member declared in the class
- // `Object`. Such a member can never be used because the member in `Object` is
- // always found first.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `toString` is defined
- // by `Object`:
- //
- // ```dart
- // extension E on String {
- // String [!toString!]() => this;
- // }
- // ```
- //
- // #### Common fixes
- //
- // Remove the member or rename it so that the name doesn't conflict with the
- // member in `Object`:
- //
- // ```dart
- // extension E on String {
- // String displayString() => this;
- // }
- // ```
- static const CompileTimeErrorCode EXTENSION_DECLARES_MEMBER_OF_OBJECT =
- CompileTimeErrorCode(
- 'EXTENSION_DECLARES_MEMBER_OF_OBJECT',
- "Extensions can't declare members with the same name as a member "
- "declared by 'Object'.",
- correction: "Try specifying a different name for the member.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an extension override is the
- // receiver of the invocation of a static member. Similar to static members in
- // classes, the static members of an extension should be accessed using the
- // name of the extension, not an extension override.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `m` is static:
- //
- // ```dart
- // extension E on String {
- // static void m() {}
- // }
- //
- // void f() {
- // E('').[!m!]();
- // }
- // ```
- //
- // #### Common fixes
- //
- // Replace the extension override with the name of the extension:
- //
- // ```dart
- // extension E on String {
- // static void m() {}
- // }
- //
- // void f() {
- // E.m();
- // }
- // ```
- static const CompileTimeErrorCode EXTENSION_OVERRIDE_ACCESS_TO_STATIC_MEMBER =
- CompileTimeErrorCode(
- 'EXTENSION_OVERRIDE_ACCESS_TO_STATIC_MEMBER',
- "An extension override can't be used to access a static member from "
- "an extension.",
- correction: "Try using just the name of the extension.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the type of the argument
- * 1: the extended type
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the argument to an extension
- // override isn't assignable to the type being extended by the extension.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `3` isn't a `String`:
- //
- // ```dart
- // extension E on String {
- // void method() {}
- // }
- //
- // void f() {
- // E([!3!]).method();
- // }
- // ```
- //
- // #### Common fixes
- //
- // If you're using the correct extension, then update the argument to have the
- // correct type:
- //
- // ```dart
- // extension E on String {
- // void method() {}
- // }
- //
- // void f() {
- // E(3.toString()).method();
- // }
- // ```
- //
- // If there's a different extension that's valid for the type of the argument,
- // then either replace the name of the extension or unwrap the argument so
- // that the correct extension is found.
- static const CompileTimeErrorCode EXTENSION_OVERRIDE_ARGUMENT_NOT_ASSIGNABLE =
- CompileTimeErrorCode(
- 'EXTENSION_OVERRIDE_ARGUMENT_NOT_ASSIGNABLE',
- "The type of the argument to the extension override '{0}' "
- "isn't assignable to the extended type '{1}'.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an extension override is used as
- // the receiver of a cascade expression. The value of a cascade expression
- // `e..m` is the value of the receiver `e`, but extension overrides aren't
- // expressions and don't have a value.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `E(3)` isn't an
- // expression:
- //
- // ```dart
- // extension E on int {
- // void m() {}
- // }
- // f() {
- // [!E!](3)..m();
- // }
- // ```
- //
- // #### Common fixes
- //
- // Use `.` rather than `..`:
- //
- // ```dart
- // extension E on int {
- // void m() {}
- // }
- // f() {
- // E(3).m();
- // }
- // ```
- //
- // If there are multiple cascaded accesses, you'll need to duplicate the
- // extension override for each one.
- static const CompileTimeErrorCode EXTENSION_OVERRIDE_WITH_CASCADE =
- CompileTimeErrorCode(
- 'EXTENSION_OVERRIDE_WITH_CASCADE',
- "Extension overrides have no value so they can't be used as the "
- "receiver of a cascade expression.",
- correction: "Try using '.' instead of '..'.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an extension override is found
- // that isn't being used to access one of the members of the extension. The
- // extension override syntax doesn't have any runtime semantics; it only
- // controls which member is selected at compile time.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `E(i)` isn't an
- // expression:
- //
- // ```dart
- // extension E on int {
- // int get a => 0;
- // }
- //
- // void f(int i) {
- // print([!E(i)!]);
- // }
- // ```
- //
- // #### Common fixes
- //
- // If you want to invoke one of the members of the extension, then add the
- // invocation:
- //
- // ```dart
- // extension E on int {
- // int get a => 0;
- // }
- //
- // void f(int i) {
- // print(E(i).a);
- // }
- // ```
- //
- // If you don't want to invoke a member, then unwrap the argument:
- //
- // ```dart
- // extension E on int {
- // int get a => 0;
- // }
- //
- // void f(int i) {
- // print(i);
- // }
- // ```
- static const CompileTimeErrorCode EXTENSION_OVERRIDE_WITHOUT_ACCESS =
- CompileTimeErrorCode('EXTENSION_OVERRIDE_WITHOUT_ACCESS',
- "An extension override can only be used to access instance members.",
- correction: "Consider adding an access to an instance member.",
- hasPublishedDocs: true);
-
- static const CompileTimeErrorCode EXTERNAL_FIELD_CONSTRUCTOR_INITIALIZER =
- CompileTimeErrorCode('EXTERNAL_FIELD_CONSTRUCTOR_INITIALIZER',
- 'External fields cannot have initializers.',
- correction:
- "Try removing the field initializer or the 'external' keyword "
- "from the field declaration.");
-
- static const CompileTimeErrorCode EXTERNAL_FIELD_INITIALIZER =
- CompileTimeErrorCode('EXTERNAL_FIELD_INITIALIZER',
- 'External fields cannot have initializers.',
- correction:
- "Try removing the initializer or the 'external' keyword.");
-
- static const CompileTimeErrorCode EXTERNAL_VARIABLE_INITIALIZER =
- CompileTimeErrorCode('EXTERNAL_VARIABLE_INITIALIZER',
- 'External variables cannot have initializers.',
- correction:
- "Try removing the initializer or the 'external' keyword.");
-
- /**
- * Parameters:
- * 0: the maximum number of positional arguments
- * 1: the actual number of positional arguments given
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a method or function invocation
- // has more positional arguments than the method or function allows.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `f` defines 2
- // parameters but is invoked with 3 arguments:
- //
- // ```dart
- // void f(int a, int b) {}
- // void g() {
- // f(1, 2, [!3!]);
- // }
- // ```
- //
- // #### Common fixes
- //
- // Remove the arguments that don't correspond to parameters:
- //
- // ```dart
- // void f(int a, int b) {}
- // void g() {
- // f(1, 2);
- // }
- // ```
- static const CompileTimeErrorCode EXTRA_POSITIONAL_ARGUMENTS =
- CompileTimeErrorCode('EXTRA_POSITIONAL_ARGUMENTS',
- "Too many positional arguments: {0} expected, but {1} found.",
- correction: "Try removing the extra arguments.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the maximum number of positional arguments
- * 1: the actual number of positional arguments given
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a method or function invocation
- // has more positional arguments than the method or function allows, but the
- // method or function defines named parameters.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `f` defines 2
- // positional parameters but has a named parameter that could be used for the
- // third argument:
- //
- // ```dart
- // %language=2.9
- // void f(int a, int b, {int c}) {}
- // void g() {
- // f(1, 2, [!3!]);
- // }
- // ```
- //
- // #### Common fixes
- //
- // If some of the arguments should be values for named parameters, then add
- // the names before the arguments:
- //
- // ```dart
- // %language=2.9
- // void f(int a, int b, {int c}) {}
- // void g() {
- // f(1, 2, c: 3);
- // }
- // ```
- //
- // Otherwise, remove the arguments that don't correspond to positional
- // parameters:
- //
- // ```dart
- // %language=2.9
- // void f(int a, int b, {int c}) {}
- // void g() {
- // f(1, 2);
- // }
- // ```
- static const CompileTimeErrorCode EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED =
- CompileTimeErrorCode('EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED',
- "Too many positional arguments: {0} expected, but {1} found.",
- correction: "Try removing the extra positional arguments, "
- "or specifying the name for named arguments.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the field being initialized multiple times
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the initializer list of a
- // constructor initializes a field more than once. There is no value to allow
- // both initializers because only the last value is preserved.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the field `f` is being
- // initialized twice:
- //
- // ```dart
- // class C {
- // int f;
- //
- // C() : f = 0, [!f!] = 1;
- // }
- // ```
- //
- // #### Common fixes
- //
- // Remove one of the initializers:
- //
- // ```dart
- // class C {
- // int f;
- //
- // C() : f = 0;
- // }
- // ```
- static const CompileTimeErrorCode FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS =
- CompileTimeErrorCode('FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS',
- "The field '{0}' can't be initialized twice in the same constructor.",
- correction: "Try removing one of the initializations.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a final field is initialized in
- // both the declaration of the field and in an initializer in a constructor.
- // Final fields can only be assigned once, so it can't be initialized in both
- // places.
- //
- // #### Example
- //
- // The following code produces this diagnostic because `f` is :
- //
- // ```dart
- // class C {
- // final int f = 0;
- // C() : [!f!] = 1;
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the initialization doesn't depend on any values passed to the
- // constructor, and if all of the constructors need to initialize the field to
- // the same value, then remove the initializer from the constructor:
- //
- // ```dart
- // class C {
- // final int f = 0;
- // C();
- // }
- // ```
- //
- // If the initialization depends on a value passed to the constructor, or if
- // different constructors need to initialize the field differently, then
- // remove the initializer in the field's declaration:
- //
- // ```dart
- // class C {
- // final int f;
- // C() : f = 1;
- // }
- // ```
- static const CompileTimeErrorCode
- FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION = CompileTimeErrorCode(
- 'FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION',
- "Fields can't be initialized in the constructor if they are final "
- "and were already initialized at their declaration.",
- correction: "Try removing one of the initializations.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a field is initialized in both
- // the parameter list and in the initializer list of a constructor.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the field `f` is
- // initialized both by a field formal parameter and in the initializer list:
- //
- // ```dart
- // class C {
- // int f;
- //
- // C(this.f) : [!f!] = 0;
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the field should be initialized by the parameter, then remove the
- // initialization in the initializer list:
- //
- // ```dart
- // class C {
- // int f;
- //
- // C(this.f);
- // }
- // ```
- //
- // If the field should be initialized in the initializer list and the
- // parameter isn't needed, then remove the parameter:
- //
- // ```dart
- // class C {
- // int f;
- //
- // C() : f = 0;
- // }
- // ```
- //
- // If the field should be initialized in the initializer list and the
- // parameter is needed, then make it a normal parameter:
- //
- // ```dart
- // class C {
- // int f;
- //
- // C(int g) : f = g * 2;
- // }
- // ```
- static const CompileTimeErrorCode
- FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER = CompileTimeErrorCode(
- 'FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER',
- "Fields can't be initialized in both the parameter list and the "
- "initializers.",
- correction: "Try removing one of the initializations.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a factory constructor has a
- // field formal parameter. Factory constructors can't assign values to fields
- // because no instance is created; hence, there is no field to assign.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the factory constructor
- // uses a field formal parameter:
- //
- // ```dart
- // class C {
- // int? f;
- //
- // factory C([!this.f!]) => throw 0;
- // }
- // ```
- //
- // #### Common fixes
- //
- // Replace the field formal parameter with a normal parameter:
- //
- // ```dart
- // class C {
- // int? f;
- //
- // factory C(int f) => throw 0;
- // }
- // ```
- static const CompileTimeErrorCode FIELD_INITIALIZER_FACTORY_CONSTRUCTOR =
- CompileTimeErrorCode(
- 'FIELD_INITIALIZER_FACTORY_CONSTRUCTOR',
- "Initializing formal parameters can't be used in factory "
- "constructors.",
- correction: "Try using a normal parameter.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the type of the initializer expression
- * 1: the name of the type of the field
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the initializer list of a
- // constructor initializes a field to a value that isn't assignable to the
- // field.
- //
- // #### Example
- //
- // The following code produces this diagnostic because `0` has the type `int`,
- // and an `int` can't be assigned to a field of type `String`:
- //
- // ```dart
- // class C {
- // String s;
- //
- // C() : s = [!0!];
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the type of the field is correct, then change the value assigned to it
- // so that the value has a valid type:
- //
- // ```dart
- // class C {
- // String s;
- //
- // C() : s = '0';
- // }
- // ```
- //
- // If the type of the value is correct, then change the type of the field to
- // allow the assignment:
- //
- // ```dart
- // class C {
- // int s;
- //
- // C() : s = 0;
- // }
- // ```
- static const CompileTimeErrorCode FIELD_INITIALIZER_NOT_ASSIGNABLE =
- CompileTimeErrorCode(
- 'FIELD_INITIALIZER_NOT_ASSIGNABLE',
- "The initializer type '{0}' can't be assigned to the field type "
- "'{1}'.",
- hasPublishedDocs: true);
-
- /**
- * 7.6.1 Generative Constructors: It is a compile-time error if an
- * initializing formal is used by a function other than a non-redirecting
- * generative constructor.
- */
- static const CompileTimeErrorCode FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR =
- CompileTimeErrorCode('FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR',
- "Initializing formal parameters can only be used in constructors.",
- correction: "Try using a normal parameter.");
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a redirecting constructor
- // initializes a field in the object. This isn't allowed because the instance
- // that has the field hasn't been created at the point at which it should be
- // initialized.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the constructor
- // `C.zero`, which redirects to the constructor `C`, has a field formal
- // parameter that initializes the field `f`:
- //
- // ```dart
- // class C {
- // int f;
- //
- // C(this.f);
- //
- // C.zero([!this.f!]) : this(f);
- // }
- // ```
- //
- // The following code produces this diagnostic because the constructor
- // `C.zero`, which redirects to the constructor `C`, has an initializer that
- // initializes the field `f`:
- //
- // ```dart
- // class C {
- // int f;
- //
- // C(this.f);
- //
- // C.zero() : [!f = 0!], this(1);
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the initialization is done by a field formal parameter, then use a
- // normal parameter:
- //
- // ```dart
- // class C {
- // int f;
- //
- // C(this.f);
- //
- // C.zero(int f) : this(f);
- // }
- // ```
- //
- // If the initialization is done in an initializer, then remove the
- // initializer:
- //
- // ```dart
- // class C {
- // int f;
- //
- // C(this.f);
- //
- // C.zero() : this(0);
- // }
- // ```
- static const CompileTimeErrorCode FIELD_INITIALIZER_REDIRECTING_CONSTRUCTOR =
- CompileTimeErrorCode('FIELD_INITIALIZER_REDIRECTING_CONSTRUCTOR',
- "The redirecting constructor can't have a field initializer.",
- correction:
- "Try initializing the field in the constructor being redirected "
- "to.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the type of the field formal parameter
- * 1: the name of the type of the field
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the type of a field formal
- // parameter isn't assignable to the type of the field being initialized.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the field formal
- // parameter has the type `String`, but the type of the field is `int`. The
- // parameter must have a type that is a subtype of the field's type.
- //
- // ```dart
- // class C {
- // int f;
- //
- // C([!String this.f!]);
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the type of the field is incorrect, then change the type of the field to
- // match the type of the parameter, and consider removing the type from the
- // parameter:
- //
- // ```dart
- // class C {
- // String f;
- //
- // C(this.f);
- // }
- // ```
- //
- // If the type of the parameter is incorrect, then remove the type of the
- // parameter:
- //
- // ```dart
- // class C {
- // int f;
- //
- // C(this.f);
- // }
- // ```
- //
- // If the types of both the field and the parameter are correct, then use an
- // initializer rather than a field formal parameter to convert the parameter
- // value into a value of the correct type:
- //
- // ```dart
- // class C {
- // int f;
- //
- // C(String s) : f = int.parse(s);
- // }
- // ```
- static const CompileTimeErrorCode FIELD_INITIALIZING_FORMAL_NOT_ASSIGNABLE =
- CompileTimeErrorCode('FIELD_INITIALIZING_FORMAL_NOT_ASSIGNABLE',
- "The parameter type '{0}' is incompatible with the field type '{1}'.",
- correction: "Try changing or removing the parameter's type, or "
- "changing the field's type.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the field in question
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a final field is initialized
- // twice: once where it's declared and once by a constructor's parameter.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the field `f` is
- // initialized twice:
- //
- // ```dart
- // class C {
- // final int f = 0;
- //
- // C(this.[!f!]);
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the field should have the same value for all instances, then remove the
- // initialization in the parameter list:
- //
- // ```dart
- // class C {
- // final int f = 0;
- //
- // C();
- // }
- // ```
- //
- // If the field can have different values in different instances, then remove
- // the initialization in the declaration:
- //
- // ```dart
- // class C {
- // final int f;
- //
- // C(this.f);
- // }
- // ```
- static const CompileTimeErrorCode
- FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR = CompileTimeErrorCode(
- 'FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR',
- "'{0}' is final and was given a value when it was declared, "
- "so it can't be set to a new value.",
- correction: "Try removing one of the initializations.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the uninitialized final variable
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a final field or variable isn't
- // initialized.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `x` doesn't have an
- // initializer:
- //
- // ```dart
- // final [!x!];
- // ```
- //
- // #### Common fixes
- //
- // For variables and static fields, you can add an initializer:
- //
- // ```dart
- // final x = 0;
- // ```
- //
- // For instance fields, you can add an initializer as shown in the previous
- // example, or you can initialize the field in every constructor. You can
- // initialize the field by using a field formal parameter:
- //
- // ```dart
- // class C {
- // final int x;
- // C(this.x);
- // }
- // ```
- //
- // You can also initialize the field by using an initializer in the
- // constructor:
- //
- // ```dart
- // class C {
- // final int x;
- // C(int y) : x = y * 2;
- // }
- // ```
- static const CompileTimeErrorCode FINAL_NOT_INITIALIZED =
- CompileTimeErrorCode('FINAL_NOT_INITIALIZED',
- "The final variable '{0}' must be initialized.",
- // TODO(brianwilkerson) Split this error code so that we can suggest
- // initializing fields in constructors (FINAL_FIELD_NOT_INITIALIZED
- // and FINAL_VARIABLE_NOT_INITIALIZED).
- correction: "Try initializing the variable.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the uninitialized final variable
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a class defines one or more
- // final instance fields without initializers and has at least one constructor
- // that doesn't initialize those fields. All final instance fields must be
- // initialized when the instance is created, either by the field's initializer
- // or by the constructor.
- //
- // #### Examples
- //
- // The following code produces this diagnostic:
- //
- // ```dart
- // class C {
- // final String value;
- //
- // [!C!]();
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the value should be passed in to the constructor directly, then use a
- // field formal parameter to initialize the field `value`:
- //
- // ```dart
- // class C {
- // final String value;
- //
- // C(this.value);
- // }
- // ```
- //
- // If the value should be computed indirectly from a value provided by the
- // caller, then add a parameter and include an initializer:
- //
- // ```dart
- // class C {
- // final String value;
- //
- // C(Object o) : value = o.toString();
- // }
- // ```
- //
- // If the value of the field doesn't depend on values that can be passed to
- // the constructor, then add an initializer for the field as part of the field
- // declaration:
- //
- // ```dart
- // class C {
- // final String value = '';
- //
- // C();
- // }
- // ```
- //
- // If the value of the field doesn't depend on values that can be passed to
- // the constructor but different constructors need to initialize it to
- // different values, then add an initializer for the field in the initializer
- // list:
- //
- // ```dart
- // class C {
- // final String value;
- //
- // C() : value = '';
- //
- // C.named() : value = 'c';
- // }
- // ```
- //
- // However, if the value is the same for all instances, then consider using a
- // static field instead of an instance field:
- //
- // ```dart
- // class C {
- // static const String value = '';
- //
- // C();
- // }
- // ```
- static const CompileTimeErrorCode FINAL_NOT_INITIALIZED_CONSTRUCTOR_1 =
- CompileTimeErrorCode(
- 'FINAL_NOT_INITIALIZED_CONSTRUCTOR',
- "All final variables must be initialized, but '{0}' isn't.",
- correction: "Try adding an initializer for the field.",
- hasPublishedDocs: true,
- uniqueName: 'FINAL_NOT_INITIALIZED_CONSTRUCTOR_1',
- );
-
- /**
- * Parameters:
- * 0: the name of the uninitialized final variable
- * 1: the name of the uninitialized final variable
- */
- static const CompileTimeErrorCode FINAL_NOT_INITIALIZED_CONSTRUCTOR_2 =
- CompileTimeErrorCode(
- 'FINAL_NOT_INITIALIZED_CONSTRUCTOR',
- "All final variables must be initialized, but '{0}' and '{1}' "
- "aren't.",
- correction: "Try adding initializers for the fields.",
- hasPublishedDocs: true,
- uniqueName: 'FINAL_NOT_INITIALIZED_CONSTRUCTOR_2',
- );
-
- /**
- * Parameters:
- * 0: the name of the uninitialized final variable
- * 1: the name of the uninitialized final variable
- * 2: the number of additional not initialized variables that aren't listed
- */
- static const CompileTimeErrorCode FINAL_NOT_INITIALIZED_CONSTRUCTOR_3_PLUS =
- CompileTimeErrorCode(
- 'FINAL_NOT_INITIALIZED_CONSTRUCTOR',
- "All final variables must be initialized, but '{0}', '{1}', and {2} "
- "others aren't.",
- correction: "Try adding initializers for the fields.",
- hasPublishedDocs: true,
- uniqueName: 'FINAL_NOT_INITIALIZED_CONSTRUCTOR_3_PLUS',
- );
-
- /**
- * 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 "
- "type argument that can be assigned to '{2}'.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the type of the iterable expression.
- * 1: the sequence type -- Iterable for `for` or Stream for `await for`.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the expression following `in` in
- // a for-in loop has a type that isn't a subclass of `Iterable`.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `m` is a `Map`, and
- // `Map` isn't a subclass of `Iterable`:
- //
- // ```dart
- // void f(Map<String, String> m) {
- // for (String s in [!m!]) {
- // print(s);
- // }
- // }
- // ```
- //
- // #### Common fixes
- //
- // Replace the expression with one that produces an iterable value:
- //
- // ```dart
- // void f(Map<String, String> m) {
- // for (String s in m.values) {
- // print(s);
- // }
- // }
- // ```
- static const CompileTimeErrorCode FOR_IN_OF_INVALID_TYPE =
- CompileTimeErrorCode('FOR_IN_OF_INVALID_TYPE',
- "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 a 'const'.",
- correction: "Try removing the 'const' modifier from the variable, or "
- "use a different variable.",
- hasPublishedDocs: true);
-
- /**
- * It is a compile-time error if a generic function type is used as a bound
- * for a formal type parameter of a class or a function.
- */
- static const CompileTimeErrorCode GENERIC_FUNCTION_TYPE_CANNOT_BE_BOUND =
- CompileTimeErrorCode('GENERIC_FUNCTION_TYPE_CANNOT_BE_BOUND',
- "Generic function types can't be used as type parameter bounds",
- correction: "Try making the free variable in the function type part "
- "of the larger declaration signature");
-
- /**
- * It is a compile-time error if a generic function type is used as an actual
- * type argument.
- */
- static const CompileTimeErrorCode
- GENERIC_FUNCTION_TYPE_CANNOT_BE_TYPE_ARGUMENT = CompileTimeErrorCode(
- 'GENERIC_FUNCTION_TYPE_CANNOT_BE_TYPE_ARGUMENT',
- "A generic function type can't be a type argument.",
- correction: "Try removing type parameters from the generic function "
- "type, or using 'dynamic' as the type argument here.");
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an instance method is being torn
- // off from a receiver whose type is `dynamic`, and the tear-off includes type
- // arguments. Because the analyzer can't know how many type parameters the
- // method has, or whether it has any type parameters, there's no way it can
- // validate that the type arguments are correct. As a result, the type
- // arguments aren't allowed.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the type of `p` is
- // `dynamic` and the tear-off of `m` has type arguments:
- //
- // ```dart
- // void f(dynamic list) {
- // [!list.fold!]<int>;
- // }
- // ```
- //
- // #### Common fixes
- //
- // If you can use a more specific type than `dynamic`, then change the type of
- // the receiver:
- //
- // ```dart
- // void f(List<Object> list) {
- // list.fold<int>;
- // }
- // ```
- //
- // If you can't use a more specific type, then remove the type arguments:
- //
- // ```dart
- // void f(dynamic list) {
- // list.cast;
- // }
- // ```
- static const CompileTimeErrorCode
- GENERIC_METHOD_TYPE_INSTANTIATION_ON_DYNAMIC = CompileTimeErrorCode(
- 'GENERIC_METHOD_TYPE_INSTANTIATION_ON_DYNAMIC',
- "A method tear-off on a receiver whose type is 'dynamic' can't have type "
- "arguments.",
- correction:
- "Specify the type of the receiver, or remove the type arguments from "
- "the method tear-off.",
- );
-
- /**
- * Parameters:
- * 0: the name of the getter
- * 1: the type of the getter
- * 2: the type of the setter
- * 3: the name of the setter
- */
- static const CompileTimeErrorCode GETTER_NOT_ASSIGNABLE_SETTER_TYPES =
- CompileTimeErrorCode(
- 'GETTER_NOT_ASSIGNABLE_SETTER_TYPES',
- "The return type of getter '{0}' is '{1}' which isn't assignable "
- "to the type '{2}' of its setter '{3}'.",
- correction: "Try changing the types so that they are compatible.");
-
- /**
- * Parameters:
- * 0: the name of the getter
- * 1: the type of the getter
- * 2: the type of the setter
- * 3: the name of the setter
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the return type of a getter
- // isn't a subtype of the type of the parameter of a setter with the same
- // name.
- //
- // The subtype relationship is a requirement whether the getter and setter are
- // in the same class or whether one of them is in a superclass of the other.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the return type of the
- // getter `x` is `num`, the parameter type of the setter `x` is `int`, and
- // `num` isn't a subtype of `int`:
- //
- // ```dart
- // class C {
- // num get [!x!] => 0;
- //
- // set x(int y) {}
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the type of the getter is correct, then change the type of the setter:
- //
- // ```dart
- // class C {
- // num get x => 0;
- //
- // set x(num y) {}
- // }
- // ```
- //
- // If the type of the setter is correct, then change the type of the getter:
- //
- // ```dart
- // class C {
- // int get x => 0;
- //
- // set x(int y) {}
- // }
- // ```
- static const CompileTimeErrorCode GETTER_NOT_SUBTYPE_SETTER_TYPES =
- CompileTimeErrorCode(
- 'GETTER_NOT_SUBTYPE_SETTER_TYPES',
- "The return type of getter '{0}' is '{1}' which isn't a subtype "
- "of the type '{2}' of its setter '{3}'.",
- correction: "Try changing the types so that they are compatible.",
- hasPublishedDocs: true);
-
- static const CompileTimeErrorCode IF_ELEMENT_CONDITION_FROM_DEFERRED_LIBRARY =
- CompileTimeErrorCode(
- 'IF_ELEMENT_CONDITION_FROM_DEFERRED_LIBRARY',
- "Constant values from a deferred library can't be used as values in "
- "an if condition inside a const collection literal.",
- correction: "Try making the deferred import non-deferred.");
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the body of a function has the
- // `async*` modifier even though the return type of the function isn't either
- // `Stream` or a supertype of `Stream`.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the body of the
- // function `f` has the 'async*' modifier even though the return type `int`
- // isn't a supertype of `Stream`:
- //
- // ```dart
- // [!int!] f() async* {}
- // ```
- //
- // #### Common fixes
- //
- // If the function should be asynchronous, then change the return type to be
- // either `Stream` or a supertype of `Stream`:
- //
- // ```dart
- // Stream<int> f() async* {}
- // ```
- //
- // If the function should be synchronous, then remove the `async*` modifier:
- //
- // ```dart
- // int f() => 0;
- // ```
- static const CompileTimeErrorCode ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE =
- CompileTimeErrorCode(
- 'ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE',
- "Functions marked 'async*' must have a return type that is a "
- "supertype of 'Stream<T>' for some type 'T'.",
- correction: "Try fixing the return type of the function, or "
- "removing the modifier 'async*' from the function body.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the body of a function has the
- // `async` modifier even though the return type of the function isn't
- // assignable to `Future`.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the body of the
- // function `f` has the `async` modifier even though the return type isn't
- // assignable to `Future`:
- //
- // ```dart
- // [!int!] f() async {
- // return 0;
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the function should be asynchronous, then change the return type to be
- // assignable to `Future`:
- //
- // ```dart
- // Future<int> f() async {
- // return 0;
- // }
- // ```
- //
- // If the function should be synchronous, then remove the `async` modifier:
- //
- // ```dart
- // int f() => 0;
- // ```
- static const CompileTimeErrorCode ILLEGAL_ASYNC_RETURN_TYPE =
- CompileTimeErrorCode(
- 'ILLEGAL_ASYNC_RETURN_TYPE',
- "Functions marked 'async' must have a return type assignable to "
- "'Future'.",
- correction: "Try fixing the return type of the function, or "
- "removing the modifier 'async' from the function body.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the body of a function has the
- // `sync*` modifier even though the return type of the function isn't either
- // `Iterable` or a supertype of `Iterable`.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the body of the
- // function `f` has the 'sync*' modifier even though the return type `int`
- // isn't a supertype of `Iterable`:
- //
- // ```dart
- // [!int!] f() sync* {}
- // ```
- //
- // #### Common fixes
- //
- // If the function should return an iterable, then change the return type to
- // be either `Iterable` or a supertype of `Iterable`:
- //
- // ```dart
- // Iterable<int> f() sync* {}
- // ```
- //
- // If the function should return a single value, then remove the `sync*`
- // modifier:
- //
- // ```dart
- // int f() => 0;
- // ```
- static const CompileTimeErrorCode ILLEGAL_SYNC_GENERATOR_RETURN_TYPE =
- CompileTimeErrorCode(
- 'ILLEGAL_SYNC_GENERATOR_RETURN_TYPE',
- "Functions marked 'sync*' must have a return type that is a "
- "supertype of 'Iterable<T>' for some type 'T'.",
- correction: "Try fixing the return type of the function, or "
- "removing the modifier 'sync*' from the function body.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- static const CompileTimeErrorCode IMPLEMENTS_DEFERRED_CLASS =
- CompileTimeErrorCode('SUBTYPE_OF_DEFERRED_CLASS',
- "Classes and mixins can't implement deferred classes.",
- correction: "Try specifying a different interface, "
- "removing the class from the list, or "
- "changing the import to not be deferred.",
- hasPublishedDocs: true,
- uniqueName: 'IMPLEMENTS_DEFERRED_CLASS');
-
- /**
- * Parameters:
- * 0: the name of the disallowed type
- */
- static const CompileTimeErrorCode IMPLEMENTS_DISALLOWED_CLASS =
- CompileTimeErrorCode(
- 'SUBTYPE_OF_DISALLOWED_TYPE',
- "Classes and mixins can't implement '{0}'.",
- correction: "Try specifying a different interface, or "
- "remove the class from the list.",
- hasPublishedDocs: true,
- uniqueName: 'IMPLEMENTS_DISALLOWED_CLASS',
- );
-
- /**
- * Parameters:
- * 0: the name of the interface that was not found
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a name used in the `implements`
- // clause of a class or mixin declaration is defined to be something other
- // than a class or mixin.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `x` is a variable
- // rather than a class or mixin:
- //
- // ```dart
- // var x;
- // class C implements [!x!] {}
- // ```
- //
- // #### Common fixes
- //
- // If the name is the name of an existing class or mixin that's already being
- // imported, then add a prefix to the import so that the local definition of
- // the name doesn't shadow the imported name.
- //
- // If the name is the name of an existing class or mixin that isn't being
- // imported, then add an import, with a prefix, for the library in which it’s
- // declared.
- //
- // Otherwise, either replace the name in the `implements` clause with the name
- // of an existing class or mixin, or remove the name from the `implements`
- // clause.
- static const CompileTimeErrorCode IMPLEMENTS_NON_CLASS = CompileTimeErrorCode(
- 'IMPLEMENTS_NON_CLASS',
- "Classes and mixins can only implement other classes and mixins.",
- correction:
- "Try specifying a class or mixin, or remove the name from the "
- "list.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the interface that is implemented more than once
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a single class is specified more
- // than once in an `implements` clause.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `A` is in the list
- // twice:
- //
- // ```dart
- // class A {}
- // class B implements A, [!A!] {}
- // ```
- //
- // #### Common fixes
- //
- // Remove all except one occurrence of the class name:
- //
- // ```dart
- // class A {}
- // class B implements A {}
- // ```
- static const CompileTimeErrorCode IMPLEMENTS_REPEATED = CompileTimeErrorCode(
- 'IMPLEMENTS_REPEATED', "'{0}' can only be implemented once.",
- correction: "Try removing all but one occurrence of the class name.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the class that appears in both "extends" and "implements"
- * clauses
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when one class is listed in both the
- // `extends` and `implements` clauses of another class.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the class `A` is used
- // in both the `extends` and `implements` clauses for the class `B`:
- //
- // ```dart
- // class A {}
- //
- // class B extends A implements [!A!] {}
- // ```
- //
- // #### Common fixes
- //
- // If you want to inherit the implementation from the class, then remove the
- // class from the `implements` clause:
- //
- // ```dart
- // class A {}
- //
- // class B extends A {}
- // ```
- //
- // If you don't want to inherit the implementation from the class, then remove
- // the `extends` clause:
- //
- // ```dart
- // class A {}
- //
- // class B implements A {}
- // ```
- static const CompileTimeErrorCode IMPLEMENTS_SUPER_CLASS =
- CompileTimeErrorCode('IMPLEMENTS_SUPER_CLASS',
- "'{0}' can't be used in both the 'extends' and 'implements' clauses.",
- correction: "Try removing one of the occurrences.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- static const CompileTimeErrorCode
- IMPLEMENTS_TYPE_ALIAS_EXPANDS_TO_TYPE_PARAMETER = CompileTimeErrorCode(
- 'SUPERTYPE_EXPANDS_TO_TYPE_PARAMETER',
- "A type alias that expands to a type parameter can't be implemented.",
- correction: "Try specifying a class or mixin, or removing the list.",
- hasPublishedDocs: true,
- uniqueName: 'IMPLEMENTS_TYPE_ALIAS_EXPANDS_TO_TYPE_PARAMETER');
-
- /**
- * Parameters:
- * 0: the name of the instance member
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when it finds a reference to an
- // instance member in a constructor's initializer list.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `defaultX` is an
- // instance member:
- //
- // ```dart
- // class C {
- // int x;
- //
- // C() : x = [!defaultX!];
- //
- // int get defaultX => 0;
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the member can be made static, then do so:
- //
- // ```dart
- // class C {
- // int x;
- //
- // C() : x = defaultX;
- //
- // static int get defaultX => 0;
- // }
- // ```
- //
- // If not, then replace the reference in the initializer with a different
- // expression that doesn't use an instance member:
- //
- // ```dart
- // class C {
- // int x;
- //
- // C() : x = 0;
- //
- // int get defaultX => 0;
- // }
- // ```
- static const CompileTimeErrorCode IMPLICIT_THIS_REFERENCE_IN_INITIALIZER =
- CompileTimeErrorCode('IMPLICIT_THIS_REFERENCE_IN_INITIALIZER',
- "The instance member '{0}' can't be accessed in an initializer.",
- correction:
- 'Try replacing the reference to the instance member with a '
- 'different expression',
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the uri pointing to a library
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when it finds an import whose `dart:`
- // URI references an internal library.
- //
- // #### Example
- //
- // The following code produces this diagnostic because `_interceptors` is an
- // internal library:
- //
- // ```dart
- // import [!'dart:_interceptors'!];
- // ```
- //
- // #### Common fixes
- //
- // Remove the import directive.
- static const CompileTimeErrorCode IMPORT_INTERNAL_LIBRARY =
- CompileTimeErrorCode('IMPORT_INTERNAL_LIBRARY',
- "The library '{0}' is internal and can't be imported.",
- hasPublishedDocs: true);
-
- /**
- * 14.1 Imports: It is a compile-time error if the specified URI of an
- * immediate import does not refer to a library declaration.
- *
- * Parameters:
- * 0: the uri pointing to a non-library declaration
- */
- static const CompileTimeErrorCode IMPORT_OF_NON_LIBRARY =
- CompileTimeErrorCode('IMPORT_OF_NON_LIBRARY',
- "The imported library '{0}' can't have a part-of directive.",
- correction: "Try importing the library that the part is a part of.");
-
- /**
- * 13.9 Switch: It is a compile-time error if values of the expressions
- * <i>e<sub>k</sub></i> are not instances of the same class <i>C</i>, for all
- * <i>1 <= k <= n</i>.
- *
- * Parameters:
- * 0: the expression source code that is the unexpected type
- * 1: the name of the expected type
- */
- static const CompileTimeErrorCode INCONSISTENT_CASE_EXPRESSION_TYPES =
- CompileTimeErrorCode('INCONSISTENT_CASE_EXPRESSION_TYPES',
- "Case expressions must have the same types, '{0}' isn't a '{1}'.");
-
- /**
- * Parameters:
- * 0: the name of the instance member with inconsistent inheritance.
- * 1: the list of all inherited signatures for this member.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a class inherits two or more
- // conflicting signatures for a member and doesn't provide an implementation
- // that satisfies all the inherited signatures.
- //
- // #### Example
- //
- // The following code produces this diagnostic because `C` is inheriting the
- // declaration of `m` from `A`, and that implementation isn't consistent with
- // the signature of `m` that's inherited from `B`:
- //
- // ```dart
- // %language=2.9
- // class A {
- // void m({int a}) {}
- // }
- //
- // class B {
- // void m({int b}) {}
- // }
- //
- // class [!C!] extends A implements B {
- // }
- // ```
- //
- // #### Common fixes
- //
- // Add an implementation of the method that satisfies all the inherited
- // signatures:
- //
- // ```dart
- // %language=2.9
- // class A {
- // void m({int a}) {}
- // }
- //
- // class B {
- // void m({int b}) {}
- // }
- //
- // class C extends A implements B {
- // void m({int a, int b}) {}
- // }
- // ```
- static const CompileTimeErrorCode INCONSISTENT_INHERITANCE =
- CompileTimeErrorCode('INCONSISTENT_INHERITANCE',
- "Superinterfaces don't have a valid override for '{0}': {1}.",
- correction:
- "Try adding an explicit override that is consistent with all "
- "of the inherited members.",
- hasPublishedDocs: true);
-
- /**
- * 11.1.1 Inheritance and Overriding. Let `I` be the implicit interface of a
- * class `C` declared in library `L`. `I` inherits all members of
- * `inherited(I, L)` and `I` overrides `m'` if `m' ∈ overrides(I, L)`. It is
- * a compile-time error if `m` is a method and `m'` is a getter, or if `m`
- * is a getter and `m'` is a method.
- *
- * Parameters:
- * 0: the name of the the instance member with inconsistent inheritance.
- * 1: the name of the superinterface that declares the name as a getter.
- * 2: the name of the superinterface that declares the name as a method.
- */
- static const CompileTimeErrorCode INCONSISTENT_INHERITANCE_GETTER_AND_METHOD =
- CompileTimeErrorCode(
- 'INCONSISTENT_INHERITANCE_GETTER_AND_METHOD',
- "'{0}' is inherited as a getter (from '{1}') and also a "
- "method (from '{2}').",
- correction:
- "Try adjusting the supertypes of this class to remove the "
- "inconsistency.");
-
- /**
- * It is a compile-time error if a part file has a different language version
- * override than its library.
- *
- * https://github.com/dart-lang/language/blob/master/accepted/
- * future-releases/language-versioning/feature-specification.md
- * #individual-library-language-version-override
- */
- static const CompileTimeErrorCode INCONSISTENT_LANGUAGE_VERSION_OVERRIDE =
- CompileTimeErrorCode(
- 'INCONSISTENT_LANGUAGE_VERSION_OVERRIDE',
- "Parts must have exactly the same language version override as "
- "the library.");
-
- /**
- * Parameters:
- * 0: the name of the initializing formal that is not an instance variable in
- * the immediately enclosing class
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a constructor initializes a
- // field that isn't declared in the class containing the constructor.
- // Constructors can't initialize fields that aren't declared and fields that
- // are inherited from superclasses.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because the initializer is
- // initializing `x`, but `x` isn't a field in the class:
- //
- // ```dart
- // %language=2.9
- // class C {
- // int y;
- //
- // C() : [!x = 0!];
- // }
- // ```
- //
- // #### Common fixes
- //
- // If a different field should be initialized, then change the name to the
- // name of the field:
- //
- // ```dart
- // %language=2.9
- // class C {
- // int y;
- //
- // C() : y = 0;
- // }
- // ```
- //
- // If the field must be declared, then add a declaration:
- //
- // ```dart
- // %language=2.9
- // class C {
- // int x;
- // int y;
- //
- // C() : x = 0;
- // }
- // ```
- static const CompileTimeErrorCode INITIALIZER_FOR_NON_EXISTENT_FIELD =
- CompileTimeErrorCode('INITIALIZER_FOR_NON_EXISTENT_FIELD',
- "'{0}' isn't a field in the enclosing class.",
- correction: "Try correcting the name to match an existing field, or "
- "defining a field named '{0}'.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the initializing formal that is a static variable in the
- * immediately enclosing class
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a static field is initialized in
- // a constructor using either a field formal parameter or an assignment in the
- // initializer list.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the static field `a` is
- // being initialized by the field formal parameter `this.a`:
- //
- // ```dart
- // class C {
- // static int? a;
- // C([!this.a!]);
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the field should be an instance field, then remove the keyword `static`:
- //
- // ```dart
- // class C {
- // int? a;
- // C(this.a);
- // }
- // ```
- //
- // If you intended to initialize an instance field and typed the wrong name,
- // then correct the name of the field being initialized:
- //
- // ```dart
- // class C {
- // static int? a;
- // int? b;
- // C(this.b);
- // }
- // ```
- //
- // If you really want to initialize the static field, then move the
- // initialization into the constructor body:
- //
- // ```dart
- // class C {
- // static int? a;
- // C(int? c) {
- // a = c;
- // }
- // }
- // ```
- static const CompileTimeErrorCode INITIALIZER_FOR_STATIC_FIELD =
- CompileTimeErrorCode(
- 'INITIALIZER_FOR_STATIC_FIELD',
- "'{0}' is a static field in the enclosing class. Fields initialized "
- "in a constructor can't be static.",
- correction: "Try removing the initialization.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the initializing formal that is not an instance variable in
- * the immediately enclosing class
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a field formal parameter is
- // found in a constructor in a class that doesn't declare the field being
- // initialized. Constructors can't initialize fields that aren't declared and
- // fields that are inherited from superclasses.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because the field `x` isn't
- // defined:
- //
- // ```dart
- // %language=2.9
- // class C {
- // int y;
- //
- // C([!this.x!]);
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the field name was wrong, then change it to the name of an existing
- // field:
- //
- // ```dart
- // %language=2.9
- // class C {
- // int y;
- //
- // C(this.y);
- // }
- // ```
- //
- // If the field name is correct but hasn't yet been defined, then declare the
- // field:
- //
- // ```dart
- // %language=2.9
- // class C {
- // int x;
- // int y;
- //
- // C(this.x);
- // }
- // ```
- //
- // If the parameter is needed but shouldn't initialize a field, then convert
- // it to a normal parameter and use it:
- //
- // ```dart
- // %language=2.9
- // class C {
- // int y;
- //
- // C(int x) : y = x * 2;
- // }
- // ```
- //
- // If the parameter isn't needed, then remove it:
- //
- // ```dart
- // %language=2.9
- // class C {
- // int y;
- //
- // C();
- // }
- // ```
- static const CompileTimeErrorCode INITIALIZING_FORMAL_FOR_NON_EXISTENT_FIELD =
- CompileTimeErrorCode('INITIALIZING_FORMAL_FOR_NON_EXISTENT_FIELD',
- "'{0}' isn't a field in the enclosing class.",
- correction: "Try correcting the name to match an existing field, or "
- "defining a field named '{0}'.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the static member
- * 1: the kind of the static member (field, getter, setter, or method)
- * 2: the name of the defining class
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an access operator is used to
- // access a static member through an instance of the class.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `zero` is a static
- // field, but it’s being accessed as if it were an instance field:
- //
- // ```dart
- // void f(C c) {
- // c.[!zero!];
- // }
- //
- // class C {
- // static int zero = 0;
- // }
- // ```
- //
- // #### Common fixes
- //
- // Use the class to access the static member:
- //
- // ```dart
- // void f(C c) {
- // C.zero;
- // }
- //
- // class C {
- // static int zero = 0;
- // }
- // ```
- static const CompileTimeErrorCode INSTANCE_ACCESS_TO_STATIC_MEMBER =
- CompileTimeErrorCode('INSTANCE_ACCESS_TO_STATIC_MEMBER',
- "Static {1} '{0}' can't be accessed through an instance.",
- correction: "Try using the class '{2}' to access the {1}.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a factory constructor contains
- // an unqualified reference to an instance member. In a generative
- // constructor, the instance of the class is created and initialized before
- // the body of the constructor is executed, so the instance can be bound to
- // `this` and accessed just like it would be in an instance method. But, in a
- // factory constructor, the instance isn't created before executing the body,
- // so `this` can't be used to reference it.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `x` isn't in scope in
- // the factory constructor:
- //
- // ```dart
- // class C {
- // int x;
- // factory C() {
- // return C._([!x!]);
- // }
- // C._(this.x);
- // }
- // ```
- //
- // #### Common fixes
- //
- // Rewrite the code so that it doesn't reference the instance member:
- //
- // ```dart
- // class C {
- // int x;
- // factory C() {
- // return C._(0);
- // }
- // C._(this.x);
- // }
- // ```
- static const CompileTimeErrorCode INSTANCE_MEMBER_ACCESS_FROM_FACTORY =
- CompileTimeErrorCode('INSTANCE_MEMBER_ACCESS_FROM_FACTORY',
- "Instance members can't be accessed from a factory constructor.",
- correction: "Try removing the reference to the instance member.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a static method contains an
- // unqualified reference to an instance member.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because the instance field `x`
- // is being referenced in a static method:
- //
- // ```dart
- // %language=2.9
- // class C {
- // int x;
- //
- // static int m() {
- // return [!x!];
- // }
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the method must reference the instance member, then it can't be static,
- // so remove the keyword:
- //
- // ```dart
- // %language=2.9
- // class C {
- // int x;
- //
- // int m() {
- // return x;
- // }
- // }
- // ```
- //
- // If the method can't be made an instance method, then add a parameter so
- // that an instance of the class can be passed in:
- //
- // ```dart
- // %language=2.9
- // class C {
- // int x;
- //
- // static int m(C c) {
- // return c.x;
- // }
- // }
- // ```
- static const CompileTimeErrorCode INSTANCE_MEMBER_ACCESS_FROM_STATIC =
- CompileTimeErrorCode('INSTANCE_MEMBER_ACCESS_FROM_STATIC',
- "Instance members can't be accessed from a static method.",
- correction: "Try removing the reference to the instance member, or "
- "removing the keyword 'static' from the method.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when it finds a constructor
- // invocation and the constructor is declared in an abstract class. Even
- // though you can't create an instance of an abstract class, abstract classes
- // can declare constructors that can be invoked by subclasses.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `C` is an abstract
- // class:
- //
- // ```dart
- // abstract class C {}
- //
- // var c = new [!C!]();
- // ```
- //
- // #### Common fixes
- //
- // If there's a concrete subclass of the abstract class that can be used, then
- // create an instance of the concrete subclass.
- static const CompileTimeErrorCode INSTANTIATE_ABSTRACT_CLASS =
- CompileTimeErrorCode('INSTANTIATE_ABSTRACT_CLASS',
- "Abstract classes can't be instantiated.",
- correction: "Try creating an instance of a concrete subtype.",
- hasPublishedDocs: true);
-
- /**
- * 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.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a constructor invocation is
- // found where the type being instantiated is a type alias for one of the type
- // parameters of the type alias. This isn’t allowed because the value of the
- // type parameter is a type rather than a class.
- //
- // #### Example
- //
- // The following code produces this diagnostic because it creates an instance
- // of `A`, even though `A` is a type alias that is defined to be equivalent to
- // a type parameter:
- //
- // ```dart
- // typedef A<T> = T;
- //
- // void f() {
- // const [!A!]<int>();
- // }
- // ```
- //
- // #### Common fixes
- //
- // Use either a class name or a type alias defined to be a class, rather than
- // a type alias defined to be a type parameter:
- //
- // ```dart
- // typedef A<T> = C<T>;
- //
- // void f() {
- // const A<int>();
- // }
- //
- // class C<T> {
- // const C();
- // }
- // ```
- static const CompileTimeErrorCode
- INSTANTIATE_TYPE_ALIAS_EXPANDS_TO_TYPE_PARAMETER = CompileTimeErrorCode(
- 'INSTANTIATE_TYPE_ALIAS_EXPANDS_TO_TYPE_PARAMETER',
- "Type aliases that expand to a type parameter can't be instantiated.",
- correction: "Try replacing it with a class.");
-
- /**
- * Parameters:
- * 0: the lexeme of the integer
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an integer literal is being
- // implicitly converted to a double, but can't be represented as a 64-bit
- // double without overflow or loss of precision. Integer literals are
- // implicitly converted to a double if the context requires the type `double`.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the integer value
- // `9223372036854775807` can't be represented exactly as a double:
- //
- // ```dart
- // double x = [!9223372036854775807!];
- // ```
- //
- // #### Common fixes
- //
- // If you need to use the exact value, then use the class `BigInt` to
- // represent the value:
- //
- // ```dart
- // var x = BigInt.parse('9223372036854775807');
- // ```
- //
- // If you need to use a double, then change the value to one that can be
- // represented exactly:
- //
- // ```dart
- // double x = 9223372036854775808;
- // ```
- static const CompileTimeErrorCode INTEGER_LITERAL_IMPRECISE_AS_DOUBLE =
- CompileTimeErrorCode(
- 'INTEGER_LITERAL_IMPRECISE_AS_DOUBLE',
- "The integer literal is being used as a double, but can't be "
- "represented as a 64-bit double without overflow or loss of "
- "precision: '{0}'.",
- correction:
- "Try using the class 'BigInt', or switch to the closest valid "
- "double: '{1}'.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an integer literal has a value
- // that is too large (positive) or too small (negative) to be represented in a
- // 64-bit word.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the value can't be
- // represented in 64 bits:
- //
- // ```dart
- // var x = [!9223372036854775810!];
- // ```
- //
- // #### Common fixes
- //
- // If you need to represent the current value, then wrap it in an instance of
- // the class `BigInt`:
- //
- // ```dart
- // var x = BigInt.parse('9223372036854775810');
- // ```
- static const CompileTimeErrorCode INTEGER_LITERAL_OUT_OF_RANGE =
- CompileTimeErrorCode('INTEGER_LITERAL_OUT_OF_RANGE',
- "The integer literal {0} can't be represented in 64 bits.",
- correction:
- "Try using the 'BigInt' class if you need an integer larger than "
- "9,223,372,036,854,775,807 or less than "
- "-9,223,372,036,854,775,808.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an annotation is found that is
- // using something that is neither a variable marked as `const` or the
- // invocation of a `const` constructor.
- //
- // Getters can't be used as annotations.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the variable `v` isn't
- // a `const` variable:
- //
- // ```dart
- // var v = 0;
- //
- // [!@v!]
- // void f() {
- // }
- // ```
- //
- // The following code produces this diagnostic because `f` isn't a variable:
- //
- // ```dart
- // [!@f!]
- // void f() {
- // }
- // ```
- //
- // The following code produces this diagnostic because `f` isn't a
- // constructor:
- //
- // ```dart
- // [!@f()!]
- // void f() {
- // }
- // ```
- //
- // The following code produces this diagnostic because `g` is a getter:
- //
- // ```dart
- // [!@g!]
- // int get g => 0;
- // ```
- //
- // #### Common fixes
- //
- // If the annotation is referencing a variable that isn't a `const`
- // constructor, add the keyword `const` to the variable's declaration:
- //
- // ```dart
- // const v = 0;
- //
- // @v
- // void f() {
- // }
- // ```
- //
- // If the annotation isn't referencing a variable, then remove it:
- //
- // ```dart
- // int v = 0;
- //
- // void f() {
- // }
- // ```
- static const CompileTimeErrorCode INVALID_ANNOTATION = CompileTimeErrorCode(
- 'INVALID_ANNOTATION',
- "Annotation must be either a const variable reference or const "
- "constructor invocation.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a constant defined in a library
- // that is imported as a deferred library is referenced in the argument list
- // of an annotation. Annotations 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 constant `pi` is
- // being referenced in the argument list of an annotation, even though the
- // library that defines it is being imported as a deferred library:
- //
- // ```dart
- // import 'dart:math' deferred as math;
- //
- // class C {
- // const C(double d);
- // }
- //
- // @C([!math.pi!])
- // void f () {}
- // ```
- //
- // #### Common fixes
- //
- // If you need to reference the imported constant, then remove the `deferred`
- // keyword:
- //
- // ```dart
- // import 'dart:math' as math;
- //
- // class C {
- // const C(double d);
- // }
- //
- // @C(math.pi)
- // void f () {}
- // ```
- //
- // If the import is required to be deferred and there's another constant that
- // is appropriate, then use that constant in place of the constant from the
- // deferred library.
- static const CompileTimeErrorCode
- INVALID_ANNOTATION_CONSTANT_VALUE_FROM_DEFERRED_LIBRARY =
- CompileTimeErrorCode(
- 'INVALID_ANNOTATION_CONSTANT_VALUE_FROM_DEFERRED_LIBRARY',
- "Constant values from a deferred library can't be used in annotations.",
- correction: "Try moving the constant from the deferred library,"
- " or removing 'deferred' from the import.");
-
- /**
- * 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',
- "Constant values from a deferred library can't be used as "
- "annotations.",
- correction: "Try removing the annotation, or "
- "changing the import to not be deferred.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the right hand side type
- * 1: the name of the left hand side type
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the static type of an expression
- // that is assigned to a variable isn't assignable to the type of the
- // variable.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because the type of the
- // initializer (`int`) isn't assignable to the type of the variable
- // (`String`):
- //
- // ```dart
- // int i = 0;
- // String s = [!i!];
- // ```
- //
- // #### Common fixes
- //
- // If the value being assigned is always assignable at runtime, even though
- // the static types don't reflect that, then add an explicit cast.
- //
- // Otherwise, change the value being assigned so that it has the expected
- // type. In the previous example, this might look like:
- //
- // ```dart
- // int i = 0;
- // String s = i.toString();
- // ```
- //
- // If you can’t change the value, then change the type of the variable to be
- // compatible with the type of the value being assigned:
- //
- // ```dart
- // int i = 0;
- // int s = i;
- // ```
- static const CompileTimeErrorCode INVALID_ASSIGNMENT = CompileTimeErrorCode(
- 'INVALID_ASSIGNMENT',
- "A value of type '{0}' can't be assigned to a variable of type "
- "'{1}'.",
- correction: "Try changing the type of the variable, or "
- "casting the right-hand type to '{1}'.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the type of the function
- * 1: the expected function type
- */
- static const CompileTimeErrorCode INVALID_CAST_FUNCTION = CompileTimeErrorCode(
- 'INVALID_CAST_FUNCTION',
- "The function '{0}' has type '{1}' that isn't of expected type "
- "'{2}'. This means its parameter or return type doesn't match what "
- "is expected.");
-
- /**
- * Parameters:
- * 0: the type of the torn-off function expression
- * 1: the expected function type
- */
- static const CompileTimeErrorCode INVALID_CAST_FUNCTION_EXPR =
- CompileTimeErrorCode(
- 'INVALID_CAST_FUNCTION_EXPR',
- "The function expression type '{0}' isn't of type '{1}'. "
- "This means its parameter or return type doesn't match what is "
- "expected. Consider changing parameter type(s) or the returned "
- "type(s).");
-
- /**
- * Parameters:
- * 0: the type of the literal
- * 1: the expected type
- */
- static const CompileTimeErrorCode INVALID_CAST_LITERAL = CompileTimeErrorCode(
- 'INVALID_CAST_LITERAL',
- "The literal '{0}' with type '{1}' isn't of expected type '{2}'.");
-
- /**
- * Parameters:
- * 0: the type of the list literal
- * 1: the expected type
- */
- static const CompileTimeErrorCode INVALID_CAST_LITERAL_LIST =
- CompileTimeErrorCode(
- 'INVALID_CAST_LITERAL_LIST',
- "The list literal type '{0}' isn't of expected type '{1}'. The "
- "list's type can be changed with an explicit generic type "
- "argument or by changing the element types.");
-
- /**
- * Parameters:
- * 0: the type of the map literal
- * 1: the expected type
- */
- static const CompileTimeErrorCode INVALID_CAST_LITERAL_MAP =
- CompileTimeErrorCode(
- 'INVALID_CAST_LITERAL_MAP',
- "The map literal type '{0}' isn't of expected type '{1}'. The maps's "
- "type can be changed with an explicit generic type arguments or "
- "by changing the key and value types.");
-
- /**
- * Parameters:
- * 0: the type of the set literal
- * 1: the expected type
- */
- static const CompileTimeErrorCode INVALID_CAST_LITERAL_SET =
- CompileTimeErrorCode(
- 'INVALID_CAST_LITERAL_SET',
- "The set literal type '{0}' isn't of expected type '{1}'. The set's "
- "type can be changed with an explicit generic type argument or "
- "by changing the element types.");
-
- /**
- * Parameters:
- * 0: the type of the torn-off method
- * 1: the expected function type
- */
- static const CompileTimeErrorCode INVALID_CAST_METHOD = CompileTimeErrorCode(
- 'INVALID_CAST_METHOD',
- "The method tear-off '{0}' has type '{1}' that isn't of expected type "
- "'{2}'. This means its parameter or return type doesn't match what "
- "is expected.");
-
- /**
- * Parameters:
- * 0: the type of the instantiated object
- * 1: the expected type
- */
- static const CompileTimeErrorCode INVALID_CAST_NEW_EXPR = CompileTimeErrorCode(
- 'INVALID_CAST_NEW_EXPR',
- "The constructor returns type '{0}' that isn't of expected type '{1}'.");
-
- /**
- * TODO(brianwilkerson) Remove this when we have decided on how to report
- * errors in compile-time constants. Until then, this acts as a placeholder
- * for more informative errors.
- *
- * See TODOs in ConstantVisitor
- */
- static const CompileTimeErrorCode INVALID_CONSTANT =
- CompileTimeErrorCode('INVALID_CONSTANT', "Invalid constant value.");
-
- /**
- * 7.6 Constructors: It is a compile-time error if the name of a constructor
- * is not a constructor name.
- */
- static const CompileTimeErrorCode INVALID_CONSTRUCTOR_NAME =
- CompileTimeErrorCode(
- 'INVALID_CONSTRUCTOR_NAME', "Invalid constructor name.");
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an extension override doesn't
- // have exactly one argument. The argument is the expression used to compute
- // the value of `this` within the extension method, so there must be one
- // argument.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because there are no arguments:
- //
- // ```dart
- // extension E on String {
- // String join(String other) => '$this $other';
- // }
- //
- // void f() {
- // E[!()!].join('b');
- // }
- // ```
- //
- // And, the following code produces this diagnostic because there's more than
- // one argument:
- //
- // ```dart
- // extension E on String {
- // String join(String other) => '$this $other';
- // }
- //
- // void f() {
- // E[!('a', 'b')!].join('c');
- // }
- // ```
- //
- // #### Common fixes
- //
- // Provide one argument for the extension override:
- //
- // ```dart
- // extension E on String {
- // String join(String other) => '$this $other';
- // }
- //
- // void f() {
- // E('a').join('b');
- // }
- // ```
- static const CompileTimeErrorCode INVALID_EXTENSION_ARGUMENT_COUNT =
- CompileTimeErrorCode(
- 'INVALID_EXTENSION_ARGUMENT_COUNT',
- "Extension overrides must have exactly one argument: "
- "the value of 'this' in the extension method.",
- correction: "Try specifying exactly one argument.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the name of a factory
- // constructor isn't the same as the name of the surrounding class.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because the name of the factory
- // constructor (`A`) isn't the same as the surrounding class (`C`):
- //
- // ```dart
- // class A {}
- //
- // class C {
- // factory [!A!]() => throw 0;
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the factory returns an instance of the surrounding class, then rename
- // the factory:
- //
- // ```dart
- // class A {}
- //
- // class C {
- // factory C() => throw 0;
- // }
- // ```
- //
- // If the factory returns an instance of a different class, then move the
- // factory to that class:
- //
- // ```dart
- // class A {
- // factory A() => throw 0;
- // }
- //
- // class C {}
- // ```
- //
- // If the factory returns an instance of a different class, but you can't
- // modify that class or don't want to move the factory, then convert it to be
- // a static method:
- //
- // ```dart
- // class A {}
- //
- // class C {
- // static A a() => throw 0;
- // }
- // ```
- static const CompileTimeErrorCode INVALID_FACTORY_NAME_NOT_A_CLASS =
- CompileTimeErrorCode(
- 'INVALID_FACTORY_NAME_NOT_A_CLASS',
- "The name of a factory constructor must be the same as the name of "
- "the immediately enclosing class.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the declared member that is not a valid override.
- * 1: the name of the interface that declares the member.
- * 2: the type of the declared member in the interface.
- * 3. the name of the interface with the overridden member.
- * 4. the type of the overridden member.
- *
- * 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',
- "'{1}.{0}' ('{2}') isn't a valid concrete implementation of "
- "'{3}.{0}' ('{4}').",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a generic function type has a
- // function-valued parameter that is written using the older inline function
- // type syntax.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the parameter `f`, in
- // the generic function type used to define `F`, uses the inline function
- // type syntax:
- //
- // ```dart
- // typedef F = int Function(int f[!(!]String s));
- // ```
- //
- // #### Common fixes
- //
- // Use the generic function syntax for the parameter's type:
- //
- // ```dart
- // typedef F = int Function(int Function(String));
- // ```
- static const CompileTimeErrorCode INVALID_INLINE_FUNCTION_TYPE =
- CompileTimeErrorCode(
- 'INVALID_INLINE_FUNCTION_TYPE',
- "Inline function types can't be used for parameters in a generic "
- "function type.",
- correction: "Try using a generic function type "
- "(returnType 'Function(' parameters ')').",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the invalid modifier
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the body of a constructor is
- // prefixed by one of the following modifiers: `async`, `async*`, or `sync*`.
- // Constructor bodies must be synchronous.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the body of the
- // constructor for `C` is marked as being `async`:
- //
- // ```dart
- // class C {
- // C() [!async!] {}
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the constructor can be synchronous, then remove the modifier:
- //
- // ```dart
- // class C {
- // C();
- // }
- // ```
- //
- // If the constructor can't be synchronous, then use a static method to create
- // the instance instead:
- //
- // ```dart
- // class C {
- // C();
- // static Future<C> c() async {
- // return C();
- // }
- // }
- // ```
- static const CompileTimeErrorCode INVALID_MODIFIER_ON_CONSTRUCTOR =
- CompileTimeErrorCode('INVALID_MODIFIER_ON_CONSTRUCTOR',
- "The modifier '{0}' can't be applied to the body of a constructor.",
- correction: "Try removing the modifier.", hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the invalid modifier
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the body of a setter is prefixed
- // by one of the following modifiers: `async`, `async*`, or `sync*`. Setter
- // bodies must be synchronous.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the body of the setter
- // `x` is marked as being `async`:
- //
- // ```dart
- // class C {
- // set x(int i) [!async!] {}
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the setter can be synchronous, then remove the modifier:
- //
- // ```dart
- // class C {
- // set x(int i) {}
- // }
- // ```
- //
- // If the setter can't be synchronous, then use a method to set the value
- // instead:
- //
- // ```dart
- // class C {
- // void x(int i) async {}
- // }
- // ```
- static const CompileTimeErrorCode INVALID_MODIFIER_ON_SETTER =
- CompileTimeErrorCode('INVALID_MODIFIER_ON_SETTER',
- "Setters can't use 'async', 'async*', or 'sync*'.",
- correction: "Try removing the modifier.", hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the declared member that is not a valid override.
- * 1: the name of the interface that declares the member.
- * 2: the type of the declared member in the interface.
- * 3. the name of the interface with the overridden member.
- * 4. the type of the overridden member.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a member of a class is found
- // that overrides a member from a supertype and the override isn't valid. An
- // override is valid if all of these are true:
- // * It allows all of the arguments allowed by the overridden member.
- // * It doesn't require any arguments that aren't required by the overridden
- // member.
- // * The type of every parameter of the overridden member is assignable to the
- // corresponding parameter of the override.
- // * The return type of the override is assignable to the return type of the
- // overridden member.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because the type of the
- // parameter `s` (`String`) isn't assignable to the type of the parameter `i`
- // (`int`):
- //
- // ```dart
- // class A {
- // void m(int i) {}
- // }
- //
- // class B extends A {
- // void [!m!](String s) {}
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the invalid method is intended to override the method from the
- // superclass, then change it to conform:
- //
- // ```dart
- // class A {
- // void m(int i) {}
- // }
- //
- // class B extends A {
- // void m(int i) {}
- // }
- // ```
- //
- // If it isn't intended to override the method from the superclass, then
- // rename it:
- //
- // ```dart
- // class A {
- // void m(int i) {}
- // }
- //
- // class B extends A {
- // void m2(String s) {}
- // }
- // ```
- static const CompileTimeErrorCode INVALID_OVERRIDE = CompileTimeErrorCode(
- 'INVALID_OVERRIDE',
- "'{1}.{0}' ('{2}') isn't a valid override of '{3}.{0}' ('{4}').",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when `this` is used outside of an
- // instance method or a generative constructor. The reserved word `this` is
- // only defined in the context of an instance method or a generative
- // constructor.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `v` is a top-level
- // variable:
- //
- // ```dart
- // C f() => [!this!];
- //
- // class C {}
- // ```
- //
- // #### Common fixes
- //
- // Use a variable of the appropriate type in place of `this`, declaring it if
- // necessary:
- //
- // ```dart
- // C f(C c) => c;
- //
- // class C {}
- // ```
- static const CompileTimeErrorCode INVALID_REFERENCE_TO_THIS =
- CompileTimeErrorCode('INVALID_REFERENCE_TO_THIS',
- "Invalid reference to 'this' expression.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the initializer list of a
- // constructor contains an invocation of a constructor in the superclass, but
- // the invocation isn't the last item in the initializer list.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the invocation of the
- // superclass' constructor isn't the last item in the initializer list:
- //
- // ```dart
- // class A {
- // A(int x);
- // }
- //
- // class B extends A {
- // B(int x) : [!super!](x), assert(x >= 0);
- // }
- // ```
- //
- // #### Common fixes
- //
- // Move the invocation of the superclass' constructor to the end of the
- // initializer list:
- //
- // ```dart
- // class A {
- // A(int x);
- // }
- //
- // class B extends A {
- // B(int x) : assert(x >= 0), super(x);
- // }
- // ```
- static const CompileTimeErrorCode INVALID_SUPER_INVOCATION =
- CompileTimeErrorCode('INVALID_SUPER_INVOCATION',
- "The superclass call must be last in an initializer list: '{0}'.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the type parameter
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a type parameter is used as a
- // type argument in a list, map, or set literal that is prefixed by `const`.
- // 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 list:
- //
- // ```dart
- // List<T> newList<T>() => const <[!T!]>[];
- // ```
- //
- // The following code produces this diagnostic because the type parameter `T`
- // is being used as a type argument when creating a constant map:
- //
- // ```dart
- // Map<String, T> newSet<T>() => const <String, [!T!]>{};
- // ```
- //
- // The following code produces this diagnostic because the type parameter `T`
- // is being used as a type argument when creating a constant set:
- //
- // ```dart
- // Set<T> newSet<T>() => const <[!T!]>{};
- // ```
- //
- // #### Common fixes
- //
- // If the type that will be used for the type parameter can be known at
- // compile time, then remove the type parameter:
- //
- // ```dart
- // List<int> newList() => const <int>[];
- // ```
- //
- // If the type that will be used for the type parameter can't be known until
- // runtime, then remove the keyword `const`:
- //
- // ```dart
- // List<T> newList<T>() => <T>[];
- // ```
- static const CompileTimeErrorCode INVALID_TYPE_ARGUMENT_IN_CONST_LIST =
- CompileTimeErrorCode(
- 'INVALID_TYPE_ARGUMENT_IN_CONST_LITERAL',
- "Constant list literals can't include a type parameter as a type "
- "argument, such as '{0}'.",
- correction: "Try replacing the type parameter with a different type.",
- hasPublishedDocs: true,
- uniqueName: 'INVALID_TYPE_ARGUMENT_IN_CONST_LIST',
- );
-
- /**
- * Parameters:
- * 0: the name of the type parameter
- */
- static const CompileTimeErrorCode INVALID_TYPE_ARGUMENT_IN_CONST_MAP =
- CompileTimeErrorCode(
- 'INVALID_TYPE_ARGUMENT_IN_CONST_LITERAL',
- "Constant map literals can't include a type parameter as a type "
- "argument, such as '{0}'.",
- correction: "Try replacing the type parameter with a different type.",
- hasPublishedDocs: true,
- uniqueName: 'INVALID_TYPE_ARGUMENT_IN_CONST_MAP',
- );
-
- /**
- * Parameters:
- * 0: the name of the type parameter
- */
- static const CompileTimeErrorCode INVALID_TYPE_ARGUMENT_IN_CONST_SET =
- CompileTimeErrorCode(
- 'INVALID_TYPE_ARGUMENT_IN_CONST_LITERAL',
- "Constant set literals can't include a type parameter as a type "
- "argument, such as '{0}'.",
- correction: "Try replacing the type parameter with a different type.",
- hasPublishedDocs: true,
- uniqueName: 'INVALID_TYPE_ARGUMENT_IN_CONST_SET',
- );
-
- /**
- * Parameters:
- * 0: the URI that is invalid
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a URI in a directive doesn't
- // conform to the syntax of a valid URI.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `'#'` isn't a valid
- // URI:
- //
- // ```dart
- // import [!'#'!];
- // ```
- //
- // #### Common fixes
- //
- // Replace the invalid URI with a valid URI.
- static const CompileTimeErrorCode INVALID_URI = CompileTimeErrorCode(
- 'INVALID_URI', "Invalid URI syntax: '{0}'.",
- hasPublishedDocs: true);
-
- /**
- * The 'covariant' keyword was found in an inappropriate location.
- */
- static const CompileTimeErrorCode INVALID_USE_OF_COVARIANT =
- CompileTimeErrorCode(
- 'INVALID_USE_OF_COVARIANT',
- "The 'covariant' keyword can only be used for parameters in instance "
- "methods or before non-final instance fields.",
- correction: "Try removing the 'covariant' keyword.");
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an expression whose value will
- // always be `null` is dereferenced.
- //
- // #### Example
- //
- // The following code produces this diagnostic because `x` will always be
- // `null`:
- //
- // ```dart
- // int f(Null x) {
- // return [!x!].length;
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the value is allowed to be something other than `null`, then change the
- // type of the expression:
- //
- // ```dart
- // int f(String? x) {
- // return x!.length;
- // }
- // ```
- static const CompileTimeErrorCode INVALID_USE_OF_NULL_VALUE =
- CompileTimeErrorCode('INVALID_USE_OF_NULL_VALUE',
- "An expression whose value is always 'null' can't be dereferenced.",
- correction: "Try changing the type of the expression.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the extension
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an extension override is used to
- // invoke a function but the extension doesn't declare a `call` method.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because the extension `E`
- // doesn't define a `call` method:
- //
- // ```dart
- // extension E on String {}
- //
- // void f() {
- // [!E('')!]();
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the extension is intended to define a `call` method, then declare it:
- //
- // ```dart
- // extension E on String {
- // int call() => 0;
- // }
- //
- // void f() {
- // E('')();
- // }
- // ```
- //
- // If the extended type defines a `call` method, then remove the extension
- // override.
- //
- // If the `call` method isn't defined, then rewrite the code so that it
- // doesn't invoke the `call` method.
- static const CompileTimeErrorCode INVOCATION_OF_EXTENSION_WITHOUT_CALL =
- CompileTimeErrorCode(
- 'INVOCATION_OF_EXTENSION_WITHOUT_CALL',
- "The extension '{0}' doesn't define a 'call' method so the override "
- "can't be used in an invocation.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the identifier that is not a function type
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when it finds a function invocation,
- // but the name of the function being invoked is defined to be something other
- // than a function.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `Binary` is the name of
- // a function type, not a function:
- //
- // ```dart
- // typedef Binary = int Function(int, int);
- //
- // int f() {
- // return [!Binary!](1, 2);
- // }
- // ```
- //
- // #### Common fixes
- //
- // Replace the name with the name of a function.
- static const CompileTimeErrorCode INVOCATION_OF_NON_FUNCTION =
- CompileTimeErrorCode(
- 'INVOCATION_OF_NON_FUNCTION', "'{0}' isn't a function.",
- // TODO(brianwilkerson) Split this error code so that we can provide
- // better error and correction messages.
- correction:
- "Try correcting the name to match an existing function, or "
- "define a method or function named '{0}'.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a function invocation is found,
- // but the name being referenced isn't the name of a function, or when the
- // expression computing the function doesn't compute a function.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `x` isn't a function:
- //
- // ```dart
- // int x = 0;
- //
- // int f() => x;
- //
- // var y = [!x!]();
- // ```
- //
- // The following code produces this diagnostic because `f()` doesn't return a
- // function:
- //
- // ```dart
- // int x = 0;
- //
- // int f() => x;
- //
- // var y = [!f()!]();
- // ```
- //
- // #### Common fixes
- //
- // If you need to invoke a function, then replace the code before the argument
- // list with the name of a function or with an expression that computes a
- // function:
- //
- // ```dart
- // int x = 0;
- //
- // int f() => x;
- //
- // var y = f();
- // ```
- static const CompileTimeErrorCode INVOCATION_OF_NON_FUNCTION_EXPRESSION =
- CompileTimeErrorCode(
- 'INVOCATION_OF_NON_FUNCTION_EXPRESSION',
- "The expression doesn't evaluate to a function, so it can't be "
- "invoked.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the unresolvable label
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a `break` or `continue`
- // statement references a label that is declared in a method or function
- // containing the function in which the `break` or `continue` statement
- // appears. The `break` and `continue` statements can't be used to transfer
- // control outside the function that contains them.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the label `loop` is
- // declared outside the local function `g`:
- //
- // ```dart
- // void f() {
- // loop:
- // while (true) {
- // void g() {
- // break [!loop!];
- // }
- //
- // g();
- // }
- // }
- // ```
- //
- // #### Common fixes
- //
- // Try rewriting the code so that it isn't necessary to transfer control
- // outside the local function, possibly by inlining the local function:
- //
- // ```dart
- // void f() {
- // loop:
- // while (true) {
- // break loop;
- // }
- // }
- // ```
- //
- // If that isn't possible, then try rewriting the local function so that a
- // value returned by the function can be used to determine whether control is
- // transferred:
- //
- // ```dart
- // void f() {
- // loop:
- // while (true) {
- // bool g() {
- // return true;
- // }
- //
- // if (g()) {
- // break loop;
- // }
- // }
- // }
- // ```
- static const CompileTimeErrorCode LABEL_IN_OUTER_SCOPE = CompileTimeErrorCode(
- 'LABEL_IN_OUTER_SCOPE',
- "Can't reference label '{0}' declared in an outer method.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the unresolvable label
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when it finds a reference to a label
- // that isn't defined in the scope of the `break` or `continue` statement that
- // is referencing it.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the label `loop` isn't
- // defined anywhere:
- //
- // ```dart
- // void f() {
- // for (int i = 0; i < 10; i++) {
- // for (int j = 0; j < 10; j++) {
- // break [!loop!];
- // }
- // }
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the label should be on the innermost enclosing `do`, `for`, `switch`, or
- // `while` statement, then remove the label:
- //
- // ```dart
- // void f() {
- // for (int i = 0; i < 10; i++) {
- // for (int j = 0; j < 10; j++) {
- // break;
- // }
- // }
- // }
- // ```
- //
- // If the label should be on some other statement, then add the label:
- //
- // ```dart
- // void f() {
- // loop: for (int i = 0; i < 10; i++) {
- // for (int j = 0; j < 10; j++) {
- // break loop;
- // }
- // }
- // }
- // ```
- static const CompileTimeErrorCode LABEL_UNDEFINED = CompileTimeErrorCode(
- 'LABEL_UNDEFINED', "Can't reference an undefined label '{0}'.",
- correction: "Try defining the label, or "
- "correcting the name to match an existing label.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a class that has at least one
- // `const` constructor also has a field marked both `late` and `final`.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the class `A` has a
- // `const` constructor and the `final` field `f` is marked as `late`:
- //
- // ```dart
- // class A {
- // [!late!] final int f;
- //
- // const A();
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the field doesn't need to be marked `late`, then remove the `late`
- // modifier from the field:
- //
- // ```dart
- // class A {
- // final int f = 0;
- //
- // const A();
- // }
- // ```
- //
- // If the field must be marked `late`, then remove the `const` modifier from
- // the constructors:
- //
- // ```dart
- // class A {
- // late final int f;
- //
- // A();
- // }
- // ```
- static const CompileTimeErrorCode LATE_FINAL_FIELD_WITH_CONST_CONSTRUCTOR =
- CompileTimeErrorCode(
- 'LATE_FINAL_FIELD_WITH_CONST_CONSTRUCTOR',
- "Can't have a late final field in a class with a generative "
- "const constructor.",
- correction: "Try removing the 'late' modifier, or don't declare "
- "'const' constructors.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the analyzer can prove that a
- // local variable marked as both `late` and `final` was already assigned a
- // value at the point where another assignment occurs.
- //
- // Because `final` variables can only be assigned once, subsequent assignments
- // are guaranteed to fail, so they're flagged.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the `final` variable
- // `v` is assigned a value in two places:
- //
- // ```dart
- // int f() {
- // late final int v;
- // v = 0;
- // [!v!] += 1;
- // return v;
- // }
- // ```
- //
- // #### Common fixes
- //
- // If you need to be able to reassign the variable, then remove the `final`
- // keyword:
- //
- // ```dart
- // int f() {
- // late int v;
- // v = 0;
- // v += 1;
- // return v;
- // }
- // ```
- //
- // If you don't need to reassign the variable, then remove all except the
- // first of the assignments:
- //
- // ```dart
- // int f() {
- // late final int v;
- // v = 0;
- // return v;
- // }
- // ```
- static const CompileTimeErrorCode LATE_FINAL_LOCAL_ALREADY_ASSIGNED =
- CompileTimeErrorCode('LATE_FINAL_LOCAL_ALREADY_ASSIGNED',
- "The late final local variable is already assigned.",
- correction: "Try removing the 'final' modifier, or don't reassign "
- "the value.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the actual type of the list element
- * 1: the expected type of the list element
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the type of an element in a list
- // literal isn't assignable to the element type of the list.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `2.5` is a double, and
- // the list can hold only integers:
- //
- // ```dart
- // List<int> x = [1, [!2.5!], 3];
- // ```
- //
- // #### Common fixes
- //
- // If you intended to add a different object to the list, then replace the
- // element with an expression that computes the intended object:
- //
- // ```dart
- // List<int> x = [1, 2, 3];
- // ```
- //
- // If the object shouldn't be in the list, then remove the element:
- //
- // ```dart
- // List<int> x = [1, 3];
- // ```
- //
- // If the object being computed is correct, then widen the element type of the
- // list to allow all of the different types of objects it needs to contain:
- //
- // ```dart
- // List<num> x = [1, 2.5, 3];
- // ```
- static const CompileTimeErrorCode LIST_ELEMENT_TYPE_NOT_ASSIGNABLE =
- CompileTimeErrorCode('LIST_ELEMENT_TYPE_NOT_ASSIGNABLE',
- "The element type '{0}' can't be assigned to the list type '{1}'.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the first positional parameter
- // of a function named `main` isn't a supertype of `List<String>`.
- //
- // #### Example
- //
- // The following code produces this diagnostic because `List<int>` isn't a
- // supertype of `List<String>`:
- //
- // ```dart
- // void main([!List<int>!] args) {}
- // ```
- //
- // #### Common fixes
- //
- // If the function is an entry point, then change the type of the first
- // positional parameter to be a supertype of `List<String>`:
- //
- // ```dart
- // void main(List<String> args) {}
- // ```
- //
- // If the function isn't an entry point, then change the name of the function:
- //
- // ```dart
- // void f(List<int> args) {}
- // ```
- static const CompileTimeErrorCode MAIN_FIRST_POSITIONAL_PARAMETER_TYPE =
- CompileTimeErrorCode(
- 'MAIN_FIRST_POSITIONAL_PARAMETER_TYPE',
- "The type of the first positional parameter of the 'main' function must be "
- "a supertype of 'List<String>'.",
- correction: "Try changing the type of the parameter.",
- hasPublishedDocs: true,
- );
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a function named `main` has one
- // or more required named parameters.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the function named
- // `main` has a required named parameter (`x`):
- //
- // ```dart
- // void [!main!]({required int x}) {}
- // ```
- //
- // #### Common fixes
- //
- // If the function is an entry point, then remove the `required` keyword:
- //
- // ```dart
- // void main({int? x}) {}
- // ```
- //
- // If the function isn't an entry point, then change the name of the function:
- //
- // ```dart
- // void f({required int x}) {}
- // ```
- static const CompileTimeErrorCode MAIN_HAS_REQUIRED_NAMED_PARAMETERS =
- CompileTimeErrorCode('MAIN_HAS_REQUIRED_NAMED_PARAMETERS',
- "The function 'main' can't have any required named parameters.",
- correction:
- "Try using a different name for the function, or removing the "
- "'required' modifier.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a function named `main` has more
- // than two required positional parameters.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the function `main` has
- // three required positional parameters:
- //
- // ```dart
- // void [!main!](List<String> args, int x, int y) {}
- // ```
- //
- // #### Common fixes
- //
- // If the function is an entry point and the extra parameters aren't used,
- // then remove them:
- //
- // ```dart
- // void main(List<String> args, int x) {}
- // ```
- //
- // If the function is an entry point, but the extra parameters used are for
- // when the function isn't being used as an entry point, then make the extra
- // parameters optional:
- //
- // ```dart
- // void main(List<String> args, int x, [int y = 0]) {}
- // ```
- //
- // If the function isn't an entry point, then change the name of the function:
- //
- // ```dart
- // void f(List<String> args, int x, int y) {}
- // ```
- static const CompileTimeErrorCode
- MAIN_HAS_TOO_MANY_REQUIRED_POSITIONAL_PARAMETERS = CompileTimeErrorCode(
- 'MAIN_HAS_TOO_MANY_REQUIRED_POSITIONAL_PARAMETERS',
- "The function 'main' can't have more than two required positional "
- "parameters.",
- correction:
- "Try using a different name for the function, or removing extra "
- "parameters.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a library contains a declaration
- // of the name `main` that isn't the declaration of a top-level function.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the name `main` is
- // being used to declare a top-level variable:
- //
- // ```dart
- // var [!main!] = 3;
- // ```
- //
- // #### Common fixes
- //
- // Use a different name for the declaration:
- //
- // ```dart
- // var mainIndex = 3;
- // ```
- static const CompileTimeErrorCode MAIN_IS_NOT_FUNCTION = CompileTimeErrorCode(
- 'MAIN_IS_NOT_FUNCTION',
- "The declaration named 'main' must be a function.",
- correction: "Try using a different name for this declaration.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a map entry (a key/value pair)
- // is found in a set literal.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because the literal has a map
- // entry even though it's a set literal:
- //
- // ```dart
- // const collection = <String>{[!'a' : 'b'!]};
- // ```
- //
- // #### Common fixes
- //
- // If you intended for the collection to be a map, then change the code so
- // that it is a map. In the previous example, you could do this by adding
- // another type argument:
- //
- // ```dart
- // const collection = <String, String>{'a' : 'b'};
- // ```
- //
- // In other cases, you might need to change the explicit type from `Set` to
- // `Map`.
- //
- // If you intended for the collection to be a set, then remove the map entry,
- // possibly by replacing the colon with a comma if both values should be
- // included in the set:
- //
- // ```dart
- // const collection = <String>{'a', 'b'};
- // ```
- static const CompileTimeErrorCode MAP_ENTRY_NOT_IN_MAP = CompileTimeErrorCode(
- 'MAP_ENTRY_NOT_IN_MAP', "Map entries can only be used in a map literal.",
- correction: "Try converting the collection to a map or removing the map "
- "entry.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the type of the expression being used as a key
- * 1: the type of keys declared for the map
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a key of a key-value pair in a
- // map literal has a type that isn't assignable to the key type of the map.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `2` is an `int`, but
- // the keys of the map are required to be `String`s:
- //
- // ```dart
- // var m = <String, String>{[!2!] : 'a'};
- // ```
- //
- // #### Common fixes
- //
- // If the type of the map is correct, then change the key to have the correct
- // type:
- //
- // ```dart
- // var m = <String, String>{'2' : 'a'};
- // ```
- //
- // If the type of the key is correct, then change the key type of the map:
- //
- // ```dart
- // var m = <int, String>{2 : 'a'};
- // ```
- static const CompileTimeErrorCode MAP_KEY_TYPE_NOT_ASSIGNABLE =
- CompileTimeErrorCode(
- 'MAP_KEY_TYPE_NOT_ASSIGNABLE',
- "The element type '{0}' can't be assigned to the map key type "
- "'{1}'.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the type of the expression being used as a value
- * 1: the type of values declared for the map
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a value of a key-value pair in a
- // map literal has a type that isn't assignable to the the value type of the
- // map.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `2` is an `int`, but/
- // the values of the map are required to be `String`s:
- //
- // ```dart
- // var m = <String, String>{'a' : [!2!]};
- // ```
- //
- // #### Common fixes
- //
- // If the type of the map is correct, then change the value to have the
- // correct type:
- //
- // ```dart
- // var m = <String, String>{'a' : '2'};
- // ```
- //
- // If the type of the value is correct, then change the value type of the map:
- //
- // ```dart
- // var m = <String, int>{'a' : 2};
- // ```
- static const CompileTimeErrorCode MAP_VALUE_TYPE_NOT_ASSIGNABLE =
- CompileTimeErrorCode(
- 'MAP_VALUE_TYPE_NOT_ASSIGNABLE',
- "The element type '{0}' can't be assigned to the map value type "
- "'{1}'.",
- hasPublishedDocs: true);
-
- /**
- * 12.1 Constants: A constant expression is ... a constant list literal.
- */
- static const CompileTimeErrorCode MISSING_CONST_IN_LIST_LITERAL =
- CompileTimeErrorCode(
- 'MISSING_CONST_IN_LIST_LITERAL',
- "List literals must be prefixed with 'const' when used as a constant "
- "expression.",
- correction: "Try adding the keyword 'const' before the literal.");
-
- /**
- * 12.1 Constants: A constant expression is ... a constant map literal.
- */
- static const CompileTimeErrorCode MISSING_CONST_IN_MAP_LITERAL =
- CompileTimeErrorCode(
- 'MISSING_CONST_IN_MAP_LITERAL',
- "Map literals must be prefixed with 'const' when used as a constant "
- "expression.",
- correction: "Try adding the keyword 'const' before the literal.");
-
- /**
- * 12.1 Constants: A constant expression is ... a constant set literal.
- */
- static const CompileTimeErrorCode MISSING_CONST_IN_SET_LITERAL =
- CompileTimeErrorCode(
- 'MISSING_CONST_IN_SET_LITERAL',
- "Set literals must be prefixed with 'const' when used as a constant "
- "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: "Re-install the Dart or Flutter SDK.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an optional parameter, whether
- // positional or named, has a [potentially non-nullable][] type and doesn't
- // specify a default value. Optional parameters that have no explicit default
- // value have an implicit default value of `null`. If the type of the
- // parameter doesn't allow the parameter to have a value of `null`, then the
- // implicit default value isn't valid.
- //
- // #### Example
- //
- // The following code produces this diagnostic because `x` can't be `null`,
- // and no non-`null` default value is specified:
- //
- // ```dart
- // void f([int [!x!]]) {}
- // ```
- //
- // As does this:
- //
- // ```dart
- // void g({int [!x!]}) {}
- // ```
- //
- // #### Common fixes
- //
- // If you want to use `null` to indicate that no value was provided, then you
- // need to make the type nullable:
- //
- // ```dart
- // void f([int? x]) {}
- // void g({int? x}) {}
- // ```
- //
- // If the parameter can't be null, then either provide a default value:
- //
- // ```dart
- // void f([int x = 1]) {}
- // void g({int x = 2}) {}
- // ```
- //
- // or make the parameter a required parameter:
- //
- // ```dart
- // void f(int x) {}
- // void g({required int x}) {}
- // ```
- static const CompileTimeErrorCode MISSING_DEFAULT_VALUE_FOR_PARAMETER =
- CompileTimeErrorCode(
- 'MISSING_DEFAULT_VALUE_FOR_PARAMETER',
- "The parameter '{0}' can't have a value of 'null' because of its "
- "type, but the implicit default value is 'null'.",
- correction:
- "Try adding either an explicit non-'null' default value or the "
- "'required' modifier.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the parameter
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an invocation of a function is
- // missing a required named parameter.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the invocation of `f`
- // doesn't include a value for the required named parameter `end`:
- //
- // ```dart
- // void f(int start, {required int end}) {}
- // void g() {
- // [!f!](3);
- // }
- // ```
- //
- // #### Common fixes
- //
- // Add a named argument corresponding to the missing required parameter:
- //
- // ```dart
- // void f(int start, {required int end}) {}
- // void g() {
- // f(3, end: 5);
- // }
- // ```
- static const CompileTimeErrorCode MISSING_REQUIRED_ARGUMENT =
- CompileTimeErrorCode(
- 'MISSING_REQUIRED_ARGUMENT',
- "The named parameter '{0}' is required, but there's no corresponding "
- "argument.",
- correction: "Try adding the required argument.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the super-invoked member
- * 1: the display name of the type of the super-invoked member in the mixin
- * 2: the display name of the type of the concrete member in the class
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a mixin that invokes a method
- // using `super` is used in a class where the concrete implementation of that
- // method has a different signature than the signature defined for that method
- // by the mixin's `on` type. The reason this is an error is because the
- // invocation in the mixin might invoke the method in a way that's
- // incompatible with the method that will actually be executed.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the class `C` uses the
- // mixin `M`, the mixin `M` invokes `foo` using `super`, and the abstract
- // version of `foo` declared in `I` (the mixin's `on` type) doesn't have the
- // same signature as the concrete version of `foo` declared in `A`:
- //
- // ```dart
- // class I {
- // void foo([int? p]) {}
- // }
- //
- // class A {
- // void foo(int p) {}
- // }
- //
- // abstract class B extends A implements I {
- // @override
- // void foo([int? p]);
- // }
- //
- // mixin M on I {
- // void bar() {
- // super.foo(42);
- // }
- // }
- //
- // abstract class C extends B with [!M!] {}
- // ```
- //
- // #### Common fixes
- //
- // If the class doesn't need to use the mixin, then remove it from the `with`
- // clause:
- //
- // ```dart
- // class I {
- // void foo([int? p]) {}
- // }
- //
- // class A {
- // void foo(int? p) {}
- // }
- //
- // abstract class B extends A implements I {
- // @override
- // void foo([int? p]);
- // }
- //
- // mixin M on I {
- // void bar() {
- // super.foo(42);
- // }
- // }
- //
- // abstract class C extends B {}
- // ```
- //
- // If the class needs to use the mixin, then ensure that there's a concrete
- // implementation of the method that conforms to the signature expected by the
- // mixin:
- //
- // ```dart
- // class I {
- // void foo([int? p]) {}
- // }
- //
- // class A {
- // void foo(int? p) {}
- // }
- //
- // abstract class B extends A implements I {
- // @override
- // void foo([int? p]) {
- // super.foo(p);
- // }
- // }
- //
- // mixin M on I {
- // void bar() {
- // super.foo(42);
- // }
- // }
- //
- // abstract class C extends B with M {}
- // ```
- static const CompileTimeErrorCode
- MIXIN_APPLICATION_CONCRETE_SUPER_INVOKED_MEMBER_TYPE =
- CompileTimeErrorCode(
- 'MIXIN_APPLICATION_CONCRETE_SUPER_INVOKED_MEMBER_TYPE',
- "The super-invoked member '{0}' has the type '{1}', and the concrete "
- "member in the class has the type '{2}'.",
- hasPublishedDocs: true);
-
- /**
- * 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',
- "The class doesn't have a concrete implementation of the "
- "super-invoked member '{0}'.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the display name of the mixin
- * 1: the display name of the superclass
- * 2: the display name of the type that is not implemented
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a mixin that has a superclass
- // constraint is used in a [mixin application][] with a superclass that
- // doesn't implement the required constraint.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the mixin `M` requires
- // that the class to which it's applied be a subclass of `A`, but `Object`
- // isn't a subclass of `A`:
- //
- // ```dart
- // class A {}
- //
- // mixin M on A {}
- //
- // class X = Object with [!M!];
- // ```
- //
- // #### Common fixes
- //
- // If you need to use the mixin, then change the superclass to be either the
- // same as or a subclass of the superclass constraint:
- //
- // ```dart
- // class A {}
- //
- // mixin M on A {}
- //
- // class X = A with M;
- // ```
- static const CompileTimeErrorCode
- MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE = CompileTimeErrorCode(
- 'MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE',
- "'{0}' can't be mixed onto '{1}' because '{1}' doesn't implement "
- "'{2}'.",
- correction: "Try extending the class '{0}'.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the mixin that is invalid
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a class is used as a mixin and
- // the mixed-in class defines a constructor.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the class `A`, which
- // defines a constructor, is being used as a mixin:
- //
- // ```dart
- // class A {
- // A();
- // }
- //
- // class B with [!A!] {}
- // ```
- //
- // #### Common fixes
- //
- // If it's possible to convert the class to a mixin, then do so:
- //
- // ```dart
- // mixin A {
- // }
- //
- // class B with A {}
- // ```
- //
- // If the class can't be a mixin and it's possible to remove the constructor,
- // then do so:
- //
- // ```dart
- // class A {
- // }
- //
- // class B with A {}
- // ```
- //
- // If the class can't be a mixin and you can't remove the constructor, then
- // try extending or implementing the class rather than mixing it in:
- //
- // ```dart
- // class A {
- // A();
- // }
- //
- // class B extends A {}
- // ```
- static const CompileTimeErrorCode MIXIN_CLASS_DECLARES_CONSTRUCTOR =
- CompileTimeErrorCode(
- 'MIXIN_CLASS_DECLARES_CONSTRUCTOR',
- "The class '{0}' can't be used as a mixin because it declares a "
- "constructor.",
- hasPublishedDocs: true);
-
- /**
- * The <i>mixinMember</i> production allows the same instance or static
- * members that a class would allow, but no constructors (for now).
- */
- static const CompileTimeErrorCode MIXIN_DECLARES_CONSTRUCTOR =
- CompileTimeErrorCode(
- 'MIXIN_DECLARES_CONSTRUCTOR', "Mixins can't declare constructors.");
-
- /**
- * No parameters.
- */
- static const CompileTimeErrorCode MIXIN_DEFERRED_CLASS = CompileTimeErrorCode(
- 'SUBTYPE_OF_DEFERRED_CLASS', "Classes can't mixin deferred classes.",
- correction: "Try changing the import to not be deferred.",
- hasPublishedDocs: true,
- uniqueName: 'MIXIN_DEFERRED_CLASS');
-
- static const CompileTimeErrorCode
- MIXIN_INFERENCE_INCONSISTENT_MATCHING_CLASSES = CompileTimeErrorCode(
- 'MIXIN_INFERENCE_INCONSISTENT_MATCHING_CLASSES',
- "Type parameters couldn't be inferred for the mixin '{0}' because "
- "the base class implements the mixin's supertype constraint "
- "'{1}' in multiple conflicting ways");
-
- static const CompileTimeErrorCode MIXIN_INFERENCE_NO_MATCHING_CLASS =
- CompileTimeErrorCode(
- 'MIXIN_INFERENCE_NO_MATCHING_CLASS',
- "Type parameters couldn't be inferred for the mixin '{0}' because "
- "the base class doesn't implement the mixin's supertype "
- "constraint '{1}'");
-
- static const CompileTimeErrorCode MIXIN_INFERENCE_NO_POSSIBLE_SUBSTITUTION =
- CompileTimeErrorCode(
- 'MIXIN_INFERENCE_NO_POSSIBLE_SUBSTITUTION',
- "Type parameters couldn't be inferred for the mixin '{0}' because "
- "no type parameter substitution could be found matching the "
- "mixin's supertype constraints");
-
- /**
- * Parameters:
- * 0: the name of the mixin that is invalid
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a class that extends a class
- // other than `Object` is used as a mixin.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the class `B`, which
- // extends `A`, is being used as a mixin by `C`:
- //
- // ```dart
- // class A {}
- //
- // class B extends A {}
- //
- // class C with [!B!] {}
- // ```
- //
- // #### Common fixes
- //
- // If the class being used as a mixin can be changed to extend `Object`, then
- // change it:
- //
- // ```dart
- // class A {}
- //
- // class B {}
- //
- // class C with B {}
- // ```
- //
- // If the class being used as a mixin can't be changed and the class that's
- // using it extends `Object`, then extend the class being used as a mixin:
- //
- // ```dart
- // class A {}
- //
- // class B extends A {}
- //
- // class C extends B {}
- // ```
- //
- // If the class doesn't extend `Object` or if you want to be able to mix in
- // the behavior from `B` in other places, then create a real mixin:
- //
- // ```dart
- // class A {}
- //
- // mixin M on A {}
- //
- // class B extends A with M {}
- //
- // class C extends A with M {}
- // ```
- static const CompileTimeErrorCode MIXIN_INHERITS_FROM_NOT_OBJECT =
- CompileTimeErrorCode(
- 'MIXIN_INHERITS_FROM_NOT_OBJECT',
- "The class '{0}' can't be used as a mixin because it extends a class "
- "other than 'Object'.",
- hasPublishedDocs: true);
-
- /**
- * 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.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the disallowed type
- */
- static const CompileTimeErrorCode MIXIN_OF_DISALLOWED_CLASS =
- CompileTimeErrorCode(
- 'SUBTYPE_OF_DISALLOWED_TYPE',
- "Classes can't mixin '{0}'.",
- correction: "Try specifying a different class or mixin, or "
- "remove the class or mixin from the list.",
- hasPublishedDocs: true,
- uniqueName: 'MIXIN_OF_DISALLOWED_CLASS',
- );
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a name in a `with` clause is
- // defined to be something other than a mixin or a class.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `F` is defined to be a
- // function type:
- //
- // ```dart
- // typedef F = int Function(String);
- //
- // class C with [!F!] {}
- // ```
- //
- // #### Common fixes
- //
- // Remove the invalid name from the list, possibly replacing it with the name
- // of the intended mixin or class:
- //
- // ```dart
- // typedef F = int Function(String);
- //
- // class C {}
- // ```
- static const CompileTimeErrorCode MIXIN_OF_NON_CLASS = CompileTimeErrorCode(
- 'MIXIN_OF_NON_CLASS', "Classes can only mix in mixins and classes.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- static const CompileTimeErrorCode
- MIXIN_OF_TYPE_ALIAS_EXPANDS_TO_TYPE_PARAMETER = CompileTimeErrorCode(
- 'SUPERTYPE_EXPANDS_TO_TYPE_PARAMETER',
- "A type alias that expands to a type parameter can't be mixed in.",
- hasPublishedDocs: true,
- uniqueName: 'MIXIN_OF_TYPE_ALIAS_EXPANDS_TO_TYPE_PARAMETER');
-
- /**
- * No parameters.
- */
- static const CompileTimeErrorCode
- MIXIN_ON_TYPE_ALIAS_EXPANDS_TO_TYPE_PARAMETER = CompileTimeErrorCode(
- 'SUPERTYPE_EXPANDS_TO_TYPE_PARAMETER',
- "A type alias that expands to a type parameter can't be used as a "
- "superclass constraint.",
- hasPublishedDocs: true,
- uniqueName: 'MIXIN_ON_TYPE_ALIAS_EXPANDS_TO_TYPE_PARAMETER');
-
- /**
- * No parameters.
- */
- static const CompileTimeErrorCode
- MIXIN_SUPER_CLASS_CONSTRAINT_DEFERRED_CLASS = CompileTimeErrorCode(
- 'MIXIN_SUPER_CLASS_CONSTRAINT_DEFERRED_CLASS',
- "Deferred classes can't be used as super-class constraints.",
- correction: "Try changing the import to not be deferred.");
-
- /**
- * Parameters:
- * 0: the name of the disallowed type
- */
- static const CompileTimeErrorCode
- MIXIN_SUPER_CLASS_CONSTRAINT_DISALLOWED_CLASS = CompileTimeErrorCode(
- 'SUBTYPE_OF_DISALLOWED_TYPE',
- "''{0}' can't be used as a superclass constraint.",
- correction: "Try specifying a different super-class constraint, or "
- "remove the 'on' clause.",
- hasPublishedDocs: true,
- uniqueName: 'MIXIN_SUPER_CLASS_CONSTRAINT_DISALLOWED_CLASS',
- );
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a type following the `on`
- // keyword in a mixin declaration is neither a class nor a mixin.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `F` is neither a class
- // nor a mixin:
- //
- // ```dart
- // typedef F = void Function();
- //
- // mixin M on [!F!] {}
- // ```
- //
- // #### Common fixes
- //
- // If the type was intended to be a class but was mistyped, then replace the
- // name.
- //
- // Otherwise, remove the type from the `on` clause.
- static const CompileTimeErrorCode MIXIN_SUPER_CLASS_CONSTRAINT_NON_INTERFACE =
- CompileTimeErrorCode('MIXIN_SUPER_CLASS_CONSTRAINT_NON_INTERFACE',
- "Only classes and mixins can be used as superclass constraints.",
- hasPublishedDocs: true);
-
- /**
- * 9.1 Mixin Application: It is a compile-time error if <i>S</i> does not
- * denote a class available in the immediately enclosing scope.
- */
- static const CompileTimeErrorCode MIXIN_WITH_NON_CLASS_SUPERCLASS =
- CompileTimeErrorCode('MIXIN_WITH_NON_CLASS_SUPERCLASS',
- "Mixin can only be applied to class.");
-
- /**
- * Technically this is [IMPLEMENTS_SUPER_CLASS].
- * See https://github.com/dart-lang/sdk/issues/25765#issuecomment-307422593
- *
- * Parameters:
- * 0: the name of the class that appears in both "extends" and "with" clauses
- */
- static const CompileTimeErrorCode MIXINS_SUPER_CLASS = CompileTimeErrorCode(
- 'MIXINS_SUPER_CLASS',
- "'{0}' can't be used in both 'extends' and 'with' clauses.",
- correction: "Try removing one of the occurrences.");
-
- /**
- * 7.6.1 Generative Constructors: A generative constructor may be redirecting,
- * in which case its only action is to invoke another generative constructor.
- */
- static const CompileTimeErrorCode
- MULTIPLE_REDIRECTING_CONSTRUCTOR_INVOCATIONS = CompileTimeErrorCode(
- 'MULTIPLE_REDIRECTING_CONSTRUCTOR_INVOCATIONS',
- "Constructors can have at most one 'this' redirection.",
- correction: "Try removing all but one of the redirections.");
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the initializer list of a
- // constructor contains more than one invocation of a constructor from the
- // superclass. The initializer list is required to have exactly one such call,
- // which can either be explicit or implicit.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the initializer list
- // for `B`’s constructor invokes both the constructor `one` and the
- // constructor `two` from the superclass `A`:
- //
- // ```dart
- // class A {
- // int? x;
- // String? s;
- // A.one(this.x);
- // A.two(this.s);
- // }
- //
- // class B extends A {
- // B() : super.one(0), [!super.two('')!];
- // }
- // ```
- //
- // #### Common fixes
- //
- // If one of the super constructors will initialize the instance fully, then
- // remove the other:
- //
- // ```dart
- // class A {
- // int? x;
- // String? s;
- // A.one(this.x);
- // A.two(this.s);
- // }
- //
- // class B extends A {
- // B() : super.one(0);
- // }
- // ```
- //
- // If the initialization achieved by one of the super constructors can be
- // performed in the body of the constructor, then remove its super invocation
- // and perform the initialization in the body:
- //
- // ```dart
- // class A {
- // int? x;
- // String? s;
- // A.one(this.x);
- // A.two(this.s);
- // }
- //
- // class B extends A {
- // B() : super.one(0) {
- // s = '';
- // }
- // }
- // ```
- //
- // If the initialization can only be performed in a constructor in the
- // superclass, then either add a new constructor or modify one of the existing
- // constructors so there's a constructor that allows all the required
- // initialization to occur in a single call:
- //
- // ```dart
- // class A {
- // int? x;
- // String? s;
- // A.one(this.x);
- // A.two(this.s);
- // A.three(this.x, this.s);
- // }
- //
- // class B extends A {
- // B() : super.three(0, '');
- // }
- // ```
- static const CompileTimeErrorCode MULTIPLE_SUPER_INITIALIZERS =
- CompileTimeErrorCode('MULTIPLE_SUPER_INITIALIZERS',
- "A constructor can have at most one 'super' initializer.",
- correction: "Try removing all but one of the 'super' initializers.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the non-type element
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an instance creation using
- // either `new` or `const` specifies a name that isn't defined as a class.
- //
- // #### Example
- //
- // The following code produces this diagnostic because `f` is a function
- // rather than a class:
- //
- // ```dart
- // int f() => 0;
- //
- // void g() {
- // new [!f!]();
- // }
- // ```
- //
- // #### Common fixes
- //
- // If a class should be created, then replace the invalid name with the name
- // of a valid class:
- //
- // ```dart
- // int f() => 0;
- //
- // void g() {
- // new Object();
- // }
- // ```
- //
- // If the name is the name of a function and you want that function to be
- // invoked, then remove the `new` or `const` keyword:
- //
- // ```dart
- // int f() => 0;
- //
- // void g() {
- // f();
- // }
- // ```
- static const CompileTimeErrorCode NEW_WITH_NON_TYPE = CompileTimeErrorCode(
- 'CREATION_WITH_NON_TYPE',
- "The name '{0}' isn't a class.",
- correction: "Try correcting the name to match an existing class.",
- hasPublishedDocs: true,
- isUnresolvedIdentifier: true,
- uniqueName: 'NEW_WITH_NON_TYPE',
- );
-
- /**
- * 12.11.1 New: If <i>T</i> is a class or parameterized type accessible in the
- * current scope then:
- * 1. If <i>e</i> is of the form <i>new T.id(a<sub>1</sub>, …,
- * a<sub>n</sub>, x<sub>n+1</sub>: a<sub>n+1</sub>, …,
- * x<sub>n+k</sub>: a<sub>n+k</sub>)</i> it is a static warning if
- * <i>T.id</i> is not the name of a constructor declared by the type
- * <i>T</i>.
- * If <i>e</i> of the form <i>new T(a<sub>1</sub>, …, a<sub>n</sub>,
- * x<sub>n+1</sub>: a<sub>n+1</sub>, …, x<sub>n+k</sub>:
- * a<sub>n+kM/sub>)</i> it is a static warning if the type <i>T</i> does not
- * declare a constructor with the same name as the declaration of <i>T</i>.
- */
- static const CompileTimeErrorCode NEW_WITH_UNDEFINED_CONSTRUCTOR =
- CompileTimeErrorCode('NEW_WITH_UNDEFINED_CONSTRUCTOR',
- "The class '{0}' doesn't have a constructor named '{1}'.",
- correction: "Try invoking a different constructor, or "
- "define a constructor named '{1}'.");
-
- /**
- * Parameters:
- * 0: the name of the class being instantiated
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an unnamed constructor is
- // invoked on a class that defines named constructors but the class doesn’t
- // have an unnamed constructor.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `A` doesn't define an
- // unnamed constructor:
- //
- // ```dart
- // class A {
- // A.a();
- // }
- //
- // A f() => [!A!]();
- // ```
- //
- // #### Common fixes
- //
- // If one of the named constructors does what you need, then use it:
- //
- // ```dart
- // class A {
- // A.a();
- // }
- //
- // A f() => A.a();
- // ```
- //
- // If none of the named constructors does what you need, and you're able to
- // add an unnamed constructor, then add the constructor:
- //
- // ```dart
- // class A {
- // A();
- // A.a();
- // }
- //
- // A f() => A();
- // ```
- static const CompileTimeErrorCode NEW_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT =
- CompileTimeErrorCode('NEW_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT',
- "The class '{0}' doesn't have an unnamed constructor.",
- correction:
- "Try using one of the named constructors defined in '{0}'.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an annotation consists of a
- // single identifier, but that identifier is the name of a class rather than a
- // variable. To create an instance of the class, the identifier must be
- // followed by an argument list.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `C` is a class, and a
- // class can't be used as an annotation without invoking a `const` constructor
- // from the class:
- //
- // ```dart
- // class C {
- // const C();
- // }
- //
- // [!@C!]
- // var x;
- // ```
- //
- // #### Common fixes
- //
- // Add the missing argument list:
- //
- // ```dart
- // class C {
- // const C();
- // }
- //
- // @C()
- // var x;
- // ```
- static const CompileTimeErrorCode NO_ANNOTATION_CONSTRUCTOR_ARGUMENTS =
- CompileTimeErrorCode('NO_ANNOTATION_CONSTRUCTOR_ARGUMENTS',
- "Annotation creation must have arguments.",
- correction: "Try adding an empty argument list.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the class where override error was detected
- * 1: the list of candidate signatures which cannot be combined
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when there is a method declaration
- // for which one or more types needs to be inferred, and those types can't be
- // inferred because none of the overridden methods has a function type that is
- // a supertype of all the other overridden methods, as specified by
- // [override inference][].
- //
- // #### Example
- //
- // The following code produces this diagnostic because the method `m` declared
- // in the class `C` is missing both the return type and the type of the
- // parameter `a`, and neither of the missing types can be inferred for it:
- //
- // ```dart
- // abstract class A {
- // A m(String a);
- // }
- //
- // abstract class B {
- // B m(int a);
- // }
- //
- // abstract class C implements A, B {
- // [!m!](a);
- // }
- // ```
- //
- // In this example, override inference can't be performed because the
- // overridden methods are incompatible in these ways:
- // - Neither parameter type (`String` and `int`) is a supertype of the other.
- // - Neither return type is a subtype of the other.
- //
- // #### Common fixes
- //
- // If possible, add types to the method in the subclass that are consistent
- // with the types from all the overridden methods:
- //
- // ```dart
- // abstract class A {
- // A m(String a);
- // }
- //
- // abstract class B {
- // B m(int a);
- // }
- //
- // abstract class C implements A, B {
- // C m(Object a);
- // }
- // ```
- static const CompileTimeErrorCode NO_COMBINED_SUPER_SIGNATURE =
- CompileTimeErrorCode('NO_COMBINED_SUPER_SIGNATURE',
- "Can't infer missing types in '{0}' from overridden methods: {1}.",
- correction: "Try providing explicit types for this method's "
- "parameters and return type.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the superclass that does not define an implicitly invoked
- * constructor
- */
- static const CompileTimeErrorCode NO_DEFAULT_SUPER_CONSTRUCTOR_EXPLICIT =
- CompileTimeErrorCode(
- 'NO_DEFAULT_SUPER_CONSTRUCTOR',
- "The superclass '{0}' doesn't have a zero argument constructor.",
- correction: "Try declaring a zero argument constructor in '{0}', or "
- "explicitly invoking a different constructor in '{0}'.",
- uniqueName: 'NO_DEFAULT_SUPER_CONSTRUCTOR_EXPLICIT',
- );
-
- /**
- * User friendly specialized error for [NON_GENERATIVE_CONSTRUCTOR]. This
- * handles the case of `class E extends Exception` which will never work
- * because [Exception] has no generative constructors.
- *
- * Parameters:
- * 0: the name of the subclass
- * 1: the name of the superclass
- */
- static const CompileTimeErrorCode NO_GENERATIVE_CONSTRUCTORS_IN_SUPERCLASS =
- CompileTimeErrorCode(
- 'NO_GENERATIVE_CONSTRUCTORS_IN_SUPERCLASS',
- "The class '{0}' cannot extend '{1}' because '{1}' only has factory "
- "constructors (no generative constructors), and '{0}' has at "
- "least one generative constructor.",
- correction: "Try implementing the class instead, adding a generative "
- "(not factory) constructor to the superclass {0}, or a factory "
- "constructor to the subclass.");
-
- /**
- * Parameters:
- * 0: the name of the superclass that does not define an implicitly invoked
- * constructor
- * 1: the name of the subclass that does not contain any explicit constructors
- */
- static const CompileTimeErrorCode NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT =
- CompileTimeErrorCode(
- 'NO_DEFAULT_SUPER_CONSTRUCTOR',
- "The superclass '{0}' doesn't have a zero argument constructor.",
- correction: "Try declaring a zero argument constructor in '{0}', or "
- "declaring a constructor in {1} that explicitly invokes a "
- "constructor in '{0}'.",
- uniqueName: 'NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT',
- );
-
- /**
- * Parameters:
- * 0: the name of the first member
- * 1: the name of the second member
- * 2: the name of the third member
- * 3: the name of the fourth member
- * 4: the number of additional missing members that aren't listed
- */
- static const CompileTimeErrorCode
- NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FIVE_PLUS =
- CompileTimeErrorCode(
- 'NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER',
- "Missing concrete implementations of '{0}', '{1}', '{2}', '{3}', and "
- "{4} more.",
- correction: "Try implementing the missing methods, or make the class "
- "abstract.",
- hasPublishedDocs: true,
- uniqueName: 'NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FIVE_PLUS',
- );
-
- /**
- * Parameters:
- * 0: the name of the first member
- * 1: the name of the second member
- * 2: the name of the third member
- * 3: the name of the fourth member
- */
- static const CompileTimeErrorCode
- NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FOUR = CompileTimeErrorCode(
- 'NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER',
- "Missing concrete implementations of '{0}', '{1}', '{2}', and '{3}'.",
- correction: "Try implementing the missing methods, or make the class "
- "abstract.",
- hasPublishedDocs: true,
- uniqueName: 'NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FOUR',
- );
-
- /**
- * Parameters:
- * 0: the name of the member
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a concrete class inherits one or
- // more abstract members, and doesn't provide or inherit an implementation for
- // at least one of those abstract members.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because the class `B` doesn't
- // have a concrete implementation of `m`:
- //
- // ```dart
- // abstract class A {
- // void m();
- // }
- //
- // class [!B!] extends A {}
- // ```
- //
- // #### Common fixes
- //
- // If the subclass can provide a concrete implementation for some or all of
- // the abstract inherited members, then add the concrete implementations:
- //
- // ```dart
- // abstract class A {
- // void m();
- // }
- //
- // class B extends A {
- // void m() {}
- // }
- // ```
- //
- // If there is a mixin that provides an implementation of the inherited
- // methods, then apply the mixin to the subclass:
- //
- // ```dart
- // abstract class A {
- // void m();
- // }
- //
- // class B extends A with M {}
- //
- // mixin M {
- // void m() {}
- // }
- // ```
- //
- // If the subclass can't provide a concrete implementation for all of the
- // abstract inherited members, then mark the subclass as being abstract:
- //
- // ```dart
- // abstract class A {
- // void m();
- // }
- //
- // abstract class B extends A {}
- // ```
- static const CompileTimeErrorCode
- NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE = CompileTimeErrorCode(
- 'NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER',
- "Missing concrete implementation of '{0}'.",
- correction: "Try implementing the missing method, or make the class "
- "abstract.",
- hasPublishedDocs: true,
- uniqueName: 'NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE',
- );
-
- /**
- * Parameters:
- * 0: the name of the first member
- * 1: the name of the second member
- * 2: the name of the third member
- */
- static const CompileTimeErrorCode
- NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_THREE = CompileTimeErrorCode(
- 'NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER',
- "Missing concrete implementations of '{0}', '{1}', and '{2}'.",
- correction: "Try implementing the missing methods, or make the class "
- "abstract.",
- hasPublishedDocs: true,
- uniqueName: 'NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_THREE',
- );
-
- /**
- * Parameters:
- * 0: the name of the first member
- * 1: the name of the second member
- */
- static const CompileTimeErrorCode
- NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_TWO = CompileTimeErrorCode(
- 'NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER',
- "Missing concrete implementations of '{0}' and '{1}'.",
- correction: "Try implementing the missing methods, or make the class "
- "abstract.",
- hasPublishedDocs: true,
- uniqueName: 'NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_TWO',
- );
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a condition, such as an `if` or
- // `while` loop, doesn't have the static type `bool`.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `x` has the static type
- // `int`:
- //
- // ```dart
- // void f(int x) {
- // if ([!x!]) {
- // // ...
- // }
- // }
- // ```
- //
- // #### Common fixes
- //
- // Change the condition so that it produces a Boolean value:
- //
- // ```dart
- // void f(int x) {
- // if (x == 0) {
- // // ...
- // }
- // }
- // ```
- static const CompileTimeErrorCode NON_BOOL_CONDITION = CompileTimeErrorCode(
- 'NON_BOOL_CONDITION', "Conditions must have a static type of 'bool'.",
- correction: "Try changing the condition.", hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the first expression in an
- // assert has a type other than `bool`.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because the type of `p` is
- // `int`, but a `bool` is required:
- //
- // ```dart
- // void f(int p) {
- // assert([!p!]);
- // }
- // ```
- //
- // #### Common fixes
- //
- // Change the expression so that it has the type `bool`:
- //
- // ```dart
- // void f(int p) {
- // assert(p > 0);
- // }
- // ```
- static const CompileTimeErrorCode NON_BOOL_EXPRESSION = CompileTimeErrorCode(
- 'NON_BOOL_EXPRESSION',
- "The expression in an assert must be of type 'bool'.",
- correction: "Try changing the expression.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the operand of the unary
- // negation operator (`!`) doesn't have the type `bool`.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `x` is an `int` when it
- // must be a `bool`:
- //
- // ```dart
- // int x = 0;
- // bool y = ![!x!];
- // ```
- //
- // #### Common fixes
- //
- // Replace the operand with an expression that has the type `bool`:
- //
- // ```dart
- // int x = 0;
- // bool y = !(x > 0);
- // ```
- static const CompileTimeErrorCode NON_BOOL_NEGATION_EXPRESSION =
- CompileTimeErrorCode('NON_BOOL_NEGATION_EXPRESSION',
- "A negation operand must have a static type of 'bool'.",
- correction: "Try changing the operand to the '!' operator.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the lexeme of the logical operator
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when one of the operands of either
- // the `&&` or `||` operator doesn't have the type `bool`.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `a` isn't a Boolean
- // value:
- //
- // ```dart
- // int a = 3;
- // bool b = [!a!] || a > 1;
- // ```
- //
- // #### Common fixes
- //
- // Change the operand to a Boolean value:
- //
- // ```dart
- // int a = 3;
- // bool b = a == 0 || a > 1;
- // ```
- static const CompileTimeErrorCode NON_BOOL_OPERAND = CompileTimeErrorCode(
- 'NON_BOOL_OPERAND',
- "The operands of the operator '{0}' must be assignable to 'bool'.",
- hasPublishedDocs: true);
-
- /**
- * 13.2 Expression Statements: It is a compile-time error if a non-constant
- * map literal that has no explicit type arguments appears in a place where a
- * statement is expected.
- */
- static const CompileTimeErrorCode NON_CONST_MAP_AS_EXPRESSION_STATEMENT =
- CompileTimeErrorCode(
- 'NON_CONST_MAP_AS_EXPRESSION_STATEMENT',
- "A non-constant map or set literal without type arguments can't be "
- "used as an expression statement.");
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an annotation is the invocation
- // of an existing constructor even though the invoked constructor isn't a
- // const constructor.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the constructor for `C`
- // isn't a const constructor:
- //
- // ```dart
- // [!@C()!]
- // void f() {
- // }
- //
- // class C {
- // C();
- // }
- // ```
- //
- // #### Common fixes
- //
- // If it's valid for the class to have a const constructor, then create a
- // const constructor that can be used for the annotation:
- //
- // ```dart
- // @C()
- // void f() {
- // }
- //
- // class C {
- // const C();
- // }
- // ```
- //
- // If it isn't valid for the class to have a const constructor, then either
- // remove the annotation or use a different class for the annotation.
- static const CompileTimeErrorCode NON_CONSTANT_ANNOTATION_CONSTRUCTOR =
- CompileTimeErrorCode('NON_CONSTANT_ANNOTATION_CONSTRUCTOR',
- "Annotation creation can only call a const constructor.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the expression in a `case`
- // clause isn't a constant expression.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `j` isn't a constant:
- //
- // ```dart
- // void f(int i, int j) {
- // switch (i) {
- // case [!j!]:
- // // ...
- // break;
- // }
- // }
- // ```
- //
- // #### Common fixes
- //
- // Either make the expression a constant expression, or rewrite the `switch`
- // statement as a sequence of `if` statements:
- //
- // ```dart
- // void f(int i, int j) {
- // if (i == j) {
- // // ...
- // }
- // }
- // ```
- static const CompileTimeErrorCode NON_CONSTANT_CASE_EXPRESSION =
- CompileTimeErrorCode(
- 'NON_CONSTANT_CASE_EXPRESSION', "Case expressions must be constant.",
- hasPublishedDocs: true);
-
- /**
- * 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',
- "Constant values from a deferred library can't be used as a case "
- "expression.",
- correction:
- "Try re-writing the switch as a series of if statements, or "
- "changing the import to not be deferred.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an optional parameter, either
- // named or positional, has a default value that isn't a compile-time
- // constant.
- //
- // #### Examples
- //
- // The following code produces this diagnostic:
- //
- // ```dart
- // %language=2.9
- // var defaultValue = 3;
- //
- // void f([int value = [!defaultValue!]]) {}
- // ```
- //
- // #### Common fixes
- //
- // If the default value can be converted to be a constant, then convert it:
- //
- // ```dart
- // %language=2.9
- // const defaultValue = 3;
- //
- // void f([int value = defaultValue]) {}
- // ```
- //
- // If the default value needs to change over time, then apply the default
- // value inside the function:
- //
- // ```dart
- // %language=2.9
- // var defaultValue = 3;
- //
- // void f([int value]) {
- // value ??= defaultValue;
- // }
- // ```
- static const CompileTimeErrorCode NON_CONSTANT_DEFAULT_VALUE =
- CompileTimeErrorCode('NON_CONSTANT_DEFAULT_VALUE',
- "The default value of an optional parameter must be constant.",
- hasPublishedDocs: true);
-
- /**
- * 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',
- "Constant values from a deferred library can't be used as a default "
- "parameter value.",
- correction:
- "Try leaving the default as null and initializing the parameter "
- "inside the function body.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an element in a constant list
- // literal isn't a constant value. The list literal can be constant either
- // explicitly (because it's prefixed by the `const` keyword) or implicitly
- // (because it appears in a [constant context][]).
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `x` isn't a constant,
- // even though it appears in an implicitly constant list literal:
- //
- // ```dart
- // var x = 2;
- // var y = const <int>[0, 1, [!x!]];
- // ```
- //
- // #### Common fixes
- //
- // If the list needs to be a constant list, then convert the element to be a
- // constant. In the example above, you might add the `const` keyword to the
- // declaration of `x`:
- //
- // ```dart
- // const x = 2;
- // var y = const <int>[0, 1, x];
- // ```
- //
- // If the expression can't be made a constant, then the list can't be a
- // constant either, so you must change the code so that the list isn't a
- // constant. In the example above this means removing the `const` keyword
- // before the list literal:
- //
- // ```dart
- // var x = 2;
- // var y = <int>[0, 1, x];
- // ```
- static const CompileTimeErrorCode NON_CONSTANT_LIST_ELEMENT =
- CompileTimeErrorCode('NON_CONSTANT_LIST_ELEMENT',
- "The values in a const list literal must be constants.",
- correction: "Try removing the keyword 'const' from the list literal.",
- hasPublishedDocs: true);
-
- /**
- * 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 literal.",
- correction: "Try removing the keyword 'const' from the list literal "
- "or removing the keyword 'deferred' from the import.",
- hasPublishedDocs: true,
- uniqueName: 'NON_CONSTANT_LIST_ELEMENT_FROM_DEFERRED_LIBRARY');
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an `if` element or a spread
- // element in a constant map isn't a constant element.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because it's attempting to
- // spread a non-constant map:
- //
- // ```dart
- // var notConst = <int, int>{};
- // var map = const <int, int>{...[!notConst!]};
- // ```
- //
- // Similarly, the following code produces this diagnostic because the
- // condition in the `if` element isn't a constant expression:
- //
- // ```dart
- // bool notConst = true;
- // var map = const <int, int>{if ([!notConst!]) 1 : 2};
- // ```
- //
- // #### Common fixes
- //
- // If the map needs to be a constant map, then make the elements constants.
- // In the spread example, you might do that by making the collection being
- // spread a constant:
- //
- // ```dart
- // const notConst = <int, int>{};
- // var map = const <int, int>{...notConst};
- // ```
- //
- // If the map doesn't need to be a constant map, then remove the `const`
- // keyword:
- //
- // ```dart
- // bool notConst = true;
- // var map = <int, int>{if (notConst) 1 : 2};
- // ```
- static const CompileTimeErrorCode NON_CONSTANT_MAP_ELEMENT =
- CompileTimeErrorCode('NON_CONSTANT_MAP_ELEMENT',
- "The elements in a const map literal must be constant.",
- correction: "Try removing the keyword 'const' from the map literal.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a key in a constant map literal
- // isn't a constant value.
- //
- // #### Examples
- //
- // The following code produces this diagnostic beause `a` isn't a constant:
- //
- // ```dart
- // var a = 'a';
- // var m = const {[!a!]: 0};
- // ```
- //
- // #### Common fixes
- //
- // If the map needs to be a constant map, then make the key a constant:
- //
- // ```dart
- // const a = 'a';
- // var m = const {a: 0};
- // ```
- //
- // If the map doesn't need to be a constant map, then remove the `const`
- // keyword:
- //
- // ```dart
- // var a = 'a';
- // var m = {a: 0};
- // ```
- static const CompileTimeErrorCode NON_CONSTANT_MAP_KEY = CompileTimeErrorCode(
- 'NON_CONSTANT_MAP_KEY',
- "The keys in a const map literal must be constant.",
- correction: "Try removing the keyword 'const' from the map literal.",
- hasPublishedDocs: true);
-
- /**
- * 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 or removing "
- "the keyword 'deferred' from the import.",
- hasPublishedDocs: true,
- uniqueName: 'NON_CONSTANT_MAP_KEY_FROM_DEFERRED_LIBRARY');
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a value in a constant map
- // literal isn't a constant value.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `a` isn't a constant:
- //
- // ```dart
- // var a = 'a';
- // var m = const {0: [!a!]};
- // ```
- //
- // #### Common fixes
- //
- // If the map needs to be a constant map, then make the key a constant:
- //
- // ```dart
- // const a = 'a';
- // var m = const {0: a};
- // ```
- //
- // If the map doesn't need to be a constant map, then remove the `const`
- // keyword:
- //
- // ```dart
- // var a = 'a';
- // var m = {0: a};
- // ```
- static const CompileTimeErrorCode NON_CONSTANT_MAP_VALUE =
- CompileTimeErrorCode('NON_CONSTANT_MAP_VALUE',
- "The values in a const map literal must be constant.",
- correction: "Try removing the keyword 'const' from the map literal.",
- hasPublishedDocs: true);
-
- /**
- * 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 or removing "
- "the keyword 'deferred' from the import.",
- hasPublishedDocs: true,
- uniqueName: 'NON_CONSTANT_MAP_VALUE_FROM_DEFERRED_LIBRARY');
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a constant set literal contains
- // an element that isn't a compile-time constant.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `i` isn't a constant:
- //
- // ```dart
- // var i = 0;
- //
- // var s = const {[!i!]};
- // ```
- //
- // #### Common fixes
- //
- // If the element can be changed to be a constant, then change it:
- //
- // ```dart
- // const i = 0;
- //
- // var s = const {i};
- // ```
- //
- // If the element can't be a constant, then remove the keyword `const`:
- //
- // ```dart
- // var i = 0;
- //
- // var s = {i};
- // ```
- static const CompileTimeErrorCode NON_CONSTANT_SET_ELEMENT =
- CompileTimeErrorCode('NON_CONSTANT_SET_ELEMENT',
- "The values in a const set literal must be constants.",
- correction: "Try removing the keyword 'const' from the set literal.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the non-generative constructor
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the initializer list of a
- // constructor invokes a constructor from the superclass, and the invoked
- // constructor is a factory constructor. Only a generative constructor can be
- // invoked in the initializer list.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the invocation of the
- // constructor `super.one()` is invoking a factory constructor:
- //
- // ```dart
- // class A {
- // factory A.one() = B;
- // A.two();
- // }
- //
- // class B extends A {
- // B() : [!super.one()!];
- // }
- // ```
- //
- // #### Common fixes
- //
- // Change the super invocation to invoke a generative constructor:
- //
- // ```dart
- // class A {
- // factory A.one() = B;
- // A.two();
- // }
- //
- // class B extends A {
- // B() : super.two();
- // }
- // ```
- //
- // If the generative constructor is the unnamed constructor, and if there are
- // no arguments being passed to it, then you can remove the super invocation.
- static const CompileTimeErrorCode NON_GENERATIVE_CONSTRUCTOR =
- CompileTimeErrorCode(
- 'NON_GENERATIVE_CONSTRUCTOR',
- "The generative constructor '{0}' is expected, but a factory was "
- "found.",
- correction:
- "Try calling a different constructor of the superclass, or "
- "making the called constructor not be a factory constructor.",
- hasPublishedDocs: true);
-
- /**
- * An error code for when a class has no explicit constructor, and therefore
- * a constructor is implicitly defined which uses a factory as a
- * superinitializer. See [NON_GENERATIVE_CONSTRUCTOR].
- *
- * Parameters:
- * 0: the name of the superclass
- * 1: the name of the current class
- * 2: the implicitly called factory constructor of the superclass
- */
- static const CompileTimeErrorCode NON_GENERATIVE_IMPLICIT_CONSTRUCTOR =
- CompileTimeErrorCode(
- 'NON_GENERATIVE_IMPLICIT_CONSTRUCTOR',
- "The unnamed constructor of superclass '{0}' (called by the default "
- "constructor of '{1}') must be a generative constructor, "
- "but factory found.",
- correction: "Try adding an explicit constructor that has a different "
- "superinitializer or changing the superclass constructor '{2}' "
- "to not be a factory constructor.");
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the body of a factory
- // constructor is marked with `async`, `async*`, or `sync*`. All constructors,
- // including factory constructors, are required to return an instance of the
- // class in which they're declared, not a `Future`, `Stream`, or `Iterator`.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the body of the factory
- // constructor is marked with `async`:
- //
- // ```dart
- // class C {
- // factory C() [!async!] {
- // return C._();
- // }
- // C._();
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the member must be declared as a factory constructor, then remove the
- // keyword appearing before the body:
- //
- // ```dart
- // class C {
- // factory C() {
- // return C._();
- // }
- // C._();
- // }
- // ```
- //
- // If the member must return something other than an instance of the enclosing
- // class, then make the member a static method:
- //
- // ```dart
- // class C {
- // static Future<C> m() async {
- // return C._();
- // }
- // C._();
- // }
- // ```
- static const CompileTimeErrorCode NON_SYNC_FACTORY = CompileTimeErrorCode(
- 'NON_SYNC_FACTORY',
- "Factory bodies can't use 'async', 'async*', or 'sync*'.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name appearing where a type is expected
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an identifier that isn't a type
- // is used as a type argument.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `x` is a variable, not
- // a type:
- //
- // ```dart
- // var x = 0;
- // List<[!x!]> xList = [];
- // ```
- //
- // #### Common fixes
- //
- // Change the type argument to be a type:
- //
- // ```dart
- // var x = 0;
- // List<int> xList = [];
- // ```
- static const CompileTimeErrorCode NON_TYPE_AS_TYPE_ARGUMENT =
- CompileTimeErrorCode('NON_TYPE_AS_TYPE_ARGUMENT',
- "The name '{0}' isn't a type so it can't be used as a type argument.",
- correction: "Try correcting the name to an existing type, or "
- "defining a type named '{0}'.",
- hasPublishedDocs: true,
- isUnresolvedIdentifier: true);
-
- /**
- * Parameters:
- * 0: the name of the non-type element
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the identifier following the
- // `on` in a `catch` clause is defined to be something other than a type.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `f` is a function, not
- // a type:
- //
- // ```dart
- // %language=2.9
- // void f() {
- // try {
- // // ...
- // } on [!f!] {
- // // ...
- // }
- // }
- // ```
- //
- // #### Common fixes
- //
- // Change the name to the type of object that should be caught:
- //
- // ```dart
- // %language=2.9
- // void f() {
- // try {
- // // ...
- // } on FormatException {
- // // ...
- // }
- // }
- // ```
- static const CompileTimeErrorCode NON_TYPE_IN_CATCH_CLAUSE =
- CompileTimeErrorCode(
- 'NON_TYPE_IN_CATCH_CLAUSE',
- "The name '{0}' isn't a type and can't be used in an on-catch "
- "clause.",
- correction: "Try correcting the name to match an existing class.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a declaration of the operator
- // `[]=` has a return type other than `void`.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the declaration of the
- // operator `[]=` has a return type of `int`:
- //
- // ```dart
- // class C {
- // [!int!] operator []=(int index, int value) => 0;
- // }
- // ```
- //
- // #### Common fixes
- //
- // Change the return type to `void`:
- //
- // ```dart
- // class C {
- // void operator []=(int index, int value) => 0;
- // }
- // ```
- static const CompileTimeErrorCode NON_VOID_RETURN_FOR_OPERATOR =
- CompileTimeErrorCode('NON_VOID_RETURN_FOR_OPERATOR',
- "The return type of the operator []= must be 'void'.",
- correction: "Try changing the return type to 'void'.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a setter is defined with a
- // return type other than `void`.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the setter `p` has a
- // return type of `int`:
- //
- // ```dart
- // class C {
- // [!int!] set p(int i) => 0;
- // }
- // ```
- //
- // #### Common fixes
- //
- // Change the return type to `void` or omit the return type:
- //
- // ```dart
- // class C {
- // set p(int i) => 0;
- // }
- // ```
- static const CompileTimeErrorCode NON_VOID_RETURN_FOR_SETTER =
- CompileTimeErrorCode('NON_VOID_RETURN_FOR_SETTER',
- "The return type of the setter must be 'void' or absent.",
- correction: "Try removing the return type, or "
- "define a method rather than a setter.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name that is not a type
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a name is used as a type but
- // declared to be something other than a type.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `f` is a function:
- //
- // ```dart
- // f() {}
- // g([!f!] v) {}
- // ```
- //
- // #### Common fixes
- //
- // Replace the name with the name of a type.
- static const CompileTimeErrorCode NOT_A_TYPE = CompileTimeErrorCode(
- 'NOT_A_TYPE', "{0} isn't a type.",
- correction: "Try correcting the name to match an existing type.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the variable that is invalid
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a local variable is referenced
- // and has all these characteristics:
- // - Has a type that's [potentially non-nullable][].
- // - Doesn't have an initializer.
- // - Isn't marked as `late`.
- // - The analyzer can't prove that the local variable will be assigned before
- // the reference based on the specification of [definite assignment][].
- //
- // #### Example
- //
- // The following code produces this diagnostic because `x` can't have a value
- // of `null`, but is referenced before a value was assigned to it:
- //
- // ```dart
- // String f() {
- // int x;
- // return [!x!].toString();
- // }
- // ```
- //
- // The following code produces this diagnostic because the assignment to `x`
- // might not be executed, so it might have a value of `null`:
- //
- // ```dart
- // int g(bool b) {
- // int x;
- // if (b) {
- // x = 1;
- // }
- // return [!x!] * 2;
- // }
- // ```
- //
- // The following code produces this diagnostic because the analyzer can't
- // prove, based on definite assignment analysis, that `x` won't be referenced
- // without having a value assigned to it:
- //
- // ```dart
- // int h(bool b) {
- // int x;
- // if (b) {
- // x = 1;
- // }
- // if (b) {
- // return [!x!] * 2;
- // }
- // return 0;
- // }
- // ```
- //
- // #### Common fixes
- //
- // If `null` is a valid value, then make the variable nullable:
- //
- // ```dart
- // String f() {
- // int? x;
- // return x!.toString();
- // }
- // ```
- //
- // If `null` isn’t a valid value, and there's a reasonable default value, then
- // add an initializer:
- //
- // ```dart
- // int g(bool b) {
- // int x = 2;
- // if (b) {
- // x = 1;
- // }
- // return x * 2;
- // }
- // ```
- //
- // Otherwise, ensure that a value was assigned on every possible code path
- // before the value is accessed:
- //
- // ```dart
- // int g(bool b) {
- // int x;
- // if (b) {
- // x = 1;
- // } else {
- // x = 2;
- // }
- // return x * 2;
- // }
- // ```
- //
- // You can also mark the variable as `late`, which removes the diagnostic, but
- // if the variable isn't assigned a value before it's accessed, then it
- // results in an exception being thrown at runtime. This approach should only
- // be used if you're sure that the variable will always be assigned, even
- // though the analyzer can't prove it based on definite assignment analysis.
- //
- // ```dart
- // int h(bool b) {
- // late int x;
- // if (b) {
- // x = 1;
- // }
- // if (b) {
- // return x * 2;
- // }
- // return 0;
- // }
- // ```
- static const CompileTimeErrorCode
- NOT_ASSIGNED_POTENTIALLY_NON_NULLABLE_LOCAL_VARIABLE =
- CompileTimeErrorCode(
- 'NOT_ASSIGNED_POTENTIALLY_NON_NULLABLE_LOCAL_VARIABLE',
- "The non-nullable local variable '{0}' must be assigned before it "
- "can be used.",
- correction: "Try giving it an initializer expression, or ensure that "
- "it's assigned on every execution path.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the operator that is not a binary operator.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an operator that can only be
- // used as a unary operator is used as a binary operator.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the operator `~` can
- // only be used as a unary operator:
- //
- // ```dart
- // var a = 5 [!~!] 3;
- // ```
- //
- // #### Common fixes
- //
- // Replace the operator with the correct binary operator:
- //
- // ```dart
- // var a = 5 - 3;
- // ```
- static const CompileTimeErrorCode NOT_BINARY_OPERATOR = CompileTimeErrorCode(
- 'NOT_BINARY_OPERATOR', "'{0}' isn't a binary operator.");
-
- /**
- * Parameters:
- * 0: the expected number of required arguments
- * 1: the actual number of positional arguments given
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a method or function invocation
- // has fewer positional arguments than the number of required positional
- // parameters.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `f` declares two
- // required parameters, but only one argument is provided:
- //
- // ```dart
- // void f(int a, int b) {}
- // void g() {
- // f[!(0)!];
- // }
- // ```
- //
- // #### Common fixes
- //
- // Add arguments corresponding to the remaining parameters:
- //
- // ```dart
- // void f(int a, int b) {}
- // void g() {
- // f(0, 1);
- // }
- // ```
- static const CompileTimeErrorCode NOT_ENOUGH_POSITIONAL_ARGUMENTS =
- CompileTimeErrorCode('NOT_ENOUGH_POSITIONAL_ARGUMENTS',
- "{0} positional argument(s) expected, but {1} found.",
- correction: "Try adding the missing arguments.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the field that is not initialized
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a field is declared and has all
- // these characteristics:
- // - Has a type that's [potentially non-nullable][]
- // - Doesn't have an initializer
- // - Isn't marked as `late`
- //
- // #### Example
- //
- // The following code produces this diagnostic because `x` is implicitly
- // initialized to `null` when it isn't allowed to be `null`:
- //
- // ```dart
- // class C {
- // int [!x!];
- // }
- // ```
- //
- // Similarly, the following code produces this diagnostic because `x` is
- // implicitly initialized to `null`, when it isn't allowed to be `null`, by
- // one of the constructors, even though it's initialized by other
- // constructors:
- //
- // ```dart
- // class C {
- // int x;
- //
- // C(this.x);
- //
- // [!C!].n();
- // }
- // ```
- //
- // #### Common fixes
- //
- // If there's a reasonable default value for the field that’s the same for all
- // instances, then add an initializer expression:
- //
- // ```dart
- // class C {
- // int x = 0;
- // }
- // ```
- //
- // If the value of the field should be provided when an instance is created,
- // then add a constructor that sets the value of the field or update an
- // existing constructor:
- //
- // ```dart
- // class C {
- // int x;
- //
- // C(this.x);
- // }
- // ```
- //
- // You can also mark the field as `late`, which removes the diagnostic, but if
- // the field isn't assigned a value before it's accessed, then it results in
- // an exception being thrown at runtime. This approach should only be used if
- // you're sure that the field will always be assigned before it's referenced.
- //
- // ```dart
- // class C {
- // late int x;
- // }
- // ```
- static const CompileTimeErrorCode
- NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD = CompileTimeErrorCode(
- 'NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD',
- "Non-nullable instance field '{0}' must be initialized.",
- correction: "Try adding an initializer expression, "
- "or a generative constructor that initializes it, "
- "or mark it 'late'.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the field that is not initialized
- */
- static const CompileTimeErrorCode
- NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD_CONSTRUCTOR =
- CompileTimeErrorCode(
- 'NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD',
- "Non-nullable instance field '{0}' must be initialized.",
- correction: "Try adding an initializer expression, "
- "or add a field initializer in this constructor, "
- "or mark it 'late'.",
- hasPublishedDocs: true,
- uniqueName: 'NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD_CONSTRUCTOR',
- );
-
- /**
- * Parameters:
- * 0: the name of the variable that is invalid
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a static field or top-level
- // variable has a type that's non-nullable and doesn't have an initializer.
- // Fields and variables that don't have an initializer are normally
- // initialized to `null`, but the type of the field or variable doesn't allow
- // it to be set to `null`, so an explicit initializer must be provided.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the field `f` can't be
- // initialized to `null`:
- //
- // ```dart
- // class C {
- // static int [!f!];
- // }
- // ```
- //
- // Similarly, the following code produces this diagnostic because the
- // top-level variable `v` can't be initialized to `null`:
- //
- // ```dart
- // int [!v!];
- // ```
- //
- // #### Common fixes
- //
- // If the field or variable can't be initialized to `null`, then add an
- // initializer that sets it to a non-null value:
- //
- // ```dart
- // class C {
- // static int f = 0;
- // }
- // ```
- //
- // If the field or variable should be initialized to `null`, then change the
- // type to be nullable:
- //
- // ```dart
- // int? v;
- // ```
- //
- // If the field or variable can't be initialized in the declaration but will
- // always be initialized before it's referenced, then mark it as being `late`:
- //
- // ```dart
- // class C {
- // static late int f;
- // }
- // ```
- static const CompileTimeErrorCode NOT_INITIALIZED_NON_NULLABLE_VARIABLE =
- CompileTimeErrorCode('NOT_INITIALIZED_NON_NULLABLE_VARIABLE',
- "The non-nullable variable '{0}' must be initialized.",
- correction: "Try adding an initializer expression.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- static const CompileTimeErrorCode NOT_INSTANTIATED_BOUND =
- CompileTimeErrorCode('NOT_INSTANTIATED_BOUND',
- 'Type parameter bound types must be instantiated.',
- correction: 'Try adding type arguments to the type parameter bound.');
-
- /**
- * 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.',
- correction:
- '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 the static type of the
- // expression of a spread element that appears in either a list literal or a
- // set literal doesn't implement the type `Iterable`.
- //
- // #### Examples
- //
- // The following code produces this diagnostic:
- //
- // ```dart
- // var m = <String, int>{'a': 0, 'b': 1};
- // var s = <String>{...[!m!]};
- // ```
- //
- // #### Common fixes
- //
- // The most common fix is to replace the expression with one that produces an
- // iterable object:
- //
- // ```dart
- // var m = <String, int>{'a': 0, 'b': 1};
- // var s = <String>{...m.keys};
- // ```
- static const CompileTimeErrorCode NOT_ITERABLE_SPREAD = CompileTimeErrorCode(
- 'NOT_ITERABLE_SPREAD',
- "Spread elements in list or set literals must implement 'Iterable'.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the static type of the
- // expression of a spread element that appears in a map literal doesn't
- // implement the type `Map`.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `l` isn't a `Map`:
- //
- // ```dart
- // var l = <String>['a', 'b'];
- // var m = <int, String>{...[!l!]};
- // ```
- //
- // #### Common fixes
- //
- // The most common fix is to replace the expression with one that produces a
- // map:
- //
- // ```dart
- // var l = <String>['a', 'b'];
- // var m = <int, String>{...l.asMap()};
- // ```
- static const CompileTimeErrorCode NOT_MAP_SPREAD = CompileTimeErrorCode(
- 'NOT_MAP_SPREAD', "Spread elements in map literals must implement 'Map'.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- static const CompileTimeErrorCode NOT_NULL_AWARE_NULL_SPREAD =
- CompileTimeErrorCode(
- 'NOT_NULL_AWARE_NULL_SPREAD',
- "The Null typed expression can't be used with a non-null-aware "
- "spread.");
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a class declaration uses an
- // `extends` clause to specify a superclass, and the superclass is followed by
- // a `?`.
- //
- // It isn't valid to specify a nullable superclass because doing so would have
- // no meaning; it wouldn't change either the interface or implementation being
- // inherited by the class containing the `extends` clause.
- //
- // Note, however, that it _is_ valid to use a nullable type as a type argument
- // to the superclass, such as `class A extends B<C?> {}`.
- //
- // #### Example
- //
- // The following code produces this diagnostic because `A?` is a nullable
- // type, and nullable types can't be used in an `extends` clause:
- //
- // ```dart
- // class A {}
- // class B extends [!A?!] {}
- // ```
- //
- // #### Common fixes
- //
- // Remove the question mark from the type:
- //
- // ```dart
- // class A {}
- // class B extends A {}
- // ```
- static const CompileTimeErrorCode NULLABLE_TYPE_IN_EXTENDS_CLAUSE =
- CompileTimeErrorCode('NULLABLE_TYPE_IN_EXTENDS_CLAUSE',
- "A class can't extend a nullable type.",
- correction: "Try removing the question mark.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a class or mixin declaration has
- // an `implements` clause, and an interface is followed by a `?`.
- //
- // It isn't valid to specify a nullable interface because doing so would have
- // no meaning; it wouldn't change the interface being inherited by the class
- // containing the `implements` clause.
- //
- // Note, however, that it _is_ valid to use a nullable type as a type argument
- // to the interface, such as `class A implements B<C?> {}`.
- //
- //
- // #### Example
- //
- // The following code produces this diagnostic because `A?` is a nullable
- // type, and nullable types can't be used in an `implements` clause:
- //
- // ```dart
- // class A {}
- // class B implements [!A?!] {}
- // ```
- //
- // #### Common fixes
- //
- // Remove the question mark from the type:
- //
- // ```dart
- // class A {}
- // class B implements A {}
- // ```
- static const CompileTimeErrorCode NULLABLE_TYPE_IN_IMPLEMENTS_CLAUSE =
- CompileTimeErrorCode('NULLABLE_TYPE_IN_IMPLEMENTS_CLAUSE',
- "A class or mixin can't implement a nullable type.",
- correction: "Try removing the question mark.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a mixin declaration uses an `on`
- // clause to specify a superclass constraint, and the class that's specified
- // is followed by a `?`.
- //
- // It isn't valid to specify a nullable superclass constraint because doing so
- // would have no meaning; it wouldn't change the interface being depended on
- // by the mixin containing the `on` clause.
- //
- // Note, however, that it _is_ valid to use a nullable type as a type argument
- // to the superclass constraint, such as `mixin A on B<C?> {}`.
- //
- //
- // #### Example
- //
- // The following code produces this diagnostic because `A?` is a nullable type
- // and nullable types can't be used in an `on` clause:
- //
- // ```dart
- // class C {}
- // mixin M on [!C?!] {}
- // ```
- //
- // #### Common fixes
- //
- // Remove the question mark from the type:
- //
- // ```dart
- // class C {}
- // mixin M on C {}
- // ```
- static const CompileTimeErrorCode NULLABLE_TYPE_IN_ON_CLAUSE =
- CompileTimeErrorCode('NULLABLE_TYPE_IN_ON_CLAUSE',
- "A mixin can't have a nullable type as a superclass constraint.",
- correction: "Try removing the question mark.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a class or mixin declaration has
- // a `with` clause, and a mixin is followed by a `?`.
- //
- // It isn't valid to specify a nullable mixin because doing so would have no
- // meaning; it wouldn't change either the interface or implementation being
- // inherited by the class containing the `with` clause.
- //
- // Note, however, that it _is_ valid to use a nullable type as a type argument
- // to the mixin, such as `class A with B<C?> {}`.
- //
- // #### Example
- //
- // The following code produces this diagnostic because `A?` is a nullable
- // type, and nullable types can't be used in a `with` clause:
- //
- // ```dart
- // mixin M {}
- // class C with [!M?!] {}
- // ```
- //
- // #### Common fixes
- //
- // Remove the question mark from the type:
- //
- // ```dart
- // mixin M {}
- // class C with M {}
- // ```
- static const CompileTimeErrorCode NULLABLE_TYPE_IN_WITH_CLAUSE =
- CompileTimeErrorCode('NULLABLE_TYPE_IN_WITH_CLAUSE',
- "A class or mixin can't mix in a nullable type.",
- correction: "Try removing the question mark.",
- hasPublishedDocs: true);
-
- /**
- * 7.9 Superclasses: It is a compile-time error to specify an extends clause
- * for class Object.
- */
- static const CompileTimeErrorCode OBJECT_CANNOT_EXTEND_ANOTHER_CLASS =
- CompileTimeErrorCode('OBJECT_CANNOT_EXTEND_ANOTHER_CLASS',
- "The class 'Object' can't extend any other class.");
-
- /**
- * Parameters:
- * 0: the name of the interface that is implemented more than once
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the same type is listed in the
- // superclass constraints of a mixin multiple times.
- //
- // #### Example
- //
- // The following code produces this diagnostic because `A` is included twice
- // in the superclass constraints for `M`:
- //
- // ```dart
- // mixin M on A, [!A!] {
- // }
- //
- // class A {}
- // class B {}
- // ```
- //
- // #### Common fixes
- //
- // If a different type should be included in the superclass constraints, then
- // replace one of the occurrences with the other type:
- //
- // ```dart
- // mixin M on A, B {
- // }
- //
- // class A {}
- // class B {}
- // ```
- //
- // If no other type was intended, then remove the repeated type name:
- //
- // ```dart
- // mixin M on A {
- // }
- //
- // class A {}
- // class B {}
- // ```
- static const CompileTimeErrorCode ON_REPEATED = CompileTimeErrorCode(
- 'ON_REPEATED',
- "The type '{0}' can be included in the superclass constraints only once.",
- correction: "Try removing all except one occurrence of the type name.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when one or more of the parameters in
- // an operator declaration are optional.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the parameter `other`
- // is an optional parameter:
- //
- // ```dart
- // class C {
- // C operator +([[!C? other!]]) => this;
- // }
- // ```
- //
- // #### Common fixes
- //
- // Make all of the parameters be required parameters:
- //
- // ```dart
- // class C {
- // C operator +(C other) => this;
- // }
- // ```
- static const CompileTimeErrorCode OPTIONAL_PARAMETER_IN_OPERATOR =
- CompileTimeErrorCode('OPTIONAL_PARAMETER_IN_OPERATOR',
- "Optional parameters aren't allowed when defining an operator.",
- correction: "Try removing the optional parameters.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of expected library name
- * 1: the non-matching actual library name from the "part of" declaration
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a library attempts to include a
- // file as a part of itself when the other file is a part of a different
- // library.
- //
- // #### Example
- //
- // Given a file named `part.dart` containing
- //
- // ```dart
- // %uri="package:a/part.dart"
- // part of 'library.dart';
- // ```
- //
- // The following code, in any file other than `library.dart`, produces this
- // diagnostic because it attempts to include `part.dart` as a part of itself
- // when `part.dart` is a part of a different library:
- //
- // ```dart
- // part [!'package:a/part.dart'!];
- // ```
- //
- // #### Common fixes
- //
- // If the library should be using a different file as a part, then change the
- // URI in the part directive to be the URI of the other file.
- //
- // If the part file should be a part of this library, then update the URI (or
- // library name) in the part-of directive to be the URI (or name) of the
- // correct library.
- static const CompileTimeErrorCode PART_OF_DIFFERENT_LIBRARY =
- CompileTimeErrorCode('PART_OF_DIFFERENT_LIBRARY',
- "Expected this library to be part of '{0}', not '{1}'.",
- correction: "Try including a different part, or changing the name of "
- "the library in the part's part-of directive.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the uri pointing to a non-library declaration
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a part directive is found and
- // the referenced file doesn't have a part-of directive.
- //
- // #### Examples
- //
- // Given a file (`a.dart`) containing:
- //
- // ```dart
- // %uri="lib/a.dart"
- // class A {}
- // ```
- //
- // The following code produces this diagnostic because `a.dart` doesn't
- // contain a part-of directive:
- //
- // ```dart
- // part [!'a.dart'!];
- // ```
- //
- // #### Common fixes
- //
- // If the referenced file is intended to be a part of another library, then
- // add a part-of directive to the file:
- //
- // ```dart
- // part of 'test.dart';
- //
- // class A {}
- // ```
- //
- // If the referenced file is intended to be a library, then replace the part
- // directive with an import directive:
- //
- // ```dart
- // import 'a.dart';
- // ```
- static const CompileTimeErrorCode PART_OF_NON_PART = CompileTimeErrorCode(
- 'PART_OF_NON_PART',
- "The included part '{0}' must have a part-of directive.",
- correction: "Try adding a part-of directive to '{0}'.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the URI of the expected library
- * 1: the non-matching actual library name from the "part of" declaration
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a library that doesn't have a
- // `library` directive (and hence has no name) contains a `part` directive and
- // the `part of` directive in the part file uses a name to specify the library
- // that it's a part of.
- //
- // #### Example
- //
- // Given a part file named `part_file.dart` containing the following code:
- //
- // ```dart
- // %uri="lib/part_file.dart"
- // part of lib;
- // ```
- //
- // The following code produces this diagnostic because the library including
- // the part file doesn't have a name even though the part file uses a name to
- // specify which library it's a part of:
- //
- // ```dart
- // part [!'part_file.dart'!];
- // ```
- //
- // #### Common fixes
- //
- // Change the `part of` directive in the part file to specify its library by
- // URI:
- //
- // ```dart
- // part of 'test.dart';
- // ```
- static const CompileTimeErrorCode PART_OF_UNNAMED_LIBRARY =
- CompileTimeErrorCode(
- 'PART_OF_UNNAMED_LIBRARY',
- "The library is unnamed. A URI is expected, not a library name "
- "'{0}', in the part-of directive.",
- correction:
- "Try changing the part-of directive to a URI, or try including a "
- "different part.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the prefix
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a name is used as both an import
- // prefix and the name of a top-level declaration in the same library.
- //
- // #### Example
- //
- // The following code produces this diagnostic because `f` is used as both an
- // import prefix and the name of a function:
- //
- // ```dart
- // import 'dart:math' as f;
- //
- // int [!f!]() => f.min(0, 1);
- // ```
- //
- // #### Common fixes
- //
- // If you want to use the name for the import prefix, then rename the
- // top-level declaration:
- //
- // ```dart
- // import 'dart:math' as f;
- //
- // int g() => f.min(0, 1);
- // ```
- //
- // If you want to use the name for the top-level declaration, then rename the
- // import prefix:
- //
- // ```dart
- // import 'dart:math' as math;
- //
- // int f() => math.min(0, 1);
- // ```
- static const CompileTimeErrorCode PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER =
- CompileTimeErrorCode(
- 'PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER',
- "The name '{0}' is already used as an import prefix and can't be "
- "used to name a top-level element.",
- correction:
- "Try renaming either the top-level element or the prefix.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the prefix
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an import prefix is used by
- // itself, without accessing any of the names declared in the libraries
- // associated with the prefix. Prefixes aren't variables, and therefore can't
- // be used as a value.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the prefix `math` is
- // being used as if it were a variable:
- //
- // ```dart
- // import 'dart:math' as math;
- //
- // void f() {
- // print([!math!]);
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the code is incomplete, then reference something in one of the libraries
- // associated with the prefix:
- //
- // ```dart
- // import 'dart:math' as math;
- //
- // void f() {
- // print(math.pi);
- // }
- // ```
- //
- // If the name is wrong, then correct the name.
- static const CompileTimeErrorCode PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT =
- CompileTimeErrorCode(
- 'PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT',
- "The name '{0}' refers to an import prefix, so it must be followed "
- "by '.'.",
- correction:
- "Try correcting the name to refer to something other than a "
- "prefix, or renaming the prefix.",
- hasPublishedDocs: true);
-
- /**
- * From the `Static Types` section of the spec:
- *
- * A type T is malformed if:
- * - T has the form id or the form prefix.id, and in the enclosing lexical
- * scope, the name id (respectively prefix.id) does not denote a type.
- *
- * In particular, this means that if an import prefix is shadowed by a local
- * declaration, it is an error to try to use it as a prefix for a type name.
- */
- static const CompileTimeErrorCode PREFIX_SHADOWED_BY_LOCAL_DECLARATION =
- CompileTimeErrorCode(
- 'PREFIX_SHADOWED_BY_LOCAL_DECLARATION',
- "The prefix '{0}' can't be used here because it is shadowed by a "
- "local declaration.",
- correction:
- "Try renaming either the prefix or the local declaration.");
-
- /**
- * Parameters:
- * 0: the private name that collides
- * 1: the name of the first mixin
- * 2: the name of the second mixin
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when two mixins that define the same
- // private member are used together in a single class in a library other than
- // the one that defines the mixins.
- //
- // #### Example
- //
- // Given a file named `a.dart` containing the following code:
- //
- // ```dart
- // %uri="lib/a.dart"
- // class A {
- // void _foo() {}
- // }
- //
- // class B {
- // void _foo() {}
- // }
- // ```
- //
- // The following code produces this diagnostic because the classes `A` and `B`
- // both define the method `_foo`:
- //
- // ```dart
- // import 'a.dart';
- //
- // class C extends Object with A, [!B!] {}
- // ```
- //
- // #### Common fixes
- //
- // If you don't need both of the mixins, then remove one of them from the
- // `with` clause:
- //
- // ```dart
- // import 'a.dart';
- //
- // class C extends Object with A, [!B!] {}
- // ```
- //
- // If you need both of the mixins, then rename the conflicting member in one
- // of the two mixins.
- static const CompileTimeErrorCode PRIVATE_COLLISION_IN_MIXIN_APPLICATION =
- CompileTimeErrorCode(
- 'PRIVATE_COLLISION_IN_MIXIN_APPLICATION',
- "The private name '{0}', defined by '{1}', "
- "conflicts with the same name defined by '{2}'.",
- correction: "Try removing '{1}' from the 'with' clause.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the name of a named parameter
- // starts with an underscore.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the named parameter
- // `_x` starts with an underscore:
- //
- // ```dart
- // class C {
- // void m({int [!_x!] = 0}) {}
- // }
- // ```
- //
- // #### Common fixes
- //
- // Rename the parameter so that it doesn't start with an underscore:
- //
- // ```dart
- // class C {
- // void m({int x = 0}) {}
- // }
- // ```
- static const CompileTimeErrorCode PRIVATE_OPTIONAL_PARAMETER =
- CompileTimeErrorCode('PRIVATE_OPTIONAL_PARAMETER',
- "Named parameters can't start with an underscore.",
- hasPublishedDocs: true);
-
- static const CompileTimeErrorCode PRIVATE_SETTER = CompileTimeErrorCode(
- 'PRIVATE_SETTER',
- "The setter '{0}' is private and can't be accessed outside of the "
- "library that declares it.",
- correction: "Try making it public.");
-
- static const CompileTimeErrorCode READ_POTENTIALLY_UNASSIGNED_FINAL =
- CompileTimeErrorCode(
- 'READ_POTENTIALLY_UNASSIGNED_FINAL',
- "The final variable '{0}' can't be read because it is potentially "
- "unassigned at this point.",
- correction: "Ensure that it is assigned on necessary execution paths.",
- );
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the value of a compile-time
- // constant is defined in terms of itself, either directly or indirectly,
- // creating an infinite loop.
- //
- // #### Example
- //
- // The following code produces this diagnostic twice because both of the
- // constants are defined in terms of the other:
- //
- // ```dart
- // const [!secondsPerHour!] = minutesPerHour * 60;
- // const [!minutesPerHour!] = secondsPerHour / 60;
- // ```
- //
- // #### Common fixes
- //
- // Break the cycle by finding an alternative way of defining at least one of
- // the constants:
- //
- // ```dart
- // const secondsPerHour = minutesPerHour * 60;
- // const minutesPerHour = 60;
- // ```
- static const CompileTimeErrorCode RECURSIVE_COMPILE_TIME_CONSTANT =
- CompileTimeErrorCode('RECURSIVE_COMPILE_TIME_CONSTANT',
- "The compile-time constant expression depends on itself.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- *
- * TODO(scheglov) review this later, there are no explicit "it is a
- * compile-time error" in specification. But it was added to the co19 and
- * there is same error for factories.
- *
- * https://code.google.com/p/dart/issues/detail?id=954
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a constructor redirects to
- // itself, either directly or indirectly, creating an infinite loop.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the generative
- // constructors `C.a` and `C.b` each redirect to the other:
- //
- // ```dart
- // class C {
- // C.a() : [!this.b()!];
- // C.b() : [!this.a()!];
- // }
- // ```
- //
- // The following code produces this diagnostic because the factory
- // constructors `A` and `B` each redirect to the other:
- //
- // ```dart
- // abstract class A {
- // factory A() = [!B!];
- // }
- // class B implements A {
- // factory B() = [!A!];
- // B.named();
- // }
- // ```
- //
- // #### Common fixes
- //
- // In the case of generative constructors, break the cycle by finding defining
- // at least one of the constructors to not redirect to another constructor:
- //
- // ```dart
- // class C {
- // C.a() : this.b();
- // C.b();
- // }
- // ```
- //
- // In the case of factory constructors, break the cycle by defining at least
- // one of the factory constructors to do one of the following:
- //
- // - Redirect to a generative constructor:
- //
- // ```dart
- // abstract class A {
- // factory A() = B;
- // }
- // class B implements A {
- // factory B() = B.named;
- // B.named();
- // }
- // ```
- //
- // - Not redirect to another constructor:
- //
- // ```dart
- // abstract class A {
- // factory A() = B;
- // }
- // class B implements A {
- // factory B() {
- // return B.named();
- // }
- //
- // B.named();
- // }
- // ```
- //
- // - Not be a factory constructor:
- //
- // ```dart
- // abstract class A {
- // factory A() = B;
- // }
- // class B implements A {
- // B();
- // B.named();
- // }
- // ```
- static const CompileTimeErrorCode RECURSIVE_CONSTRUCTOR_REDIRECT =
- CompileTimeErrorCode(
- 'RECURSIVE_CONSTRUCTOR_REDIRECT',
- "Constructors can't redirect to themselves either directly or "
- "indirectly.",
- correction: 'Try changing one of the constructors in the loop to not '
- 'redirect.',
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- static const CompileTimeErrorCode RECURSIVE_FACTORY_REDIRECT =
- CompileTimeErrorCode(
- 'RECURSIVE_CONSTRUCTOR_REDIRECT',
- "Constructors can't redirect to themselves either directly or "
- "indirectly.",
- correction: 'Try changing one of the constructors in the loop to not '
- 'redirect.',
- hasPublishedDocs: true,
- uniqueName: 'RECURSIVE_FACTORY_REDIRECT');
-
- /**
- * Parameters:
- * 0: the name of the class that implements itself recursively
- * 1: a string representation of the implements loop
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when there's a circularity in the
- // type hierarchy. This happens when a type, either directly or indirectly,
- // is declared to be a subtype of itself.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the class `A` is
- // declared to be a subtype of `B`, and `B` is a subtype of `A`:
- //
- // ```dart
- // class [!A!] extends B {}
- // class B implements A {}
- // ```
- //
- // #### Common fixes
- //
- // Change the type hierarchy so that there's no circularity.
- static const CompileTimeErrorCode RECURSIVE_INTERFACE_INHERITANCE =
- CompileTimeErrorCode('RECURSIVE_INTERFACE_INHERITANCE',
- "'{0}' can't be a superinterface of itself: {1}.",
- hasPublishedDocs: true,
- uniqueName: 'RECURSIVE_INTERFACE_INHERITANCE');
-
- /**
- * 7.10 Superinterfaces: It is a compile-time error if the interface of a
- * class <i>C</i> is a superinterface of itself.
- *
- * 8.1 Superinterfaces: It is a compile-time error if an interface is a
- * superinterface of itself.
- *
- * 7.9 Superclasses: It is a compile-time error if a class <i>C</i> is a
- * superclass of itself.
- *
- * Parameters:
- * 0: the name of the class that implements itself recursively
- */
- static const CompileTimeErrorCode RECURSIVE_INTERFACE_INHERITANCE_EXTENDS =
- CompileTimeErrorCode(
- 'RECURSIVE_INTERFACE_INHERITANCE', "'{0}' can't extend itself.",
- hasPublishedDocs: true,
- uniqueName: 'RECURSIVE_INTERFACE_INHERITANCE_EXTENDS');
-
- /**
- * 7.10 Superinterfaces: It is a compile-time error if the interface of a
- * class <i>C</i> is a superinterface of itself.
- *
- * 8.1 Superinterfaces: It is a compile-time error if an interface is a
- * superinterface of itself.
- *
- * 7.9 Superclasses: It is a compile-time error if a class <i>C</i> is a
- * superclass of itself.
- *
- * Parameters:
- * 0: the name of the class that implements itself recursively
- */
- static const CompileTimeErrorCode RECURSIVE_INTERFACE_INHERITANCE_IMPLEMENTS =
- CompileTimeErrorCode(
- 'RECURSIVE_INTERFACE_INHERITANCE', "'{0}' can't implement itself.",
- hasPublishedDocs: true,
- uniqueName: 'RECURSIVE_INTERFACE_INHERITANCE_IMPLEMENTS');
-
- /**
- * Parameters:
- * 0: the name of the mixin that constraints itself recursively
- */
- static const CompileTimeErrorCode RECURSIVE_INTERFACE_INHERITANCE_ON =
- CompileTimeErrorCode('RECURSIVE_INTERFACE_INHERITANCE',
- "'{0}' can't use itself as a superclass constraint.",
- hasPublishedDocs: true,
- uniqueName: 'RECURSIVE_INTERFACE_INHERITANCE_ON');
-
- /**
- * 7.10 Superinterfaces: It is a compile-time error if the interface of a
- * class <i>C</i> is a superinterface of itself.
- *
- * 8.1 Superinterfaces: It is a compile-time error if an interface is a
- * superinterface of itself.
- *
- * 7.9 Superclasses: It is a compile-time error if a class <i>C</i> is a
- * superclass of itself.
- *
- * Parameters:
- * 0: the name of the class that implements itself recursively
- */
- static const CompileTimeErrorCode RECURSIVE_INTERFACE_INHERITANCE_WITH =
- CompileTimeErrorCode('RECURSIVE_INTERFACE_INHERITANCE',
- "'{0}' can't use itself as a mixin.",
- hasPublishedDocs: true,
- uniqueName: 'RECURSIVE_INTERFACE_INHERITANCE_WITH');
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a generative constructor
- // redirects to a constructor that isn't defined.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the constructor `C.a`
- // redirects to the constructor `C.b`, but `C.b` isn't defined:
- //
- // ```dart
- // class C {
- // C.a() : [!this.b()!];
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the missing constructor must be called, then define it:
- //
- // ```dart
- // class C {
- // C.a() : this.b();
- // C.b();
- // }
- // ```
- //
- // If the missing constructor doesn't need to be called, then remove the
- // redirect:
- //
- // ```dart
- // class C {
- // C.a();
- // }
- // ```
- static const CompileTimeErrorCode REDIRECT_GENERATIVE_TO_MISSING_CONSTRUCTOR =
- CompileTimeErrorCode('REDIRECT_GENERATIVE_TO_MISSING_CONSTRUCTOR',
- "The constructor '{0}' couldn't be found in '{1}'.",
- correction: "Try redirecting to a different constructor, or "
- "defining the constructor named '{0}'.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a generative constructor
- // redirects to a factory constructor.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the generative
- // constructor `C.a` redirects to the factory constructor `C.b`:
- //
- // ```dart
- // class C {
- // C.a() : [!this.b()!];
- // factory C.b() => C.a();
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the generative constructor doesn't need to redirect to another
- // constructor, then remove the redirect.
- //
- // ```dart
- // class C {
- // C.a();
- // factory C.b() => C.a();
- // }
- // ```
- //
- // If the generative constructor must redirect to another constructor, then
- // make the other constructor be a generative (non-factory) constructor:
- //
- // ```dart
- // class C {
- // C.a() : this.b();
- // C.b();
- // }
- // ```
- static const CompileTimeErrorCode
- REDIRECT_GENERATIVE_TO_NON_GENERATIVE_CONSTRUCTOR = CompileTimeErrorCode(
- 'REDIRECT_GENERATIVE_TO_NON_GENERATIVE_CONSTRUCTOR',
- "Generative constructors can't redirect to a factory constructor.",
- correction: "Try redirecting to a different constructor.",
- hasPublishedDocs: true);
-
- /**
- * A factory constructor can't redirect to a non-generative constructor of an
- * abstract class.
- */
- static const CompileTimeErrorCode REDIRECT_TO_ABSTRACT_CLASS_CONSTRUCTOR =
- CompileTimeErrorCode(
- 'REDIRECT_TO_ABSTRACT_CLASS_CONSTRUCTOR',
- "The redirecting constructor '{0}' can't redirect to a constructor "
- "of the abstract class '{1}'.",
- correction: "Try redirecting to a constructor of a different class.");
-
- /**
- * Parameters:
- * 0: the name of the redirected constructor
- * 1: the name of the redirecting constructor
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a factory constructor attempts
- // to redirect to another constructor, but the two have incompatible
- // parameters. The parameters are compatible if all of the parameters of the
- // redirecting constructor can be passed to the other constructor and if the
- // other constructor doesn't require any parameters that aren't declared by
- // the redirecting constructor.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because the constructor for `A`
- // doesn't declare a parameter that the constructor for `B` requires:
- //
- // ```dart
- // abstract class A {
- // factory A() = [!B!];
- // }
- //
- // class B implements A {
- // B(int x);
- // B.zero();
- // }
- // ```
- //
- // The following code produces this diagnostic because the constructor for `A`
- // declares a named parameter (`y`) that the constructor for `B` doesn't
- // allow:
- //
- // ```dart
- // abstract class A {
- // factory A(int x, {int y}) = [!B!];
- // }
- //
- // class B implements A {
- // B(int x);
- // }
- // ```
- //
- // #### Common fixes
- //
- // If there's a different constructor that is compatible with the redirecting
- // constructor, then redirect to that constructor:
- //
- // ```dart
- // abstract class A {
- // factory A() = B.zero;
- // }
- //
- // class B implements A {
- // B(int x);
- // B.zero();
- // }
- // ```
- //
- // Otherwise, update the redirecting constructor to be compatible:
- //
- // ```dart
- // abstract class A {
- // factory A(int x) = B;
- // }
- //
- // class B implements A {
- // B(int x);
- // }
- // ```
- static const CompileTimeErrorCode REDIRECT_TO_INVALID_FUNCTION_TYPE =
- CompileTimeErrorCode(
- 'REDIRECT_TO_INVALID_FUNCTION_TYPE',
- "The redirected constructor '{0}' has incompatible parameters with "
- "'{1}'.",
- correction: "Try redirecting to a different constructor.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the redirected constructor's return type
- * 1: the name of the redirecting constructor's return type
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a factory constructor redirects
- // to a constructor whose return type isn't a subtype of the type that the
- // factory constructor is declared to produce.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `A` isn't a subclass
- // of `C`, which means that the value returned by the constructor `A()`
- // couldn't be returned from the constructor `C()`:
- //
- // ```dart
- // class A {}
- //
- // class B implements C {}
- //
- // class C {
- // factory C() = [!A!];
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the factory constructor is redirecting to a constructor in the wrong
- // class, then update the factory constructor to redirect to the correct
- // constructor:
- //
- // ```dart
- // class A {}
- //
- // class B implements C {}
- //
- // class C {
- // factory C() = B;
- // }
- // ```
- //
- // If the class defining the constructor being redirected to is the class that
- // should be returned, then make it a subtype of the factory's return type:
- //
- // ```dart
- // class A implements C {}
- //
- // class B implements C {}
- //
- // class C {
- // factory C() = A;
- // }
- // ```
- static const CompileTimeErrorCode REDIRECT_TO_INVALID_RETURN_TYPE =
- CompileTimeErrorCode(
- 'REDIRECT_TO_INVALID_RETURN_TYPE',
- "The return type '{0}' of the redirected constructor isn't "
- "a subtype of '{1}'.",
- correction: "Try redirecting to a different constructor.",
- hasPublishedDocs: true);
-
- /**
- * 7.6.2 Factories: It is a compile-time error if <i>k</i> is prefixed with
- * the const modifier but <i>k'</i> is not a constant constructor.
- */
- static const CompileTimeErrorCode REDIRECT_TO_MISSING_CONSTRUCTOR =
- CompileTimeErrorCode('REDIRECT_TO_MISSING_CONSTRUCTOR',
- "The constructor '{0}' couldn't be found in '{1}'.",
- correction: "Try redirecting to a different constructor, or "
- "define the constructor named '{0}'.");
-
- /**
- * Parameters:
- * 0: the name of the non-type referenced in the redirect
- */
- // #### Description
- //
- // One way to implement a factory constructor is to redirect to another
- // constructor by referencing the name of the constructor. The analyzer
- // produces this diagnostic when the redirect is to something other than a
- // constructor.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `f` is a function:
- //
- // ```dart
- // C f() => throw 0;
- //
- // class C {
- // factory C() = [!f!];
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the constructor isn't defined, then either define it or replace it with
- // a constructor that is defined.
- //
- // If the constructor is defined but the class that defines it isn't visible,
- // then you probably need to add an import.
- //
- // If you're trying to return the value returned by a function, then rewrite
- // the constructor to return the value from the constructor's body:
- //
- // ```dart
- // C f() => throw 0;
- //
- // class C {
- // factory C() => f();
- // }
- // ```
- static const CompileTimeErrorCode REDIRECT_TO_NON_CLASS =
- CompileTimeErrorCode(
- 'REDIRECT_TO_NON_CLASS',
- "The name '{0}' isn't a type and can't be used in a redirected "
- "constructor.",
- correction: "Try redirecting to a different constructor.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a constructor marked as `const`
- // redirects to a constructor that isn't marked as `const`.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the constructor `C.a`
- // is marked as `const` but redirects to the constructor `C.b`, which isn't:
- //
- // ```dart
- // class C {
- // const C.a() : this.[!b!]();
- // C.b();
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the non-constant constructor can be marked as `const`, then mark it as
- // `const`:
- //
- // ```dart
- // class C {
- // const C.a() : this.b();
- // const C.b();
- // }
- // ```
- //
- // If the non-constant constructor can't be marked as `const`, then either
- // remove the redirect or remove `const` from the redirecting constructor:
- //
- // ```dart
- // class C {
- // C.a() : this.b();
- // C.b();
- // }
- // ```
- static const CompileTimeErrorCode REDIRECT_TO_NON_CONST_CONSTRUCTOR =
- CompileTimeErrorCode(
- 'REDIRECT_TO_NON_CONST_CONSTRUCTOR',
- "A constant redirecting constructor can't redirect to a non-constant "
- "constructor.",
- correction: "Try redirecting to a different constructor.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a redirecting factory
- // constructor redirects to a type alias, and the type alias expands to one of
- // the type parameters of the type alias. This isn’t allowed because the value
- // of the type parameter is a type rather than a class.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the redirect to `B<A>`
- // is to a type alias whose value is `T`, even though it looks like the value
- // should be `A`:
- //
- // ```dart
- // class A implements C {}
- //
- // typedef B<T> = T;
- //
- // abstract class C {
- // factory C() = [!B!]<A>;
- // }
- // ```
- //
- // #### Common fixes
- //
- // Use either a class name or a type alias that is defined to be a class
- // rather than a type alias defined to be a type parameter:
- //
- // ```dart
- // class A implements C {}
- //
- // abstract class C {
- // factory C() = A;
- // }
- // ```
- static const CompileTimeErrorCode
- REDIRECT_TO_TYPE_ALIAS_EXPANDS_TO_TYPE_PARAMETER = CompileTimeErrorCode(
- 'REDIRECT_TO_TYPE_ALIAS_EXPANDS_TO_TYPE_PARAMETER',
- "A redirecting constructor can't redirect to a type alias that "
- "expands to a type parameter.",
- correction: "Try replacing it with a class.");
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a variable is referenced before
- // it’s declared. In Dart, variables are visible everywhere in the block in
- // which they are declared, but can only be referenced after they are
- // declared.
- //
- // The analyzer also produces a context message that indicates where the
- // declaration is located.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `i` is used before it
- // is declared:
- //
- // ```dart
- // %language=2.9
- // void f() {
- // print([!i!]);
- // int i = 5;
- // }
- // ```
- //
- // #### Common fixes
- //
- // If you intended to reference the local variable, move the declaration
- // before the first reference:
- //
- // ```dart
- // %language=2.9
- // void f() {
- // int i = 5;
- // print(i);
- // }
- // ```
- //
- // If you intended to reference a name from an outer scope, such as a
- // parameter, instance field or top-level variable, then rename the local
- // declaration so that it doesn't hide the outer variable.
- //
- // ```dart
- // %language=2.9
- // void f(int i) {
- // print(i);
- // int x = 5;
- // print(x);
- // }
- // ```
- static const CompileTimeErrorCode REFERENCED_BEFORE_DECLARATION =
- CompileTimeErrorCode('REFERENCED_BEFORE_DECLARATION',
- "Local variable '{0}' can't be referenced before it is declared.",
- correction: "Try moving the declaration to before the first use, or "
- "renaming the local variable so that it doesn't hide a name from "
- "an enclosing scope.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a `rethrow` statement is outside
- // a `catch` clause. The `rethrow` statement is used to throw a caught
- // exception again, but there's no caught exception outside of a `catch`
- // clause.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the`rethrow` statement
- // is outside of a `catch` clause:
- //
- // ```dart
- // void f() {
- // [!rethrow!];
- // }
- // ```
- //
- // #### Common fixes
- //
- // If you're trying to rethrow an exception, then wrap the `rethrow` statement
- // in a `catch` clause:
- //
- // ```dart
- // void f() {
- // try {
- // // ...
- // } catch (exception) {
- // rethrow;
- // }
- // }
- // ```
- //
- // If you're trying to throw a new exception, then replace the `rethrow`
- // statement with a `throw` expression:
- //
- // ```dart
- // void f() {
- // throw UnsupportedError('Not yet implemented');
- // }
- // ```
- static const CompileTimeErrorCode RETHROW_OUTSIDE_CATCH =
- CompileTimeErrorCode('RETHROW_OUTSIDE_CATCH',
- "A rethrow must be inside of a catch clause.",
- correction:
- "Try moving the expression into a catch clause, or using a "
- "'throw' expression.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a generative constructor
- // contains a `return` statement that specifies a value to be returned.
- // Generative constructors always return the object that was created, and
- // therefore can't return a different object.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the `return` statement
- // has an expression:
- //
- // ```dart
- // class C {
- // C() {
- // return [!this!];
- // }
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the constructor should create a new instance, then remove either the
- // `return` statement or the expression:
- //
- // ```dart
- // class C {
- // C();
- // }
- // ```
- //
- // If the constructor shouldn't create a new instance, then convert it to be a
- // factory constructor:
- //
- // ```dart
- // class C {
- // factory C() {
- // return _instance;
- // }
- //
- // static C _instance = C._();
- //
- // C._();
- // }
- // ```
- static const CompileTimeErrorCode RETURN_IN_GENERATIVE_CONSTRUCTOR =
- CompileTimeErrorCode('RETURN_IN_GENERATIVE_CONSTRUCTOR',
- "Constructors can't return values.",
- correction: "Try removing the return statement or using a factory "
- "constructor.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a generator function (one whose
- // body is marked with either `async*` or `sync*`) uses either a `return`
- // statement to return a value or implicitly returns a value because of using
- // `=>`. In any of these cases, they should use `yield` instead of `return`.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the method `f` is a
- // generator and is using `return` to return a value:
- //
- // ```dart
- // Iterable<int> f() sync* {
- // [!return 3!];
- // }
- // ```
- //
- // The following code produces this diagnostic because the function `f` is a
- // generator and is implicitly returning a value:
- //
- // ```dart
- // Stream<int> f() async* [!=>!] 3;
- // ```
- //
- // #### Common fixes
- //
- // If the function is using `=>` for the body of the function, then convert it
- // to a block function body, and use `yield` to return a value:
- //
- // ```dart
- // Stream<int> f() async* {
- // yield 3;
- // }
- // ```
- //
- // If the method is intended to be a generator, then use `yield` to return a
- // value:
- //
- // ```dart
- // Iterable<int> f() sync* {
- // yield 3;
- // }
- // ```
- //
- // If the method isn't intended to be a generator, then remove the modifier
- // from the body (or use `async` if you're returning a future):
- //
- // ```dart
- // int f() {
- // return 3;
- // }
- // ```
- static const CompileTimeErrorCode RETURN_IN_GENERATOR = CompileTimeErrorCode(
- 'RETURN_IN_GENERATOR',
- "Can't return a value from a generator function that uses the 'async*' "
- "or 'sync*' modifier.",
- // TODO(srawlins): Splitting this code into two cases, one for block-
- // bodied, and one for expression-bodied, would improve each correction
- // message. This split would have to be done in the parser.
- correction: "Try replacing 'return' with 'yield', using a block function "
- "body, or changing the method body modifier.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the return type as declared in the return statement
- * 1: the expected return type as defined by the method
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the static type of a returned
- // expression isn't assignable to the return type that the closure is required
- // to have.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `f` is defined to be a
- // function that returns a `String`, but the closure assigned to it returns an
- // `int`:
- //
- // ```dart
- // String Function(String) f = (s) => [!3!];
- // ```
- //
- // #### Common fixes
- //
- // If the return type is correct, then replace the returned value with a value
- // of the correct type, possibly by converting the existing value:
- //
- // ```dart
- // String Function(String) f = (s) => 3.toString();
- // ```
- static const CompileTimeErrorCode RETURN_OF_INVALID_TYPE_FROM_CLOSURE =
- CompileTimeErrorCode(
- 'RETURN_OF_INVALID_TYPE_FROM_CLOSURE',
- "The return type '{0}' isn't a '{1}', as required by the closure's "
- "context.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the return type as declared in the return statement
- * 1: the expected return type as defined by the enclosing class
- * 2: the name of the constructor
- */
- static const CompileTimeErrorCode RETURN_OF_INVALID_TYPE_FROM_CONSTRUCTOR =
- CompileTimeErrorCode(
- 'RETURN_OF_INVALID_TYPE',
- "A value of type '{0}' can't be returned from the constructor '{2}' "
- "because it has a return type of '{1}'.",
- hasPublishedDocs: true,
- uniqueName: 'RETURN_OF_INVALID_TYPE_FROM_CONSTRUCTOR',
- );
-
- /**
- * Parameters:
- * 0: the return type as declared in the return statement
- * 1: the expected return type as defined by the method
- * 2: the name of the method
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a method or function returns a
- // value whose type isn't assignable to the declared return type.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `f` has a return type
- // of `String` but is returning an `int`:
- //
- // ```dart
- // String f() => [!3!];
- // ```
- //
- // #### Common fixes
- //
- // If the return type is correct, then replace the value being returned with a
- // value of the correct type, possibly by converting the existing value:
- //
- // ```dart
- // String f() => 3.toString();
- // ```
- //
- // If the value is correct, then change the return type to match:
- //
- // ```dart
- // int f() => 3;
- // ```
- static const CompileTimeErrorCode RETURN_OF_INVALID_TYPE_FROM_FUNCTION =
- CompileTimeErrorCode(
- 'RETURN_OF_INVALID_TYPE',
- "A value of type '{0}' can't be returned from the function '{2}' because "
- "it has a return type of '{1}'.",
- hasPublishedDocs: true,
- uniqueName: 'RETURN_OF_INVALID_TYPE_FROM_FUNCTION',
- );
-
- /**
- * Parameters:
- * 0: the return type as declared in the return statement
- * 1: the expected return type as defined by the method
- * 2: the name of the method
- */
- static const CompileTimeErrorCode RETURN_OF_INVALID_TYPE_FROM_METHOD =
- CompileTimeErrorCode(
- 'RETURN_OF_INVALID_TYPE',
- "A value of type '{0}' can't be returned from the method '{2}' because "
- "it has a return type of '{1}'.",
- hasPublishedDocs: true,
- uniqueName: 'RETURN_OF_INVALID_TYPE_FROM_METHOD',
- );
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when it finds a `return` statement
- // without an expression in a function that declares a return type.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because the function `f` is
- // expected to return an `int`, but no value is being returned:
- //
- // ```dart
- // int f() {
- // [!return!];
- // }
- // ```
- //
- // #### Common fixes
- //
- // Add an expression that computes the value to be returned:
- //
- // ```dart
- // int f() {
- // return 0;
- // }
- // ```
- static const CompileTimeErrorCode RETURN_WITHOUT_VALUE = CompileTimeErrorCode(
- '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 literal.",
- correction:
- "Try removing the keyword 'const' from the set literal or removing "
- "the keyword 'deferred' from the import.",
- hasPublishedDocs: true,
- uniqueName: 'SET_ELEMENT_FROM_DEFERRED_LIBRARY');
-
- /**
- * Parameters:
- * 0: the actual type of the set element
- * 1: the expected type of the set element
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an element in a set literal has
- // a type that isn't assignable to the element type of the set.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the type of the string
- // literal `'0'` is `String`, which isn't assignable to `int`, the element
- // type of the set:
- //
- // ```dart
- // var s = <int>{[!'0'!]};
- // ```
- //
- // #### Common fixes
- //
- // If the element type of the set literal is wrong, then change the element
- // type of the set:
- //
- // ```dart
- // var s = <String>{'0'};
- // ```
- //
- // If the type of the element is wrong, then change the element:
- //
- // ```dart
- // var s = <int>{'0'.length};
- // ```
- static const CompileTimeErrorCode SET_ELEMENT_TYPE_NOT_ASSIGNABLE =
- CompileTimeErrorCode('SET_ELEMENT_TYPE_NOT_ASSIGNABLE',
- "The element type '{0}' can't be assigned to the set type '{1}'.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a prefix in a deferred import is
- // also used as a prefix in other imports (whether deferred or not). The
- // prefix in a deferred import can't be shared with other imports because the
- // prefix is used to load the imported library.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the prefix `x` is used
- // as the prefix for a deferred import and is also used for one other import:
- //
- // ```dart
- // import 'dart:math' [!deferred!] as x;
- // import 'dart:convert' as x;
- //
- // var y = x.json.encode(x.min(0, 1));
- // ```
- //
- // #### Common fixes
- //
- // If you can use a different name for the deferred import, then do so:
- //
- // ```dart
- // import 'dart:math' deferred as math;
- // import 'dart:convert' as x;
- //
- // var y = x.json.encode(math.min(0, 1));
- // ```
- //
- // If you can use a different name for the other imports, then do so:
- //
- // ```dart
- // import 'dart:math' deferred as x;
- // import 'dart:convert' as convert;
- //
- // var y = convert.json.encode(x.min(0, 1));
- // ```
- static const CompileTimeErrorCode SHARED_DEFERRED_PREFIX =
- CompileTimeErrorCode(
- 'SHARED_DEFERRED_PREFIX',
- "The prefix of a deferred import can't be used in other import "
- "directives.",
- correction: "Try renaming one of the prefixes.",
- hasPublishedDocs: true);
-
- static const CompileTimeErrorCode SPREAD_EXPRESSION_FROM_DEFERRED_LIBRARY =
- CompileTimeErrorCode(
- 'SPREAD_EXPRESSION_FROM_DEFERRED_LIBRARY',
- "Constant values from a deferred library can't be spread into a "
- "const literal.",
- correction: "Try making the deferred import non-deferred.");
-
- /**
- * Parameters:
- * 0: the name of the instance member
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a class name is used to access
- // an instance field. Instance fields don't exist on a class; they exist only
- // on an instance of the class.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `x` is an instance
- // field:
- //
- // ```dart
- // %language=2.9
- // class C {
- // static int a;
- //
- // int b;
- // }
- //
- // int f() => C.[!b!];
- // ```
- //
- // #### Common fixes
- //
- // If you intend to access a static field, then change the name of the field
- // to an existing static field:
- //
- // ```dart
- // %language=2.9
- // class C {
- // static int a;
- //
- // int b;
- // }
- //
- // int f() => C.a;
- // ```
- //
- // If you intend to access the instance field, then use an instance of the
- // class to access the field:
- //
- // ```dart
- // %language=2.9
- // class C {
- // static int a;
- //
- // int b;
- // }
- //
- // int f(C c) => c.b;
- // ```
- static const CompileTimeErrorCode STATIC_ACCESS_TO_INSTANCE_MEMBER =
- CompileTimeErrorCode('STATIC_ACCESS_TO_INSTANCE_MEMBER',
- "Instance member '{0}' can't be accessed using static access.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a member declared inside an
- // extension uses the `super` keyword . Extensions aren't classes and don't
- // have superclasses, so the `super` keyword serves no purpose.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `super` can't be used
- // in an extension:
- //
- // ```dart
- // extension E on Object {
- // String get displayString => [!super!].toString();
- // }
- // ```
- //
- // #### Common fixes
- //
- // Remove the `super` keyword :
- //
- // ```dart
- // extension E on Object {
- // String get displayString => toString();
- // }
- // ```
- static const CompileTimeErrorCode SUPER_IN_EXTENSION = CompileTimeErrorCode(
- 'SUPER_IN_EXTENSION',
- "The 'super' keyword can't be used in an extension because an "
- "extension doesn't have a superclass.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the keyword `super` is used
- // outside of a instance method.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `super` is used in a
- // top-level function:
- //
- // ```dart
- // void f() {
- // [!super!].f();
- // }
- // ```
- //
- // #### Common fixes
- //
- // Rewrite the code to not use `super`.
- static const CompileTimeErrorCode SUPER_IN_INVALID_CONTEXT =
- CompileTimeErrorCode(
- 'SUPER_IN_INVALID_CONTEXT', "Invalid context for 'super' invocation.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a constructor that redirects to
- // another constructor also attempts to invoke a constructor from the
- // superclass. The superclass constructor will be invoked when the constructor
- // that the redirecting constructor is redirected to is invoked.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the constructor `C.a`
- // both redirects to `C.b` and invokes a constructor from the superclass:
- //
- // ```dart
- // class C {
- // C.a() : this.b(), [!super()!];
- // C.b();
- // }
- // ```
- //
- // #### Common fixes
- //
- // Remove the invocation of the `super` constructor:
- //
- // ```dart
- // class C {
- // C.a() : this.b();
- // C.b();
- // }
- // ```
- static const CompileTimeErrorCode SUPER_IN_REDIRECTING_CONSTRUCTOR =
- CompileTimeErrorCode('SUPER_IN_REDIRECTING_CONSTRUCTOR',
- "The redirecting constructor can't have a 'super' initializer.",
- hasPublishedDocs: true);
-
- /**
- * 7.6.1 Generative Constructors: Let <i>k</i> be a generative constructor. It
- * is a compile-time error if a generative constructor of class Object
- * includes a superinitializer.
- */
- static const CompileTimeErrorCode SUPER_INITIALIZER_IN_OBJECT =
- CompileTimeErrorCode('SUPER_INITIALIZER_IN_OBJECT',
- "The class 'Object' can't invoke a constructor from a superclass.");
-
- /**
- * It is an error if any case of a switch statement except the last case (the
- * default case if present) may complete normally. The previous syntactic
- * restriction requiring the last statement of each case to be one of an
- * enumerated list of statements (break, continue, return, throw, or rethrow)
- * is removed.
- */
- static const CompileTimeErrorCode SWITCH_CASE_COMPLETES_NORMALLY =
- CompileTimeErrorCode('SWITCH_CASE_COMPLETES_NORMALLY',
- "The 'case' should not complete normally.",
- correction: "Try adding 'break', or 'return', etc.");
-
- /**
- * Parameters:
- * 0: the static type of the switch expression
- * 1: the static type of the case expressions
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the type of the expression in a
- // `switch` statement isn't assignable to the type of the expressions in the
- // `case` clauses.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the type of `s`
- // (`String`) isn't assignable to the type of `0` (`int`):
- //
- // ```dart
- // %language=2.9
- // void f(String s) {
- // switch ([!s!]) {
- // case 0:
- // break;
- // }
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the type of the `case` expressions is correct, then change the
- // expression in the `switch` statement to have the correct type:
- //
- // ```dart
- // %language=2.9
- // void f(String s) {
- // switch (int.parse(s)) {
- // case 0:
- // break;
- // }
- // }
- // ```
- //
- // If the type of the `switch` expression is correct, then change the `case`
- // expressions to have the correct type:
- //
- // ```dart
- // %language=2.9
- // void f(String s) {
- // switch (s) {
- // case '0':
- // break;
- // }
- // }
- // ```
- static const CompileTimeErrorCode SWITCH_EXPRESSION_NOT_ASSIGNABLE =
- CompileTimeErrorCode(
- 'SWITCH_EXPRESSION_NOT_ASSIGNABLE',
- "Type '{0}' of the switch expression isn't assignable to "
- "the type '{1}' of case expressions.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a generative constructor from an
- // abstract class is being torn off. This isn't allowed because it isn't valid
- // to create an instance of an abstract class, which means that there isn't
- // any valid use for the torn off constructor.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the constructor `C.new`
- // is being torn off and the class `C` is an abstract class:
- //
- // ```dart
- // abstract class C {
- // C();
- // }
- //
- // void f() {
- // [!C.new!];
- // }
- // ```
- //
- // #### Common fixes
- //
- // Tear off the constructor of a concrete class.
- static const CompileTimeErrorCode
- TEAROFF_OF_GENERATIVE_CONSTRUCTOR_OF_ABSTRACT_CLASS =
- CompileTimeErrorCode(
- 'TEAROFF_OF_GENERATIVE_CONSTRUCTOR_OF_ABSTRACT_CLASS',
- "A generative constructor of an abstract class can't be torn off.",
- correction: "Try tearing off a constructor of a concrete class, or a "
- "non-generative constructor.");
-
- /**
- * Parameters:
- * 0: the type that can't be thrown
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the type of the expression in a
- // throw expression isn't assignable to `Object`. It isn't valid to throw
- // `null`, so it isn't valid to use an expression that might evaluate to
- // `null`.
- //
- // #### Example
- //
- // The following code produces this diagnostic because `s` might be `null`:
- //
- // ```dart
- // void f(String? s) {
- // throw [!s!];
- // }
- // ```
- //
- // #### Common fixes
- //
- // Add an explicit null check to the expression:
- //
- // ```dart
- // void f(String? s) {
- // throw s!;
- // }
- // ```
- static const CompileTimeErrorCode THROW_OF_INVALID_TYPE = CompileTimeErrorCode(
- 'THROW_OF_INVALID_TYPE',
- "The type '{0}' of the thrown expression must be assignable to 'Object'.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the element whose type could not be inferred.
- * 1: The [TopLevelInferenceError]'s arguments that led to the cycle.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a top-level variable has no type
- // annotation and the variable's initializer refers to the variable, either
- // directly or indirectly.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the variables `x` and
- // `y` are defined in terms of each other, and neither has an explicit type,
- // so the type of the other can't be inferred:
- //
- // ```dart
- // var x = y;
- // var y = [!x!];
- // ```
- //
- // #### Common fixes
- //
- // If the two variables don't need to refer to each other, then break the
- // cycle:
- //
- // ```dart
- // var x = 0;
- // var y = x;
- // ```
- //
- // If the two variables need to refer to each other, then give at least one of
- // them an explicit type:
- //
- // ```dart
- // int x = y;
- // var y = x;
- // ```
- //
- // Note, however, that while this code doesn't produce any diagnostics, it
- // will produce a stack overflow at runtime unless at least one of the
- // variables is assigned a value that doesn't depend on the other variables
- // before any of the variables in the cycle are referenced.
- static const CompileTimeErrorCode TOP_LEVEL_CYCLE = CompileTimeErrorCode(
- 'TOP_LEVEL_CYCLE',
- "The type of '{0}' can't be inferred because it depends on itself "
- "through the cycle: {1}.",
- correction:
- "Try adding an explicit type to one or more of the variables in the "
- "cycle in order to break the cycle.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a typedef refers to itself,
- // either directly or indirectly.
- //
- // #### Example
- //
- // The following code produces this diagnostic because `F` depends on itself
- // indirectly through `G`:
- //
- // ```dart
- // typedef [!F!] = void Function(G);
- // typedef G = void Function(F);
- // ```
- //
- // #### Common fixes
- //
- // Change one or more of the typedefs in the cycle so that none of them refer
- // to themselves:
- //
- // ```dart
- // typedef F = void Function(G);
- // typedef G = void Function(int);
- // ```
- static const CompileTimeErrorCode TYPE_ALIAS_CANNOT_REFERENCE_ITSELF =
- CompileTimeErrorCode(
- 'TYPE_ALIAS_CANNOT_REFERENCE_ITSELF',
- "Typedefs can't reference themselves directly or recursively via "
- "another typedef.",
- hasPublishedDocs: true);
-
- /**
- * 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 "
- "type test.",
- correction: "Try using a different type, or "
- "changing the import to not be deferred.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the type used in the instance creation that should be
- * limited by the bound as specified in the class declaration
- * 1: the name of the type parameter
- * 2: the substituted bound of the type parameter
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a type argument isn't the same
- // as or a subclass of the bounds of the corresponding type parameter.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `String` isn't a
- // subclass of `num`:
- //
- // ```dart
- // class A<E extends num> {}
- //
- // var a = A<[!String!]>();
- // ```
- //
- // #### Common fixes
- //
- // Change the type argument to be a subclass of the bounds:
- //
- // ```dart
- // class A<E extends num> {}
- //
- // var a = A<int>();
- // ```
- static const CompileTimeErrorCode TYPE_ARGUMENT_NOT_MATCHING_BOUNDS =
- CompileTimeErrorCode(
- 'TYPE_ARGUMENT_NOT_MATCHING_BOUNDS',
- "'{0}' doesn't conform to the bound '{2}' of the type parameter '{1}'.",
- correction: "Try using a type that is or is a subclass of '{2}'.",
- hasPublishedDocs: true,
- );
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a static member references a
- // type parameter that is declared for the class. Type parameters only have
- // meaning for instances of the class.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the static method
- // `hasType` has a reference to the type parameter `T`:
- //
- // ```dart
- // class C<T> {
- // static bool hasType(Object o) => o is [!T!];
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the member can be an instance member, then remove the keyword `static`:
- //
- // ```dart
- // class C<T> {
- // bool hasType(Object o) => o is T;
- // }
- // ```
- //
- // If the member must be a static member, then make the member be generic:
- //
- // ```dart
- // class C<T> {
- // static bool hasType<S>(Object o) => o is S;
- // }
- // ```
- //
- // Note, however, that there isn’t a relationship between `T` and `S`, so this
- // second option changes the semantics from what was likely to be intended.
- static const CompileTimeErrorCode TYPE_PARAMETER_REFERENCED_BY_STATIC =
- CompileTimeErrorCode('TYPE_PARAMETER_REFERENCED_BY_STATIC',
- "Static members can't reference type parameters of the class.",
- correction: "Try removing the reference to the type parameter, or "
- "making the member an instance member.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the type parameter
- * 1: the name of the bounding type
- *
- * See [CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS].
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the bound of a type parameter
- // (the type following the `extends` keyword) is either directly or indirectly
- // the type parameter itself. Stating that the type parameter must be the same
- // as itself or a subtype of itself or a subtype of itself isn't helpful
- // because it will always be the same as itself.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the bound of `T` is
- // `T`:
- //
- // ```dart
- // class C<[!T!] extends T> {}
- // ```
- //
- // The following code produces this diagnostic because the bound of `T1` is
- // `T2`, and the bound of `T2` is `T1`, effectively making the bound of `T1`
- // be `T1`:
- //
- // ```dart
- // class C<[!T1!] extends T2, T2 extends T1> {}
- // ```
- //
- // #### Common fixes
- //
- // If the type parameter needs to be a subclass of some type, then replace the
- // bound with the required type:
- //
- // ```dart
- // class C<T extends num> {}
- // ```
- //
- // If the type parameter can be any type, then remove the `extends` clause:
- //
- // ```dart
- // class C<T> {}
- // ```
- static const CompileTimeErrorCode TYPE_PARAMETER_SUPERTYPE_OF_ITS_BOUND =
- CompileTimeErrorCode('TYPE_PARAMETER_SUPERTYPE_OF_ITS_BOUND',
- "'{0}' can't be a supertype of its upper bound.",
- correction:
- "Try using a type that is the same as or a subclass of '{1}'.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the right-hand side of an `is`
- // or `is!` test isn't a type.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the right-hand side is
- // a parameter, not a type:
- //
- // ```dart
- // typedef B = int Function(int);
- //
- // void f(Object a, B b) {
- // if (a is [!b!]) {
- // return;
- // }
- // }
- // ```
- //
- // #### Common fixes
- //
- // If you intended to use a type test, then replace the right-hand side with a
- // type:
- //
- // ```dart
- // typedef B = int Function(int);
- //
- // void f(Object a, B b) {
- // if (a is B) {
- // return;
- // }
- // }
- // ```
- //
- // If you intended to use a different kind of test, then change the test:
- //
- // ```dart
- // typedef B = int Function(int);
- //
- // void f(Object a, B b) {
- // if (a == b) {
- // return;
- // }
- // }
- // ```
- static const CompileTimeErrorCode TYPE_TEST_WITH_NON_TYPE =
- CompileTimeErrorCode(
- 'TYPE_TEST_WITH_NON_TYPE',
- "The name '{0}' isn't a type and can't be used in an 'is' "
- "expression.",
- correction: "Try correcting the name to match an existing type.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the name following the `is` in a
- // type test expression isn't defined.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because the name `Srting` isn't
- // defined:
- //
- // ```dart
- // void f(Object o) {
- // if (o is [!Srting!]) {
- // // ...
- // }
- // }
- // ```
- //
- // #### Common fixes
- //
- // Replace the name with the name of a type:
- //
- // ```dart
- // void f(Object o) {
- // if (o is String) {
- // // ...
- // }
- // }
- // ```
- static const CompileTimeErrorCode TYPE_TEST_WITH_UNDEFINED_NAME =
- CompileTimeErrorCode(
- 'TYPE_TEST_WITH_UNDEFINED_NAME',
- "The name '{0}' isn't defined, so it can't be used in an 'is' "
- "expression.",
- correction:
- "Try changing the name to the name of an existing type, or "
- "creating a type with the name '{0}'.",
- hasPublishedDocs: true);
-
- static const CompileTimeErrorCode UNCHECKED_INVOCATION_OF_NULLABLE_VALUE =
- CompileTimeErrorCode('UNCHECKED_USE_OF_NULLABLE_VALUE',
- "The function can't be unconditionally invoked because it can be 'null'.",
- correction: "Try adding a null check ('!').",
- hasPublishedDocs: true,
- uniqueName: 'UNCHECKED_INVOCATION_OF_NULLABLE_VALUE');
-
- static const CompileTimeErrorCode
- UNCHECKED_METHOD_INVOCATION_OF_NULLABLE_VALUE = CompileTimeErrorCode(
- 'UNCHECKED_USE_OF_NULLABLE_VALUE',
- "The method '{0}' can't be unconditionally invoked because the "
- "receiver can be 'null'.",
- correction:
- "Try making the call conditional (using '?.') or adding a null "
- "check to the target ('!').",
- hasPublishedDocs: true,
- uniqueName: 'UNCHECKED_METHOD_INVOCATION_OF_NULLABLE_VALUE');
-
- static const CompileTimeErrorCode
- UNCHECKED_OPERATOR_INVOCATION_OF_NULLABLE_VALUE = CompileTimeErrorCode(
- 'UNCHECKED_USE_OF_NULLABLE_VALUE',
- "The operator '{0}' can't be unconditionally invoked because the "
- "receiver can be 'null'.",
- correction: "Try adding a null check to the target ('!').",
- hasPublishedDocs: true,
- uniqueName: 'UNCHECKED_OPERATOR_INVOCATION_OF_NULLABLE_VALUE');
-
- static const CompileTimeErrorCode
- UNCHECKED_PROPERTY_ACCESS_OF_NULLABLE_VALUE = CompileTimeErrorCode(
- 'UNCHECKED_USE_OF_NULLABLE_VALUE',
- "The property '{0}' can't be unconditionally accessed because the "
- "receiver can be 'null'.",
- correction:
- "Try making the access conditional (using '?.') or adding a null "
- "check to the target ('!').",
- hasPublishedDocs: true,
- uniqueName: 'UNCHECKED_PROPERTY_ACCESS_OF_NULLABLE_VALUE');
-
- // #### Description
- //
- // The analyzer produces this diagnostic when an expression whose type is
- // [potentially non-nullable][] is dereferenced without first verifying that
- // the value isn't `null`.
- //
- // #### Example
- //
- // The following code produces this diagnostic because `s` can be `null` at
- // the point where it's referenced:
- //
- // ```dart
- // void f(String? s) {
- // if (s.[!length!] > 3) {
- // // ...
- // }
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the value really can be `null`, then add a test to ensure that members
- // are only accessed when the value isn't `null`:
- //
- // ```dart
- // void f(String? s) {
- // if (s != null && s.length > 3) {
- // // ...
- // }
- // }
- // ```
- //
- // If the expression is a variable and the value should never be `null`, then
- // change the type of the variable to be non-nullable:
- //
- // ```dart
- // void f(String s) {
- // if (s.length > 3) {
- // // ...
- // }
- // }
- // ```
- //
- // If you believe that the value of the expression should never be `null`, but
- // you can't change the type of the variable, and you're willing to risk
- // having an exception thrown at runtime if you're wrong, then you can assert
- // that the value isn't null:
- //
- // ```dart
- // void f(String? s) {
- // if (s!.length > 3) {
- // // ...
- // }
- // }
- // ```
- static const CompileTimeErrorCode
- UNCHECKED_USE_OF_NULLABLE_VALUE_AS_CONDITION = CompileTimeErrorCode(
- 'UNCHECKED_USE_OF_NULLABLE_VALUE',
- "A nullable expression can't be used as a condition.",
- correction:
- "Try checking that the value isn't 'null' before using it as a "
- 'condition.',
- hasPublishedDocs: true,
- uniqueName: 'UNCHECKED_USE_OF_NULLABLE_VALUE_AS_CONDITION');
-
- static const CompileTimeErrorCode
- UNCHECKED_USE_OF_NULLABLE_VALUE_AS_ITERATOR = CompileTimeErrorCode(
- 'UNCHECKED_USE_OF_NULLABLE_VALUE',
- "A nullable expression can't be used as an iterator in a for-in "
- 'loop.',
- correction:
- "Try checking that the value isn't 'null' before using it as an "
- 'iterator.',
- hasPublishedDocs: true,
- uniqueName: 'UNCHECKED_USE_OF_NULLABLE_VALUE_AS_ITERATOR');
-
- static const CompileTimeErrorCode UNCHECKED_USE_OF_NULLABLE_VALUE_IN_SPREAD =
- CompileTimeErrorCode('UNCHECKED_USE_OF_NULLABLE_VALUE',
- "A nullable expression can't be used in a spread.",
- correction:
- "Try checking that the value isn't 'null' before using it in a "
- 'spread, or use a null-aware spread.',
- hasPublishedDocs: true,
- uniqueName: 'UNCHECKED_USE_OF_NULLABLE_VALUE_IN_SPREAD');
-
- static const CompileTimeErrorCode
- UNCHECKED_USE_OF_NULLABLE_VALUE_IN_YIELD_EACH = CompileTimeErrorCode(
- 'UNCHECKED_USE_OF_NULLABLE_VALUE',
- "A nullable expression can't be used in a yield-each statement.",
- correction:
- "Try checking that the value isn't 'null' before using it in a "
- 'yield-each statement.',
- hasPublishedDocs: true,
- uniqueName: 'UNCHECKED_USE_OF_NULLABLE_VALUE_IN_YIELD_EACH');
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a name that isn't defined is
- // used as an annotation.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because the name `undefined`
- // isn't defined:
- //
- // ```dart
- // [!@undefined!]
- // void f() {}
- // ```
- //
- // #### Common fixes
- //
- // If the name is correct, but it isn’t declared yet, then declare the name as
- // a constant value:
- //
- // ```dart
- // const undefined = 'undefined';
- //
- // @undefined
- // void f() {}
- // ```
- //
- // If the name is wrong, replace the name with the name of a valid constant:
- //
- // ```dart
- // @deprecated
- // void f() {}
- // ```
- //
- // Otherwise, remove the annotation.
- static const CompileTimeErrorCode UNDEFINED_ANNOTATION = CompileTimeErrorCode(
- 'UNDEFINED_ANNOTATION', "Undefined name '{0}' used as an annotation.",
- correction: "Try defining the name or importing it from another library.",
- hasPublishedDocs: true,
- isUnresolvedIdentifier: true);
-
- /**
- * Parameters:
- * 0: the name of the undefined class
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when it encounters an identifier that
- // appears to be the name of a class but either isn't defined or isn't visible
- // in the scope in which it's being referenced.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `Piont` isn't defined:
- //
- // ```dart
- // class Point {}
- //
- // void f([!Piont!] p) {}
- // ```
- //
- // #### Common fixes
- //
- // If the identifier isn't defined, then either define it or replace it with
- // the name of a class that is defined. The example above can be corrected by
- // fixing the spelling of the class:
- //
- // ```dart
- // class Point {}
- //
- // void f(Point p) {}
- // ```
- //
- // If the class is defined but isn't visible, then you probably need to add an
- // import.
- static const CompileTimeErrorCode UNDEFINED_CLASS = CompileTimeErrorCode(
- 'UNDEFINED_CLASS', "Undefined class '{0}'.",
- correction: "Try changing the name to the name of an existing class, or "
- "creating a class with the name '{0}'.",
- hasPublishedDocs: true,
- isUnresolvedIdentifier: true);
-
- /**
- * Same as [CompileTimeErrorCode.UNDEFINED_CLASS], but to catch using
- * "boolean" instead of "bool" in order to improve the correction message.
- *
- * Parameters:
- * 0: the name of the undefined class
- */
- static const CompileTimeErrorCode UNDEFINED_CLASS_BOOLEAN =
- CompileTimeErrorCode('UNDEFINED_CLASS', "Undefined class '{0}'.",
- correction: "Try using the type 'bool'.",
- hasPublishedDocs: true,
- isUnresolvedIdentifier: true,
- uniqueName: 'UNDEFINED_CLASS_BOOLEAN');
-
- /**
- * Parameters:
- * 0: the name of the superclass that does not define the invoked constructor
- * 1: the name of the constructor being invoked
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a superclass constructor is
- // invoked in the initializer list of a constructor, but the superclass
- // doesn't define the constructor being invoked.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `A` doesn't have an
- // unnamed constructor:
- //
- // ```dart
- // class A {
- // A.n();
- // }
- // class B extends A {
- // B() : [!super()!];
- // }
- // ```
- //
- // The following code produces this diagnostic because `A` doesn't have a
- // constructor named `m`:
- //
- // ```dart
- // class A {
- // A.n();
- // }
- // class B extends A {
- // B() : [!super.m()!];
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the superclass defines a constructor that should be invoked, then change
- // the constructor being invoked:
- //
- // ```dart
- // class A {
- // A.n();
- // }
- // class B extends A {
- // B() : super.n();
- // }
- // ```
- //
- // If the superclass doesn't define an appropriate constructor, then define
- // the constructor being invoked:
- //
- // ```dart
- // class A {
- // A.m();
- // A.n();
- // }
- // class B extends A {
- // B() : super.m();
- // }
- // ```
- static const CompileTimeErrorCode UNDEFINED_CONSTRUCTOR_IN_INITIALIZER =
- CompileTimeErrorCode('UNDEFINED_CONSTRUCTOR_IN_INITIALIZER',
- "The class '{0}' doesn't have a constructor named '{1}'.",
- correction: "Try defining a constructor named '{1}' in '{0}', or "
- "invoking a different constructor.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the superclass that does not define the invoked constructor
- */
- static const CompileTimeErrorCode
- UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT = CompileTimeErrorCode(
- 'UNDEFINED_CONSTRUCTOR_IN_INITIALIZER',
- "The class '{0}' doesn't have an unnamed constructor.",
- correction: "Try defining an unnamed constructor in '{0}', or "
- "invoking a different constructor.",
- hasPublishedDocs: true,
- uniqueName: 'UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT',
- );
-
- /**
- * Parameters:
- * 0: the name of the enumeration constant that is not defined
- * 1: the name of the enumeration used to access the constant
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when it encounters an identifier that
- // appears to be the name of an enum constant, and the name either isn't
- // defined or isn't visible in the scope in which it's being referenced.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `E` doesn't define a
- // constant named `c`:
- //
- // ```dart
- // enum E {a, b}
- //
- // var e = E.[!c!];
- // ```
- //
- // #### Common fixes
- //
- // If the constant should be defined, then add it to the declaration of the
- // enum:
- //
- // ```dart
- // enum E {a, b, c}
- //
- // var e = E.c;
- // ```
- //
- // If the constant shouldn't be defined, then change the name to the name of
- // an existing constant:
- //
- // ```dart
- // enum E {a, b}
- //
- // var e = E.b;
- // ```
- static const CompileTimeErrorCode UNDEFINED_ENUM_CONSTANT =
- CompileTimeErrorCode('UNDEFINED_ENUM_CONSTANT',
- "There's no constant named '{0}' in '{1}'.",
- correction:
- "Try correcting the name to the name of an existing constant, or "
- "defining a constant named '{0}'.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the getter that is undefined
- * 1: the name of the extension that was explicitly specified
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an extension override is used to
- // invoke a getter, but the getter isn't defined by the specified extension.
- // The analyzer also produces this diagnostic when a static getter is
- // referenced but isn't defined by the specified extension.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because the extension `E`
- // doesn't declare an instance getter named `b`:
- //
- // ```dart
- // extension E on String {
- // String get a => 'a';
- // }
- //
- // extension F on String {
- // String get b => 'b';
- // }
- //
- // void f() {
- // E('c').[!b!];
- // }
- // ```
- //
- // The following code produces this diagnostic because the extension `E`
- // doesn't declare a static getter named `a`:
- //
- // ```dart
- // extension E on String {}
- //
- // var x = E.[!a!];
- // ```
- //
- // #### Common fixes
- //
- // If the name of the getter is incorrect, then change it to the name of an
- // existing getter:
- //
- // ```dart
- // extension E on String {
- // String get a => 'a';
- // }
- //
- // extension F on String {
- // String get b => 'b';
- // }
- //
- // void f() {
- // E('c').a;
- // }
- // ```
- //
- // If the name of the getter is correct but the name of the extension is
- // wrong, then change the name of the extension to the correct name:
- //
- // ```dart
- // extension E on String {
- // String get a => 'a';
- // }
- //
- // extension F on String {
- // String get b => 'b';
- // }
- //
- // void f() {
- // F('c').b;
- // }
- // ```
- //
- // If the name of the getter and extension are both correct, but the getter
- // isn't defined, then define the getter:
- //
- // ```dart
- // extension E on String {
- // String get a => 'a';
- // String get b => 'z';
- // }
- //
- // extension F on String {
- // String get b => 'b';
- // }
- //
- // void f() {
- // E('c').b;
- // }
- // ```
- static const CompileTimeErrorCode UNDEFINED_EXTENSION_GETTER =
- CompileTimeErrorCode('UNDEFINED_EXTENSION_GETTER',
- "The getter '{0}' isn't defined for the extension '{1}'.",
- correction:
- "Try correcting the name to the name of an existing getter, or "
- "defining a getter named '{0}'.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the method that is undefined
- * 1: the name of the extension that was explicitly specified
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an extension override is used to
- // invoke a method, but the method isn't defined by the specified extension.
- // The analyzer also produces this diagnostic when a static method is
- // referenced but isn't defined by the specified extension.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because the extension `E`
- // doesn't declare an instance method named `b`:
- //
- // ```dart
- // extension E on String {
- // String a() => 'a';
- // }
- //
- // extension F on String {
- // String b() => 'b';
- // }
- //
- // void f() {
- // E('c').[!b!]();
- // }
- // ```
- //
- // The following code produces this diagnostic because the extension `E`
- // doesn't declare a static method named `a`:
- //
- // ```dart
- // extension E on String {}
- //
- // var x = E.[!a!]();
- // ```
- //
- // #### Common fixes
- //
- // If the name of the method is incorrect, then change it to the name of an
- // existing method:
- //
- // ```dart
- // extension E on String {
- // String a() => 'a';
- // }
- //
- // extension F on String {
- // String b() => 'b';
- // }
- //
- // void f() {
- // E('c').a();
- // }
- // ```
- //
- // If the name of the method is correct, but the name of the extension is
- // wrong, then change the name of the extension to the correct name:
- //
- // ```dart
- // extension E on String {
- // String a() => 'a';
- // }
- //
- // extension F on String {
- // String b() => 'b';
- // }
- //
- // void f() {
- // F('c').b();
- // }
- // ```
- //
- // If the name of the method and extension are both correct, but the method
- // isn't defined, then define the method:
- //
- // ```dart
- // extension E on String {
- // String a() => 'a';
- // String b() => 'z';
- // }
- //
- // extension F on String {
- // String b() => 'b';
- // }
- //
- // void f() {
- // E('c').b();
- // }
- // ```
- static const CompileTimeErrorCode UNDEFINED_EXTENSION_METHOD =
- CompileTimeErrorCode('UNDEFINED_EXTENSION_METHOD',
- "The method '{0}' isn't defined for the extension '{1}'.",
- correction:
- "Try correcting the name to the name of an existing method, or "
- "defining a method named '{0}'.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the operator that is undefined
- * 1: the name of the extension that was explicitly specified
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an operator is invoked on a
- // specific extension when that extension doesn't implement the operator.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the extension `E`
- // doesn't define the operator `*`:
- //
- // ```dart
- // var x = E('') [!*!] 4;
- //
- // extension E on String {}
- // ```
- //
- // #### Common fixes
- //
- // If the extension is expected to implement the operator, then add an
- // implementation of the operator to the extension:
- //
- // ```dart
- // var x = E('') * 4;
- //
- // extension E on String {
- // int operator *(int multiplier) => length * multiplier;
- // }
- // ```
- //
- // If the operator is defined by a different extension, then change the name
- // of the extension to the name of the one that defines the operator.
- //
- // If the operator is defined on the argument of the extension override, then
- // remove the extension override:
- //
- // ```dart
- // var x = '' * 4;
- //
- // extension E on String {}
- // ```
- static const CompileTimeErrorCode UNDEFINED_EXTENSION_OPERATOR =
- CompileTimeErrorCode('UNDEFINED_EXTENSION_OPERATOR',
- "The operator '{0}' isn't defined for the extension '{1}'.",
- correction: "Try defining the operator '{0}'.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the setter that is undefined
- * 1: the name of the extension that was explicitly specified
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an extension override is used to
- // invoke a setter, but the setter isn't defined by the specified extension.
- // The analyzer also produces this diagnostic when a static setter is
- // referenced but isn't defined by the specified extension.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because the extension `E`
- // doesn't declare an instance setter named `b`:
- //
- // ```dart
- // extension E on String {
- // set a(String v) {}
- // }
- //
- // extension F on String {
- // set b(String v) {}
- // }
- //
- // void f() {
- // E('c').[!b!] = 'd';
- // }
- // ```
- //
- // The following code produces this diagnostic because the extension `E`
- // doesn't declare a static setter named `a`:
- //
- // ```dart
- // extension E on String {}
- //
- // void f() {
- // E.[!a!] = 3;
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the name of the setter is incorrect, then change it to the name of an
- // existing setter:
- //
- // ```dart
- // extension E on String {
- // set a(String v) {}
- // }
- //
- // extension F on String {
- // set b(String v) {}
- // }
- //
- // void f() {
- // E('c').a = 'd';
- // }
- // ```
- //
- // If the name of the setter is correct, but the name of the extension is
- // wrong, then change the name of the extension to the correct name:
- //
- // ```dart
- // extension E on String {
- // set a(String v) {}
- // }
- //
- // extension F on String {
- // set b(String v) {}
- // }
- //
- // void f() {
- // F('c').b = 'd';
- // }
- // ```
- //
- // If the name of the setter and extension are both correct, but the setter
- // isn't defined, then define the setter:
- //
- // ```dart
- // extension E on String {
- // set a(String v) {}
- // set b(String v) {}
- // }
- //
- // extension F on String {
- // set b(String v) {}
- // }
- //
- // void f() {
- // E('c').b = 'd';
- // }
- // ```
- static const CompileTimeErrorCode UNDEFINED_EXTENSION_SETTER =
- CompileTimeErrorCode('UNDEFINED_EXTENSION_SETTER',
- "The setter '{0}' isn't defined for the extension '{1}'.",
- correction:
- "Try correcting the name to the name of an existing setter, or "
- "defining a setter named '{0}'.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the method that is undefined
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when it encounters an identifier that
- // appears to be the name of a function but either isn't defined or isn't
- // visible in the scope in which it's being referenced.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because the name `emty` isn't
- // defined:
- //
- // ```dart
- // List<int> empty() => [];
- //
- // void main() {
- // print([!emty!]());
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the identifier isn't defined, then either define it or replace it with
- // the name of a function that is defined. The example above can be corrected
- // by fixing the spelling of the function:
- //
- // ```dart
- // List<int> empty() => [];
- //
- // void main() {
- // print(empty());
- // }
- // ```
- //
- // If the function is defined but isn't visible, then you probably need to add
- // an import or re-arrange your code to make the function visible.
- static const CompileTimeErrorCode UNDEFINED_FUNCTION = CompileTimeErrorCode(
- 'UNDEFINED_FUNCTION', "The function '{0}' isn't defined.",
- correction: "Try importing the library that defines '{0}', "
- "correcting the name to the name of an existing function, or "
- "defining a function named '{0}'.",
- hasPublishedDocs: true,
- isUnresolvedIdentifier: true);
-
- /**
- * Parameters:
- * 0: the name of the getter
- * 1: the name of the enclosing type where the getter is being looked for
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when it encounters an identifier that
- // appears to be the name of a getter but either isn't defined or isn't
- // visible in the scope in which it's being referenced.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `String` has no member
- // named `len`:
- //
- // ```dart
- // int f(String s) => s.[!len!];
- // ```
- //
- // #### Common fixes
- //
- // If the identifier isn't defined, then either define it or replace it with
- // the name of a getter that is defined. The example above can be corrected by
- // fixing the spelling of the getter:
- //
- // ```dart
- // int f(String s) => s.length;
- // ```
- static const CompileTimeErrorCode UNDEFINED_GETTER = CompileTimeErrorCode(
- 'UNDEFINED_GETTER', "The getter '{0}' isn't defined for the type '{1}'.",
- correction: "Try importing the library that defines '{0}', "
- "correcting the name to the name of an existing getter, or "
- "defining a getter or field named '{0}'.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the getter
- * 1: the name of the function type alias
- */
- static const CompileTimeErrorCode UNDEFINED_GETTER_ON_FUNCTION_TYPE =
- CompileTimeErrorCode('UNDEFINED_GETTER',
- "The getter '{0}' isn't defined for the '{1}' function type.",
- correction: "Try wrapping the function type alias in parentheses in "
- "order to access '{0}' as an extension getter on 'Type'.",
- hasPublishedDocs: true,
- uniqueName: 'UNDEFINED_GETTER_ON_FUNCTION_TYPE');
-
- /**
- * Parameters:
- * 0: the name of the identifier
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when it encounters an identifier that
- // either isn't defined or isn't visible in the scope in which it's being
- // referenced.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because the name `rihgt` isn't
- // defined:
- //
- // ```dart
- // int min(int left, int right) => left <= [!rihgt!] ? left : right;
- // ```
- //
- // #### Common fixes
- //
- // If the identifier isn't defined, then either define it or replace it with
- // an identifier that is defined. The example above can be corrected by
- // fixing the spelling of the variable:
- //
- // ```dart
- // int min(int left, int right) => left <= right ? left : right;
- // ```
- //
- // If the identifier is defined but isn't visible, then you probably need to
- // add an import or re-arrange your code to make the identifier visible.
- static const CompileTimeErrorCode UNDEFINED_IDENTIFIER =
- CompileTimeErrorCode('UNDEFINED_IDENTIFIER', "Undefined name '{0}'.",
- correction: "Try correcting the name to one that is defined, or "
- "defining the name.",
- hasPublishedDocs: true,
- isUnresolvedIdentifier: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the name `await` is used in a
- // method or function body without being declared, and the body isn't marked
- // with the `async` keyword. The name `await` only introduces an await
- // expression in an asynchronous function.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the name `await` is
- // used in the body of `f` even though the body of `f` isn't marked with the
- // `async` keyword:
- //
- // ```dart
- // void f(p) { [!await!] p; }
- // ```
- //
- // #### Common fixes
- //
- // Add the keyword `async` to the function body:
- //
- // ```dart
- // void f(p) async { await p; }
- // ```
- static const CompileTimeErrorCode UNDEFINED_IDENTIFIER_AWAIT =
- CompileTimeErrorCode('UNDEFINED_IDENTIFIER_AWAIT',
- "Undefined name 'await' in function body not marked with 'async'.",
- correction: "Try correcting the name to one that is defined, "
- "defining the name, or "
- "adding 'async' to the enclosing function body.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the method that is undefined
- * 1: the resolved type name that the method lookup is happening on
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when it encounters an identifier that
- // appears to be the name of a method but either isn't defined or isn't
- // visible in the scope in which it's being referenced.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because the identifier
- // `removeMiddle` isn't defined:
- //
- // ```dart
- // int f(List<int> l) => l.[!removeMiddle!]();
- // ```
- //
- // #### Common fixes
- //
- // If the identifier isn't defined, then either define it or replace it with
- // the name of a method that is defined. The example above can be corrected by
- // fixing the spelling of the method:
- //
- // ```dart
- // int f(List<int> l) => l.removeLast();
- // ```
- static const CompileTimeErrorCode UNDEFINED_METHOD = CompileTimeErrorCode(
- 'UNDEFINED_METHOD', "The method '{0}' isn't defined for the type '{1}'.",
- correction:
- "Try correcting the name to the name of an existing method, or "
- "defining a method named '{0}'.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the method
- * 1: the name of the function type alias
- */
- static const CompileTimeErrorCode UNDEFINED_METHOD_ON_FUNCTION_TYPE =
- CompileTimeErrorCode('UNDEFINED_METHOD',
- "The method '{0}' isn't defined for the '{1}' function type.",
- correction: "Try wrapping the function type alias in parentheses in "
- "order to access '{0}' as an extension method on 'Type'.",
- hasPublishedDocs: true,
- uniqueName: 'UNDEFINED_METHOD_ON_FUNCTION_TYPE');
-
- /**
- * Parameters:
- * 0: the name of the requested named parameter
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a method or function invocation
- // has a named argument, but the method or function being invoked doesn't
- // define a parameter with the same name.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `m` doesn't declare a
- // named parameter named `a`:
- //
- // ```dart
- // %language=2.9
- // class C {
- // m({int b}) {}
- // }
- //
- // void f(C c) {
- // c.m([!a!]: 1);
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the argument name is mistyped, then replace it with the correct name.
- // The example above can be fixed by changing `a` to `b`:
- //
- // ```dart
- // %language=2.9
- // class C {
- // m({int b}) {}
- // }
- //
- // void f(C c) {
- // c.m(b: 1);
- // }
- // ```
- //
- // If a subclass adds a parameter with the name in question, then cast the
- // receiver to the subclass:
- //
- // ```dart
- // %language=2.9
- // class C {
- // m({int b}) {}
- // }
- //
- // class D extends C {
- // m({int a, int b}) {}
- // }
- //
- // void f(C c) {
- // (c as D).m(a: 1);
- // }
- // ```
- //
- // If the parameter should be added to the function, then add it:
- //
- // ```dart
- // %language=2.9
- // class C {
- // m({int a, int b}) {}
- // }
- //
- // void f(C c) {
- // c.m(a: 1);
- // }
- // ```
- static const CompileTimeErrorCode UNDEFINED_NAMED_PARAMETER =
- CompileTimeErrorCode('UNDEFINED_NAMED_PARAMETER',
- "The named parameter '{0}' isn't defined.",
- correction:
- "Try correcting the name to an existing named parameter's name, "
- "or defining a named parameter with the name '{0}'.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the operator
- * 1: the name of the enclosing type where the operator is being looked for
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a user-definable operator is
- // invoked on an object for which the operator isn't defined.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because the class `C` doesn't
- // define the operator `+`:
- //
- // ```dart
- // class C {}
- //
- // C f(C c) => c [!+!] 2;
- // ```
- //
- // #### Common fixes
- //
- // If the operator should be defined for the class, then define it:
- //
- // ```dart
- // class C {
- // C operator +(int i) => this;
- // }
- //
- // C f(C c) => c + 2;
- // ```
- static const CompileTimeErrorCode UNDEFINED_OPERATOR = CompileTimeErrorCode(
- 'UNDEFINED_OPERATOR',
- "The operator '{0}' isn't defined for the type '{1}'.",
- correction: "Try defining the operator '{0}'.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a prefixed identifier is found
- // where the prefix is valid, but the identifier isn't declared in any of the
- // libraries imported using that prefix.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `dart:core` doesn't
- // define anything named `a`:
- //
- // ```dart
- // import 'dart:core' as p;
- //
- // void f() {
- // p.[!a!];
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the library in which the name is declared isn't imported yet, add an
- // import for the library.
- //
- // If the name is wrong, then change it to one of the names that's declared in
- // the imported libraries.
- static const CompileTimeErrorCode UNDEFINED_PREFIXED_NAME =
- CompileTimeErrorCode(
- 'UNDEFINED_PREFIXED_NAME',
- "The name '{0}' is being referenced through the prefix '{1}', but it "
- "isn't defined in any of the libraries imported using that "
- "prefix.",
- correction: "Try correcting the prefix or "
- "importing the library that defines '{0}'.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the setter
- * 1: the name of the enclosing type where the setter is being looked for
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when it encounters an identifier that
- // appears to be the name of a setter but either isn't defined or isn't
- // visible in the scope in which the identifier is being referenced.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because there isn't a setter
- // named `z`:
- //
- // ```dart
- // class C {
- // int x = 0;
- // void m(int y) {
- // this.[!z!] = y;
- // }
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the identifier isn't defined, then either define it or replace it with
- // the name of a setter that is defined. The example above can be corrected by
- // fixing the spelling of the setter:
- //
- // ```dart
- // class C {
- // int x = 0;
- // void m(int y) {
- // this.x = y;
- // }
- // }
- // ```
- static const CompileTimeErrorCode UNDEFINED_SETTER = CompileTimeErrorCode(
- 'UNDEFINED_SETTER', "The setter '{0}' isn't defined for the type '{1}'.",
- correction: "Try importing the library that defines '{0}', "
- "correcting the name to the name of an existing setter, or "
- "defining a setter or field named '{0}'.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the setter
- * 1: the name of the function type alias
- */
- static const CompileTimeErrorCode UNDEFINED_SETTER_ON_FUNCTION_TYPE =
- CompileTimeErrorCode('UNDEFINED_SETTER',
- "The setter '{0}' isn't defined for the '{1}' function type.",
- correction: "Try wrapping the function type alias in parentheses in "
- "order to access '{0}' as an extension getter on 'Type'.",
- hasPublishedDocs: true,
- uniqueName: 'UNDEFINED_SETTER_ON_FUNCTION_TYPE');
-
- /**
- * Parameters:
- * 0: the name of the getter
- * 1: the name of the enclosing type where the getter is being looked for
- */
- static const CompileTimeErrorCode UNDEFINED_SUPER_GETTER =
- CompileTimeErrorCode(
- 'UNDEFINED_SUPER_MEMBER',
- "The getter '{0}' isn't defined in a superclass of '{1}'.",
- correction: "Try correcting the name to the name of an existing getter, or "
- "defining a getter or field named '{0}' in a superclass.",
- hasPublishedDocs: true,
- uniqueName: 'UNDEFINED_SUPER_GETTER',
- );
-
- /**
- * Parameters:
- * 0: the name of the method that is undefined
- * 1: the resolved type name that the method lookup is happening on
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an inherited member (method,
- // getter, setter, or operator) is referenced using `super`, but there’s no
- // member with that name in the superclass chain.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `Object` doesn't define
- // a method named `n`:
- //
- // ```dart
- // class C {
- // void m() {
- // super.[!n!]();
- // }
- // }
- // ```
- //
- // The following code produces this diagnostic because `Object` doesn't define
- // a getter named `g`:
- //
- // ```dart
- // class C {
- // void m() {
- // super.[!g!];
- // }
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the inherited member you intend to invoke has a different name, then
- // make the name of the invoked member match the inherited member.
- //
- // If the member you intend to invoke is defined in the same class, then
- // remove the `super.`.
- //
- // If the member isn’t defined, then either add the member to one of the
- // superclasses or remove the invocation.
- static const CompileTimeErrorCode UNDEFINED_SUPER_METHOD =
- CompileTimeErrorCode(
- 'UNDEFINED_SUPER_MEMBER',
- "The method '{0}' isn't defined in a superclass of '{1}'.",
- correction: "Try correcting the name to the name of an existing method, or "
- "defining a method named '{0}' in a superclass.",
- hasPublishedDocs: true,
- uniqueName: 'UNDEFINED_SUPER_METHOD',
- );
-
- /**
- * Parameters:
- * 0: the name of the operator
- * 1: the name of the enclosing type where the operator is being looked for
- */
- static const CompileTimeErrorCode UNDEFINED_SUPER_OPERATOR =
- CompileTimeErrorCode(
- 'UNDEFINED_SUPER_MEMBER',
- "The operator '{0}' isn't defined in a superclass of '{1}'.",
- correction: "Try defining the operator '{0}' in a superclass.",
- hasPublishedDocs: true,
- uniqueName: 'UNDEFINED_SUPER_OPERATOR',
- );
-
- /**
- * Parameters:
- * 0: the name of the setter
- * 1: the name of the enclosing type where the setter is being looked for
- */
- static const CompileTimeErrorCode UNDEFINED_SUPER_SETTER =
- CompileTimeErrorCode(
- 'UNDEFINED_SUPER_MEMBER',
- "The setter '{0}' isn't defined in a superclass of '{1}'.",
- correction: "Try correcting the name to the name of an existing setter, or "
- "defining a setter or field named '{0}' in a superclass.",
- hasPublishedDocs: true,
- uniqueName: 'UNDEFINED_SUPER_SETTER',
- );
-
- /**
- * This is a specialization of [INSTANCE_ACCESS_TO_STATIC_MEMBER] that is used
- * when we are able to find the name defined in a supertype. It exists to
- * provide a more informative error message.
- *
- * Parameters:
- * 0: the name of the defining type
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when code in one class references a
- // static member in a superclass without prefixing the member's name with the
- // name of the superclass. Static members can only be referenced without a
- // prefix in the class in which they're declared.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the static field `x` is
- // referenced in the getter `g` without prefixing it with the name of the
- // defining class:
- //
- // ```dart
- // class A {
- // static int x = 3;
- // }
- //
- // class B extends A {
- // int get g => [!x!];
- // }
- // ```
- //
- // #### Common fixes
- //
- // Prefix the name of the static member with the name of the declaring class:
- //
- // ```dart
- // class A {
- // static int x = 3;
- // }
- //
- // class B extends A {
- // int get g => A.x;
- // }
- // ```
- static const CompileTimeErrorCode
- UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER = CompileTimeErrorCode(
- 'UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER',
- "Static members from supertypes must be qualified by the name of the "
- "defining type.",
- correction: "Try adding '{0}.' before the name.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the defining type
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an undefined name is found, and
- // the name is the same as a static member of the extended type or one of its
- // superclasses.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `m` is a static member
- // of the extended type `C`:
- //
- // ```dart
- // class C {
- // static void m() {}
- // }
- //
- // extension E on C {
- // void f() {
- // [!m!]();
- // }
- // }
- // ```
- //
- // #### Common fixes
- //
- // If you're trying to reference a static member that's declared outside the
- // extension, then add the name of the class or extension before the reference
- // to the member:
- //
- // ```dart
- // class C {
- // static void m() {}
- // }
- //
- // extension E on C {
- // void f() {
- // C.m();
- // }
- // }
- // ```
- //
- // If you're referencing a member that isn't declared yet, add a declaration:
- //
- // ```dart
- // class C {
- // static void m() {}
- // }
- //
- // extension E on C {
- // void f() {
- // m();
- // }
- //
- // void m() {}
- // }
- // ```
- static const CompileTimeErrorCode
- UNQUALIFIED_REFERENCE_TO_STATIC_MEMBER_OF_EXTENDED_TYPE =
- CompileTimeErrorCode(
- 'UNQUALIFIED_REFERENCE_TO_STATIC_MEMBER_OF_EXTENDED_TYPE',
- "Static members from the extended type or one of its superclasses "
- "must be qualified by the name of the defining type.",
- correction: "Try adding '{0}.' before the name.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the URI pointing to a non-existent file
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an import, export, or part
- // directive is found where the URI refers to a file that doesn't exist.
- //
- // #### Examples
- //
- // If the file `lib.dart` doesn't exist, the following code produces this
- // diagnostic:
- //
- // ```dart
- // import [!'lib.dart'!];
- // ```
- //
- // #### Common fixes
- //
- // If the URI was mistyped or invalid, then correct the URI.
- //
- // If the URI is correct, then create the file.
- static const CompileTimeErrorCode URI_DOES_NOT_EXIST = CompileTimeErrorCode(
- 'URI_DOES_NOT_EXIST', "Target of URI doesn't exist: '{0}'.",
- correction: "Try creating the file referenced by the URI, or "
- "Try using a URI for a file that does exist.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the URI pointing to a non-existent file
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an import, export, or part
- // directive is found where the URI refers to a file that doesn't exist and
- // the name of the file ends with a pattern that's commonly produced by code
- // generators, such as one of the following:
- // - `.g.dart`
- // - `.pb.dart`
- // - `.pbenum.dart`
- // - `.pbserver.dart`
- // - `.pbjson.dart`
- // - `.template.dart`
- //
- // #### Examples
- //
- // If the file `lib.g.dart` doesn't exist, the following code produces this
- // diagnostic:
- //
- // ```dart
- // import [!'lib.g.dart'!];
- // ```
- //
- // #### Common fixes
- //
- // If the file is a generated file, then run the generator that generates the
- // file.
- //
- // If the file isn't a generated file, then check the spelling of the URI or
- // create the file.
- static const CompileTimeErrorCode URI_HAS_NOT_BEEN_GENERATED =
- CompileTimeErrorCode('URI_HAS_NOT_BEEN_GENERATED',
- "Target of URI hasn't been generated: '{0}'.",
- correction: "Try running the generator that will generate the file "
- "referenced by the URI.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the string literal in an
- // `import`, `export`, or `part` directive contains an interpolation. The
- // resolution of the URIs in directives must happen before the declarations
- // are compiled, so expressions can’t be evaluated while determining the
- // values of the URIs.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the string in the
- // `import` directive contains an interpolation:
- //
- // ```dart
- // import [!'dart:$m'!];
- //
- // const m = 'math';
- // ```
- //
- // #### Common fixes
- //
- // Remove the interpolation from the URI:
- //
- // ```dart
- // import 'dart:math';
- //
- // var zero = min(0, 0);
- // ```
- static const CompileTimeErrorCode URI_WITH_INTERPOLATION =
- CompileTimeErrorCode(
- 'URI_WITH_INTERPOLATION', "URIs can't use string interpolation.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when it finds an expression whose
- // type is `void`, and the expression is used in a place where a value is
- // expected, such as before a member access or on the right-hand side of an
- // assignment.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `f` doesn't produce an
- // object on which `toString` can be invoked:
- //
- // ```dart
- // void f() {}
- //
- // void g() {
- // [!f()!].toString();
- // }
- // ```
- //
- // #### Common fixes
- //
- // Either rewrite the code so that the expression has a value or rewrite the
- // code so that it doesn't depend on the value.
- static const CompileTimeErrorCode USE_OF_VOID_RESULT = CompileTimeErrorCode(
- 'USE_OF_VOID_RESULT',
- "This expression has a type of 'void' so its value can't be used.",
- correction:
- "Try checking to see if you're using the correct API; there might "
- "be a function or call that returns void you didn't expect. Also "
- "check type parameters and variables which might also be void.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the type of the object being assigned.
- * 1: the type of the variable being assigned to
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the evaluation of a constant
- // expression would result in a `CastException`.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because the value of `x` is an
- // `int`, which can't be assigned to `y` because an `int` isn't a `String`:
- //
- // ```dart
- // %language=2.9
- // const Object x = 0;
- // const String y = [!x!];
- // ```
- //
- // #### Common fixes
- //
- // If the declaration of the constant is correct, then change the value being
- // assigned to be of the correct type:
- //
- // ```dart
- // %language=2.9
- // const Object x = 0;
- // const String y = '$x';
- // ```
- //
- // If the assigned value is correct, then change the declaration to have the
- // correct type:
- //
- // ```dart
- // %language=2.9
- // const Object x = 0;
- // const int y = x;
- // ```
- static const CompileTimeErrorCode VARIABLE_TYPE_MISMATCH =
- CompileTimeErrorCode(
- 'VARIABLE_TYPE_MISMATCH',
- "A value of type '{0}' can't be assigned to a const variable of type "
- "'{1}'.",
- correction: "Try using a subtype, or removing the 'const' keyword",
- hasPublishedDocs: true);
-
- /**
- * Let `C` be a generic class that declares a formal type parameter `X`, and
- * assume that `T` is a direct superinterface of `C`.
- *
- * It is a compile-time error if `X` is explicitly defined as a covariant or
- * 'in' type parameter and `X` occurs in a non-covariant position in `T`.
- * It is a compile-time error if `X` is explicitly defined as a contravariant
- * or 'out' type parameter and `X` occurs in a non-contravariant position in
- * `T`.
- *
- * Parameters:
- * 0: the name of the type parameter
- * 1: the variance modifier defined for {0}
- * 2: the variance position of the type parameter {0} in the
- * superinterface {3}
- * 3: the name of the superinterface
- */
- static const CompileTimeErrorCode
- WRONG_EXPLICIT_TYPE_PARAMETER_VARIANCE_IN_SUPERINTERFACE =
- CompileTimeErrorCode(
- 'WRONG_EXPLICIT_TYPE_PARAMETER_VARIANCE_IN_SUPERINTERFACE',
- "'{0}' is an '{1}' type parameter and can't be used in an '{2}' position in '{3}'.",
- correction: "Try using 'in' type parameters in 'in' positions and 'out' "
- "type parameters in 'out' positions in the superinterface.",
- );
-
- /**
- * Parameters:
- * 0: the name of the declared operator
- * 1: the number of parameters expected
- * 2: the number of parameters found in the operator declaration
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a declaration of an operator has
- // the wrong number of parameters.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because the operator `+` must
- // have a single parameter corresponding to the right operand:
- //
- // ```dart
- // class C {
- // int operator [!+!](a, b) => 0;
- // }
- // ```
- //
- // #### Common fixes
- //
- // Add or remove parameters to match the required number:
- //
- // ```dart
- // class C {
- // int operator +(a) => 0;
- // }
- // ```
- // TODO(brianwilkerson) It would be good to add a link to the spec or some
- // other documentation that lists the number of parameters for each operator,
- // but I don't know what to link to.
- static const CompileTimeErrorCode WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR =
- CompileTimeErrorCode(
- 'WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR',
- "Operator '{0}' should declare exactly {1} parameters, but {2} "
- "found.",
- hasPublishedDocs: true);
-
- /**
- * 7.1.1 Operators: It is a compile time error if the arity of the
- * user-declared operator - is not 0 or 1.
- *
- * Parameters:
- * 0: the number of parameters found in the operator declaration
- */
- static const CompileTimeErrorCode
- WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR_MINUS = CompileTimeErrorCode(
- 'WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR',
- "Operator '-' should declare 0 or 1 parameter, but {0} found.",
- hasPublishedDocs: true,
- uniqueName: 'WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR_MINUS');
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a setter is found that doesn't
- // declare exactly one required positional parameter.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because the setter `s` declares
- // two required parameters:
- //
- // ```dart
- // %language=2.9
- // class C {
- // set [!s!](int x, int y) {}
- // }
- // ```
- //
- // The following code produces this diagnostic because the setter `s` declares
- // one optional parameter:
- //
- // ```dart
- // %language=2.9
- // class C {
- // set [!s!]([int x]) {}
- // }
- // ```
- //
- // #### Common fixes
- //
- // Change the declaration so that there's exactly one required positional
- // parameter:
- //
- // ```dart
- // %language=2.9
- // class C {
- // set s(int x) {}
- // }
- // ```
- static const CompileTimeErrorCode WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER =
- CompileTimeErrorCode('WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER',
- "Setters must declare exactly one required positional parameter.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the type being referenced (<i>G</i>)
- * 1: the number of type parameters that were declared
- * 2: the number of type arguments provided
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a type that has type parameters
- // is used and type arguments are provided, but the number of type arguments
- // isn't the same as the number of type parameters.
- //
- // The analyzer also produces this diagnostic when a constructor is invoked
- // and the number of type arguments doesn't match the number of type
- // parameters declared for the class.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because `C` has one type
- // parameter but two type arguments are provided when it is used as a type
- // annotation:
- //
- // ```dart
- // class C<E> {}
- //
- // void f([!C<int, int>!] x) {}
- // ```
- //
- // The following code produces this diagnostic because `C` declares one type
- // parameter, but two type arguments are provided when creating an instance:
- //
- // ```dart
- // class C<E> {}
- //
- // var c = [!C<int, int>!]();
- // ```
- //
- // #### Common fixes
- //
- // Add or remove type arguments, as necessary, to match the number of type
- // parameters defined for the type:
- //
- // ```dart
- // class C<E> {}
- //
- // void f(C<int> x) {}
- // ```
- static const CompileTimeErrorCode WRONG_NUMBER_OF_TYPE_ARGUMENTS =
- CompileTimeErrorCode(
- 'WRONG_NUMBER_OF_TYPE_ARGUMENTS',
- "The type '{0}' is declared with {1} type parameters, "
- "but {2} type arguments were given.",
- correction:
- "Try adjusting the number of type arguments to match the number "
- "of type parameters.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the number of type parameters that were declared
- * 1: the number of type arguments provided
- */
- static const CompileTimeErrorCode
- WRONG_NUMBER_OF_TYPE_ARGUMENTS_ANONYMOUS_FUNCTION = CompileTimeErrorCode(
- 'WRONG_NUMBER_OF_TYPE_ARGUMENTS_FUNCTION',
- "This function is declared with {0} type parameters, "
- "but {1} type arguments were given.",
- correction:
- "Try adjusting the number of type arguments to match the number "
- "of type parameters.",
- uniqueName: 'WRONG_NUMBER_OF_TYPE_ARGUMENTS_ANONYMOUS_FUNCTION');
-
- /**
- * Parameters:
- * 0: the name of the class being instantiated
- * 1: the name of the constructor being invoked
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when type arguments are provided
- // after the name of a named constructor. Constructors can't declare type
- // parameters, so invocations can only provide the type arguments associated
- // with the class, and those type arguments are required to follow the name of
- // the class rather than the name of the constructor.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the type parameters
- // (`<String>`) follow the name of the constructor rather than the name of the
- // class:
- //
- // ```dart
- // class C<T> {
- // C.named();
- // }
- // C f() => C.named[!<String>!]();
- // ```
- //
- // #### Common fixes
- //
- // If the type arguments are for the class' type parameters, then move the
- // type arguments to follow the class name:
- //
- // ```dart
- // class C<T> {
- // C.named();
- // }
- // C f() => C<String>.named();
- // ```
- //
- // If the type arguments aren't for the class' type parameters, then remove
- // them:
- //
- // ```dart
- // class C<T> {
- // C.named();
- // }
- // C f() => C.named();
- // ```
- static const CompileTimeErrorCode WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR =
- CompileTimeErrorCode('WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR',
- "The constructor '{0}.{1}' doesn't have type parameters.",
- correction: "Try moving type arguments to after the type name.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the extension being referenced
- * 1: the number of type parameters that were declared
- * 2: the number of type arguments provided
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an extension that has type
- // parameters is used and type arguments are provided, but the number of type
- // arguments isn't the same as the number of type parameters.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the extension `E` is
- // declared to have a single type parameter (`T`), but the extension override
- // has two type arguments:
- //
- // ```dart
- // extension E<T> on List<T> {
- // int get len => length;
- // }
- //
- // void f(List<int> p) {
- // E[!<int, String>!](p).len;
- // }
- // ```
- //
- // #### Common fixes
- //
- // Change the type arguments so that there are the same number of type
- // arguments as there are type parameters:
- //
- // ```dart
- // extension E<T> on List<T> {
- // int get len => length;
- // }
- //
- // void f(List<int> p) {
- // E<int>(p).len;
- // }
- // ```
- static const CompileTimeErrorCode WRONG_NUMBER_OF_TYPE_ARGUMENTS_EXTENSION =
- CompileTimeErrorCode(
- 'WRONG_NUMBER_OF_TYPE_ARGUMENTS_EXTENSION',
- "The extension '{0}' is declared with {1} type parameters, "
- "but {2} type arguments were given.",
- correction: "Try adjusting the number of type arguments.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the function being referenced
- * 1: the number of type parameters that were declared
- * 2: the number of type arguments provided
- */
- static const CompileTimeErrorCode WRONG_NUMBER_OF_TYPE_ARGUMENTS_FUNCTION =
- CompileTimeErrorCode(
- 'WRONG_NUMBER_OF_TYPE_ARGUMENTS_FUNCTION',
- "The function '{0}' is declared with {1} type parameters, "
- "but {2} type arguments were given.",
- correction:
- "Try adjusting the number of type arguments to match the number "
- "of type parameters.");
-
- /**
- * Parameters:
- * 0: the name of the method being referenced (<i>G</i>)
- * 1: the number of type parameters that were declared
- * 2: the number of type arguments provided
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a method or function is invoked
- // with a different number of type arguments than the number of type
- // parameters specified in its declaration. There must either be no type
- // arguments or the number of arguments must match the number of parameters.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the invocation of the
- // method `m` has two type arguments, but the declaration of `m` only has one
- // type parameter:
- //
- // ```dart
- // class C {
- // int m<A>(A a) => 0;
- // }
- //
- // int f(C c) => c.m[!<int, int>!](2);
- // ```
- //
- // #### Common fixes
- //
- // If the type arguments are necessary, then make them match the number of
- // type parameters by either adding or removing type arguments:
- //
- // ```dart
- // class C {
- // int m<A>(A a) => 0;
- // }
- //
- // int f(C c) => c.m<int>(2);
- // ```
- //
- // If the type arguments aren't necessary, then remove them:
- //
- // ```dart
- // class C {
- // int m<A>(A a) => 0;
- // }
- //
- // int f(C c) => c.m(2);
- // ```
- static const CompileTimeErrorCode WRONG_NUMBER_OF_TYPE_ARGUMENTS_METHOD =
- CompileTimeErrorCode(
- 'WRONG_NUMBER_OF_TYPE_ARGUMENTS_METHOD',
- "The method '{0}' is declared with {1} type parameters, but {2} type "
- "arguments are given.",
- correction: "Try adjusting the number of type arguments.",
- hasPublishedDocs: true);
-
- /**
- * Let `C` be a generic class that declares a formal type parameter `X`, and
- * assume that `T` is a direct superinterface of `C`. It is a compile-time
- * error if `X` occurs contravariantly or invariantly in `T`.
- */
- static const CompileTimeErrorCode
- WRONG_TYPE_PARAMETER_VARIANCE_IN_SUPERINTERFACE = CompileTimeErrorCode(
- 'WRONG_TYPE_PARAMETER_VARIANCE_IN_SUPERINTERFACE',
- "'{0}' can't be used contravariantly or invariantly in '{1}'.",
- correction: "Try not using class type parameters in types of formal "
- "parameters of function types, nor in explicitly contravariant or "
- "invariant superinterfaces.",
- );
-
- /**
- * Let `C` be a generic class that declares a formal type parameter `X`.
- *
- * If `X` is explicitly contravariant then it is a compile-time error for
- * `X` to occur in a non-contravariant position in a member signature in the
- * body of `C`, except when `X` is in a contravariant position in the type
- * annotation of a covariant formal parameter.
- *
- * If `X` is explicitly covariant then it is a compile-time error for
- * `X` to occur in a non-covariant position in a member signature in the
- * body of `C`, except when `X` is in a covariant position in the type
- * annotation of a covariant formal parameter.
- *
- * Parameters:
- * 0: the variance modifier defined for {0}
- * 1: the name of the type parameter
- * 2: the variance position that the type parameter {1} is in
- */
- static const CompileTimeErrorCode WRONG_TYPE_PARAMETER_VARIANCE_POSITION =
- CompileTimeErrorCode(
- 'WRONG_TYPE_PARAMETER_VARIANCE_POSITION',
- "The '{0}' type parameter '{1}' can't be used in an '{2}' position.",
- correction: "Try removing the type parameter or change the explicit "
- "variance modifier declaration for the type parameter to another one "
- "of 'in', 'out', or 'inout'.",
- );
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a `yield` or `yield*` statement
- // appears in a function whose body isn't marked with one of the `async*` or
- // `sync*` modifiers.
- //
- // #### Example
- //
- // The following code produces this diagnostic because `yield` is being used
- // in a function whose body doesn't have a modifier:
- //
- // ```dart
- // Iterable<int> get digits {
- // yield* [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
- // }
- // ```
- //
- // The following code produces this diagnostic because `yield*` is being used
- // in a function whose body has the `async` modifier rather than the `async*`
- // modifier:
- //
- // ```dart
- // Stream<int> get digits async {
- // yield* [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
- // }
- // ```
- //
- // #### Common fixes
- //
- // Add a modifier, or change the existing modifier to be either `async*` or
- // `sync*`:
- //
- // ```dart
- // Iterable<int> get digits sync* {
- // yield* [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
- // }
- // ```
- static const CompileTimeErrorCode YIELD_EACH_IN_NON_GENERATOR =
- CompileTimeErrorCode(
- 'YIELD_IN_NON_GENERATOR',
- "Yield-each statements must be in a generator function "
- "(one marked with either 'async*' or 'sync*').",
- correction:
- "Try adding 'async*' or 'sync*' to the enclosing function.",
- hasPublishedDocs: true,
- uniqueName: 'YIELD_EACH_IN_NON_GENERATOR');
-
- /**
- * ?? Yield: It is a compile-time error if a yield statement appears in a
- * function that is not a generator function.
- *
- * No parameters.
- */
- static const CompileTimeErrorCode YIELD_IN_NON_GENERATOR =
- CompileTimeErrorCode(
- 'YIELD_IN_NON_GENERATOR',
- "Yield statements must be in a generator function "
- "(one marked with either 'async*' or 'sync*').",
- correction:
- "Try adding 'async*' or 'sync*' to the enclosing function.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the type of the expression after `yield`
- * 1: the return type of the function containing the `yield`
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the type of object produced by a
- // `yield` expression doesn't match the type of objects that are to be
- // returned from the `Iterable` or `Stream` types that are returned from a
- // generator (a function or method marked with either `sync*` or `async*`).
- //
- // #### Example
- //
- // The following code produces this diagnostic because the getter `zero` is
- // declared to return an `Iterable` that returns integers, but the `yield` is
- // returning a string from the iterable:
- //
- // ```dart
- // Iterable<int> get zero sync* {
- // yield [!'0'!];
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the return type of the function is correct, then fix the expression
- // following the keyword `yield` to return the correct type:
- //
- // ```dart
- // Iterable<int> get zero sync* {
- // yield 0;
- // }
- // ```
- //
- // If the expression following the `yield` is correct, then change the return
- // type of the function to allow it:
- //
- // ```dart
- // Iterable<String> get zero sync* {
- // yield '0';
- // }
- // ```
- static const CompileTimeErrorCode YIELD_OF_INVALID_TYPE =
- CompileTimeErrorCode(
- 'YIELD_OF_INVALID_TYPE',
- "The type '{0}' implied by the 'yield' expression must be assignable "
- "to '{1}'.",
- hasPublishedDocs: true);
-
- /**
- * Initialize a newly created error code to have the given [name]. The message
- * associated with the error will be created from the given [message]
- * template. The correction associated with the error will be created from the
- * given [correction] template.
- */
- const CompileTimeErrorCode(
- String name,
- String message, {
- String? correction,
- bool hasPublishedDocs = false,
- bool isUnresolvedIdentifier = false,
- String? uniqueName,
- }) : super(
- correction: correction,
- hasPublishedDocs: hasPublishedDocs,
- isUnresolvedIdentifier: isUnresolvedIdentifier,
- message: message,
- name: name,
- uniqueName: 'CompileTimeErrorCode.${uniqueName ?? name}',
- );
-
- @override
- ErrorSeverity get errorSeverity => ErrorType.COMPILE_TIME_ERROR.severity;
-
- @override
- ErrorType get type => ErrorType.COMPILE_TIME_ERROR;
-}
-
-/**
- * This class has experimental Language-specific codes.
- *
- * Currently it only contains codes related to implicit dynamic.
- */
-class LanguageCode extends ErrorCode {
- /**
- * This is appended to the end of an error message about implicit dynamic.
- *
- * The idea is to make sure the user is aware that this error message is the
- * result of turning on a particular option, and they are free to turn it
- * back off.
- */
- static const String _implicitDynamicCorrection =
- "Try adding an explicit type, or remove implicit-dynamic from your "
- "analysis options file.";
-
- static const LanguageCode IMPLICIT_DYNAMIC_FIELD = LanguageCode(
- 'IMPLICIT_DYNAMIC_FIELD', "Missing field type for '{0}'.",
- correction: _implicitDynamicCorrection);
-
- static const LanguageCode IMPLICIT_DYNAMIC_FUNCTION = LanguageCode(
- 'IMPLICIT_DYNAMIC_FUNCTION',
- "Missing type arguments for generic function '{0}<{1}>'.",
- correction: _implicitDynamicCorrection);
-
- static const LanguageCode IMPLICIT_DYNAMIC_INVOKE = LanguageCode(
- 'IMPLICIT_DYNAMIC_INVOKE',
- "Missing type arguments for calling generic function type '{0}'.",
- correction: _implicitDynamicCorrection);
-
- static const LanguageCode IMPLICIT_DYNAMIC_LIST_LITERAL = LanguageCode(
- 'IMPLICIT_DYNAMIC_LIST_LITERAL',
- "Missing type argument for list literal.",
- correction: _implicitDynamicCorrection);
-
- static const LanguageCode IMPLICIT_DYNAMIC_MAP_LITERAL = LanguageCode(
- 'IMPLICIT_DYNAMIC_MAP_LITERAL', "Missing type arguments for map literal.",
- correction: _implicitDynamicCorrection);
-
- static const LanguageCode IMPLICIT_DYNAMIC_METHOD = LanguageCode(
- 'IMPLICIT_DYNAMIC_METHOD',
- "Missing type arguments for generic method '{0}<{1}>'.",
- correction: _implicitDynamicCorrection);
-
- static const LanguageCode IMPLICIT_DYNAMIC_PARAMETER = LanguageCode(
- 'IMPLICIT_DYNAMIC_PARAMETER', "Missing parameter type for '{0}'.",
- correction: _implicitDynamicCorrection);
-
- static const LanguageCode IMPLICIT_DYNAMIC_RETURN = LanguageCode(
- 'IMPLICIT_DYNAMIC_RETURN', "Missing return type for '{0}'.",
- correction: _implicitDynamicCorrection);
-
- static const LanguageCode IMPLICIT_DYNAMIC_TYPE = LanguageCode(
- 'IMPLICIT_DYNAMIC_TYPE', "Missing type arguments for generic type '{0}'.",
- correction: _implicitDynamicCorrection);
-
- static const LanguageCode IMPLICIT_DYNAMIC_VARIABLE = LanguageCode(
- 'IMPLICIT_DYNAMIC_VARIABLE', "Missing variable type for '{0}'.",
- correction: _implicitDynamicCorrection);
-
- @override
- final ErrorType type = ErrorType.COMPILE_TIME_ERROR;
-
- /**
- * Initialize a newly created language code to have the given [type] and
- * [name].
- *
- * The message associated with the code will be created from the given
- * [message] template. The correction associated with the code will be
- * created from the optional [correction] template.
- */
- const LanguageCode(String name, String message,
- {String? correction, bool hasPublishedDocs = false})
- : super(
- correction: correction,
- hasPublishedDocs: hasPublishedDocs,
- message: message,
- name: name,
- uniqueName: 'LanguageCode.$name',
- );
-
- @override
- ErrorSeverity get errorSeverity => type.severity;
-}
-
-/**
- * The error codes used for static warnings. The convention for this class is
- * for the name of the error code to indicate the problem that caused the error
- * to be generated and for the error message to explain what is wrong and, when
- * appropriate, how the problem can be corrected.
- */
-class StaticWarningCode extends AnalyzerErrorCode {
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic in two cases.
- //
- // The first is when the left operand of an `??` operator can't be `null`.
- // The right operand is only evaluated if the left operand has the value
- // `null`, and because the left operand can't be `null`, the right operand is
- // never evaluated.
- //
- // The second is when the left-hand side of an assignment using the `??=`
- // operator can't be `null`. The right-hand side is only evaluated if the
- // left-hand side has the value `null`, and because the left-hand side can't
- // be `null`, the right-hand side is never evaluated.
- //
- // #### Example
- //
- // The following code produces this diagnostic because `x` can't be `null`:
- //
- // ```dart
- // int f(int x) {
- // return x ?? [!0!];
- // }
- // ```
- //
- // The following code produces this diagnostic because `f` can't be `null`:
- //
- // ```dart
- // class C {
- // int f = -1;
- //
- // void m(int x) {
- // f ??= [!x!];
- // }
- // }
- // ```
- //
- // #### Common fixes
- //
- // If the diagnostic is reported for an `??` operator, then remove the `??`
- // operator and the right operand:
- //
- // ```dart
- // int f(int x) {
- // return x;
- // }
- // ```
- //
- // If the diagnostic is reported for an assignment, and the assignment isn't
- // needed, then remove the assignment:
- //
- // ```dart
- // class C {
- // int f = -1;
- //
- // void m(int x) {
- // }
- // }
- // ```
- //
- // If the assignment is needed, but should be based on a different condition,
- // then rewrite the code to use `=` and the different condition:
- //
- // ```dart
- // class C {
- // int f = -1;
- //
- // void m(int x) {
- // if (f < 0) {
- // f = x;
- // }
- // }
- // }
- // ```
- static const StaticWarningCode DEAD_NULL_AWARE_EXPRESSION = StaticWarningCode(
- 'DEAD_NULL_AWARE_EXPRESSION',
- "The left operand can't be null, so the right operand is never executed.",
- correction: "Try removing the operator and the right operand.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the null-aware operator that is invalid
- * 1: the non-null-aware operator that can replace the invalid operator
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a null-aware operator (`?.`,
- // `?..`, `?[`, `?..[`, or `...?`) is used on a receiver that's known to be
- // non-nullable.
- //
- // #### Example
- //
- // The following code produces this diagnostic because `s` can't be `null`:
- //
- // ```dart
- // int? getLength(String s) {
- // return s[!?.!]length;
- // }
- // ```
- //
- // The following code produces this diagnostic because `a` can't be `null`:
- //
- // ```dart
- // var a = [];
- // var b = [[!...?!]a];
- // ```
- //
- // The following code produces this diagnostic because `s?.length` can't
- // return `null`:
- //
- // ```dart
- // void f(String? s) {
- // s?.length[!?.!]isEven;
- // }
- // ```
- //
- // The reason `s?.length` can't return `null` is because the null-aware
- // operator following `s` short-circuits the evaluation of both `length` and
- // `isEven` if `s` is `null`. In other words, if `s` is `null`, then neither
- // `length` nor `isEven` will be invoked, and if `s` is non-`null`, then
- // `length` can't return a `null` value. Either way, `isEven` can't be invoked
- // on a `null` value, so the null-aware operator is not necessary. See
- // [Understanding null safety](/null-safety/understanding-null-safety#smarter-null-aware-methods)
- // for more details.
- //
- // The following code produces this diagnostic because `s` can't be `null`.
- //
- // ```dart
- // void f(Object? o) {
- // var s = o as String;
- // s[!?.!]length;
- // }
- // ```
- //
- // The reason `s` can't be null, despite the fact that `o` can be `null`, is
- // because of the cast to `String`, which is a non-nullable type. If `o` ever
- // has the value `null`, the cast will fail and the invocation of `length`
- // will not happen.
- //
- // #### Common fixes
- //
- // Replace the null-aware operator with a non-null-aware equivalent; for
- // example, change `?.` to `.`:
- //
- // ```dart
- // int getLength(String s) {
- // return s.length;
- // }
- // ```
- //
- // (Note that the return type was also changed to be non-nullable, which might
- // not be appropriate in some cases.)
- static const StaticWarningCode INVALID_NULL_AWARE_OPERATOR =
- StaticWarningCode(
- 'INVALID_NULL_AWARE_OPERATOR',
- "The receiver can't be null, so the null-aware operator '{0}' is "
- "unnecessary.",
- correction: "Try replacing the operator '{0}' with '{1}'.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the null-aware operator that is invalid
- * 1: the non-null-aware operator that can replace the invalid operator
- */
- static const StaticWarningCode
- INVALID_NULL_AWARE_OPERATOR_AFTER_SHORT_CIRCUIT = StaticWarningCode(
- 'INVALID_NULL_AWARE_OPERATOR',
- "The receiver can't be null because of short-circuiting, so the "
- "null-aware operator '{0}' can't be used.",
- correction: "Try replacing the operator '{0}' with '{1}'.",
- hasPublishedDocs: true,
- uniqueName: 'INVALID_NULL_AWARE_OPERATOR_AFTER_SHORT_CIRCUIT',
- );
-
- /**
- * 7.1 Instance Methods: It is a static warning if an instance method
- * <i>m1</i> overrides an instance member <i>m2</i>, the signature of
- * <i>m2</i> explicitly specifies a default value for a formal parameter
- * <i>p</i> and the signature of <i>m1</i> specifies a different default value
- * for <i>p</i>.
- */
- static const StaticWarningCode
- INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_NAMED = StaticWarningCode(
- 'INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_NAMED',
- "Parameters can't override default values, this method overrides "
- "'{0}.{1}' where '{2}' has a different value.",
- correction: "Try using the same default value in both methods.");
-
- /**
- * 7.1 Instance Methods: It is a static warning if an instance method
- * <i>m1</i> overrides an instance member <i>m2</i>, the signature of
- * <i>m2</i> explicitly specifies a default value for a formal parameter
- * <i>p</i> and the signature of <i>m1</i> specifies a different default value
- * for <i>p</i>.
- */
- static const StaticWarningCode
- INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_POSITIONAL = StaticWarningCode(
- 'INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_POSITIONAL',
- "Parameters can't override default values, this method overrides "
- "'{0}.{1}' where this positional parameter has a different "
- "value.",
- correction: "Try using the same default value in both methods.");
-
- /**
- * Parameters:
- * 0: the name of the constant that is missing
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a `switch` statement for an enum
- // doesn't include an option for one of the values in the enumeration.
- //
- // Note that `null` is always a possible value for an enum and therefore also
- // must be handled.
- //
- // #### Examples
- //
- // The following code produces this diagnostic because the enum constant `e2`
- // isn't handled:
- //
- // ```dart
- // enum E { e1, e2 }
- //
- // void f(E e) {
- // [!switch (e)!] {
- // case E.e1:
- // break;
- // }
- // }
- // ```
- //
- // #### Common fixes
- //
- // If there's special handling for the missing values, then add a `case`
- // clause for each of the missing values:
- //
- // ```dart
- // enum E { e1, e2 }
- //
- // void f(E e) {
- // switch (e) {
- // case E.e1:
- // break;
- // case E.e2:
- // break;
- // }
- // }
- // ```
- //
- // If the missing values should be handled the same way, then add a `default`
- // clause:
- //
- // ```dart
- // enum E { e1, e2 }
- //
- // void f(E e) {
- // switch (e) {
- // case E.e1:
- // break;
- // default:
- // break;
- // }
- // }
- // ```
- // TODO(brianwilkerson) This documentation will need to be updated when NNBD
- // ships.
- static const StaticWarningCode MISSING_ENUM_CONSTANT_IN_SWITCH =
- StaticWarningCode(
- 'MISSING_ENUM_CONSTANT_IN_SWITCH', "Missing case clause for '{0}'.",
- correction: "Try adding a case clause for the missing constant, or "
- "adding a default clause.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the operand of the `!` operator
- // can't be `null`.
- //
- // #### Example
- //
- // The following code produces this diagnostic because `x` can't be `null`:
- //
- // ```dart
- // int f(int x) {
- // return x[!!!];
- // }
- // ```
- //
- // #### Common fixes
- //
- // Remove the null check operator (`!`):
- //
- // ```dart
- // int f(int x) {
- // return x;
- // }
- // ```
- static const StaticWarningCode UNNECESSARY_NON_NULL_ASSERTION =
- StaticWarningCode('UNNECESSARY_NON_NULL_ASSERTION',
- "The '!' will have no effect because the receiver can't be null.",
- correction: "Try removing the '!' operator.", hasPublishedDocs: true);
-
- /**
- * Initialize a newly created error code to have the given [name]. The message
- * associated with the error will be created from the given [message]
- * template. The correction associated with the error will be created from the
- * given [correction] template.
- */
- const StaticWarningCode(
- String name,
- String message, {
- String? correction,
- bool hasPublishedDocs = false,
- bool isUnresolvedIdentifier = false,
- String? uniqueName,
- }) : super(
- correction: correction,
- hasPublishedDocs: hasPublishedDocs,
- isUnresolvedIdentifier: isUnresolvedIdentifier,
- message: message,
- name: name,
- uniqueName: 'StaticWarningCode.${uniqueName ?? name}',
- );
-
- @override
- ErrorSeverity get errorSeverity => ErrorSeverity.WARNING;
-
- @override
- ErrorType get type => ErrorType.STATIC_WARNING;
-}
+export 'package:analyzer/src/error/codes.g.dart';
diff --git a/pkg/analyzer/lib/src/error/codes.g.dart b/pkg/analyzer/lib/src/error/codes.g.dart
new file mode 100644
index 0000000..eb89966
--- /dev/null
+++ b/pkg/analyzer/lib/src/error/codes.g.dart
@@ -0,0 +1,16058 @@
+// 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.
+ //
+ // #### Example
+ //
+ // 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.",
+ correction:
+ "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.",
+ correction: "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.
+ //
+ // #### Examples
+ //
+ // 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}'.",
+ correction:
+ "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 name of the first declaring extension
+ * 2: the name of the second declaring extension
+ */
+ // #### 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.
+ //
+ // #### Examples
+ //
+ // 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 extensions {1}, and none are more specific.",
+ correction:
+ "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.
+ //
+ // #### Examples
+ //
+ // 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}.",
+ correction:
+ "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.
+ //
+ // #### Examples
+ //
+ // 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.",
+ correction:
+ "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.
+ //
+ // #### Examples
+ //
+ // 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.",
+ correction:
+ "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.
+ //
+ // #### Examples
+ //
+ // 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.",
+ correction:
+ "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`.
+ //
+ // #### Examples
+ //
+ // 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.",
+ correction: "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.
+ //
+ // #### Examples
+ //
+ // 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.",
+ correction: "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.
+ //
+ // #### Examples
+ //
+ // 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}'.",
+ correction:
+ "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.
+ //
+ // #### Examples
+ //
+ // 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.",
+ correction:
+ "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.",
+ correction:
+ "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.",
+ correction:
+ "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.
+ //
+ // #### Example
+ //
+ // 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 change the
+ // return type so that it's valid to return `null`:
+ //
+ // ```dart
+ // class C<T> {
+ // T? m(T t) {
+ // print(t);
+ // }
+ // }
+ // ```
+ 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 is a potentially non-nullable type.",
+ correction: "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.",
+ correction: "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.",
+ correction: "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.
+ //
+ // #### Examples
+ //
+ // 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.",
+ correction: "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.",
+ correction: "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.",
+ correction: "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.",
+ correction: "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`.
+ //
+ // #### Examples
+ //
+ // 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'.",
+ correction: "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.
+ //
+ // #### Examples
+ //
+ // 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.",
+ correction:
+ "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.",
+ correction: "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.",
+ correction:
+ "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}.",
+ correction:
+ "Try invoking a different constructor, or defining a constructor named '{1}'.",
+ uniqueName: 'CLASS_INSTANTIATION_ACCESS_TO_UNKNOWN_MEMBER',
+ );
+
+ /**
+ * 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.
+ //
+ // #### Examples
+ //
+ // 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.",
+ correction: "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.
+ //
+ // #### Example
+ //
+ // 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.",
+ correction: "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.",
+ correction: "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.",
+ correction: "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.",
+ correction: "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.",
+ correction:
+ "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.",
+ correction:
+ "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.",
+ correction: "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.",
+ correction: "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_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.",
+ correction: "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.",
+ correction: "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_EXTENSION = CompileTimeErrorCode(
+ 'CONFLICTING_TYPE_VARIABLE_AND_MEMBER',
+ "'{0}' can't be used to name both a type variable and a member in this extension.",
+ correction: "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.",
+ correction: "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.",
+ correction: "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}'.",
+ correction: "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.",
+ correction: "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.",
+ correction:
+ "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.",
+ correction:
+ "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}.",
+ correction:
+ "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}.",
+ correction:
+ "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}'.",
+ correction:
+ "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).
+ //
+ // #### Examples
+ //
+ // 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.",
+ correction:
+ "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'.",
+ correction:
+ "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.",
+ correction: "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.
+ //
+ // #### Examples
+ //
+ // 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.",
+ correction: "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.",
+ correction:
+ "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.
+ //
+ // #### Examples
+ //
+ // 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.",
+ correction:
+ "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.",
+ correction:
+ "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.
+ //
+ // #### Examples
+ //
+ // 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.",
+ correction: "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.",
+ correction:
+ "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.
+ //
+ // #### Examples
+ //
+ // 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.
+ //
+ // #### Examples
+ //
+ // 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`.
+ //
+ // #### Examples
+ //
+ // 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.",
+ correction: "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.
+ //
+ // #### Examples
+ //
+ // 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.",
+ correction:
+ "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.",
+ correction: "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.",
+ correction: "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.",
+ correction: "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.",
+ correction: "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}'.",
+ correction: "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.",
+ correction: "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.",
+ correction: "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.",
+ correction: "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.
+ //
+ // #### Examples
+ //
+ // 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.",
+ correction:
+ "Try removing either the default value or the 'required' modifier.",
+ );
+
+ /**
+ * 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.",
+ correction:
+ "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.",
+ correction: "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.",
+ correction:
+ "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.",
+ correction: "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.",
+ correction: "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.
+ //
+ // #### Examples
+ //
+ // 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.",
+ correction: "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 field
+ // 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 field 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.",
+ correction:
+ "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.
+ //
+ // #### Examples
+ //
+ // 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.",
+ correction:
+ "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}'.",
+ correction:
+ "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.",
+ correction: "Try renaming the constant.",
+ );
+
+ /**
+ * 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.
+ //
+ // #### Examples
+ //
+ // 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.",
+ correction: "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.
+ //
+ // #### Examples
+ //
+ // 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.",
+ correction: "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.",
+ correction: "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.",
+ correction: "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 map literal has either one or
+ // more than two type arguments.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the map literal has
+ // three type arguments when it can have either two or zero:
+ //
+ // ```dart
+ // var m = [!<int, String, int>!]{};
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Remove all except two of the type arguments:
+ //
+ // ```dart
+ // var m = <int, String>{};
+ // ```
+ static const CompileTimeErrorCode EXPECTED_TWO_MAP_TYPE_ARGUMENTS =
+ CompileTimeErrorCode(
+ 'EXPECTED_TWO_MAP_TYPE_ARGUMENTS',
+ "Map literals require two type arguments or none, but {0} found.",
+ correction: "Try adjusting the number of type arguments.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the uri pointing to a library
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when it finds an export whose `dart:`
+ // URI references an internal library.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because `_interceptors` is an
+ // internal library:
+ //
+ // ```dart
+ // export [!'dart:_interceptors'!];
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Remove the export directive.
+ static const CompileTimeErrorCode EXPORT_INTERNAL_LIBRARY =
+ CompileTimeErrorCode(
+ 'EXPORT_INTERNAL_LIBRARY',
+ "The library '{0}' is internal and can't be exported.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of a symbol defined in a legacy library
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a library that was opted in to
+ // null safety exports another library, and the exported library is opted out
+ // of null safety.
+ //
+ // #### Example
+ //
+ // Given a library that is opted out of null safety:
+ //
+ // ```dart
+ // %uri="lib/optedOut.dart"
+ // // @dart = 2.8
+ // String s;
+ // ```
+ //
+ // The following code produces this diagnostic because it's exporting symbols
+ // from an opted-out library:
+ //
+ // ```dart
+ // export [!'optedOut.dart'!];
+ //
+ // class C {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you're able to do so, migrate the exported library so that it doesn't
+ // need to opt out:
+ //
+ // ```dart
+ // String? s;
+ // ```
+ //
+ // If you can't migrate the library, then remove the export:
+ //
+ // ```dart
+ // class C {}
+ // ```
+ //
+ // If the exported library (the one that is opted out) itself exports an
+ // opted-in library, then it's valid for your library to indirectly export the
+ // symbols from the opted-in library. You can do so by adding a hide
+ // combinator to the export directive in your library that hides all of the
+ // names declared in the opted-out library.
+ static const CompileTimeErrorCode EXPORT_LEGACY_SYMBOL = CompileTimeErrorCode(
+ 'EXPORT_LEGACY_SYMBOL',
+ "The symbol '{0}' is defined in a legacy library, and can't be re-exported from a library with null safety enabled.",
+ correction: "Try removing the export or migrating the legacy library.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the uri pointing to a non-library declaration
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an export directive references a
+ // part rather than a library.
+ //
+ // #### 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
+ // a part, and only libraries can be exported:
+ //
+ // ```dart
+ // library lib;
+ //
+ // export [!'part.dart'!];
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Either remove the export directive, or change the URI to be the URI of the
+ // library containing the part.
+ static const CompileTimeErrorCode EXPORT_OF_NON_LIBRARY =
+ CompileTimeErrorCode(
+ 'EXPORT_OF_NON_LIBRARY',
+ "The exported library '{0}' can't have a part-of directive.",
+ correction: "Try exporting the library that the part is a part of.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the analyzer finds an
+ // expression, rather than a map entry, in what appears to be a map literal.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic:
+ //
+ // ```dart
+ // var map = <String, int>{'a': 0, 'b': 1, [!'c'!]};
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the expression is intended to compute either a key or a value in an
+ // entry, fix the issue by replacing the expression with the key or the value.
+ // For example:
+ //
+ // ```dart
+ // var map = <String, int>{'a': 0, 'b': 1, 'c': 2};
+ // ```
+ static const CompileTimeErrorCode EXPRESSION_IN_MAP = CompileTimeErrorCode(
+ 'EXPRESSION_IN_MAP',
+ "Expressions can't be used in a map literal.",
+ correction:
+ "Try removing the expression or converting it to be a map entry.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * 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.",
+ correction:
+ "Try specifying a different superclass, or removing the extends clause.",
+ hasPublishedDocs: true,
+ uniqueName: 'EXTENDS_DEFERRED_CLASS',
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the disallowed type
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when one of the restricted classes is
+ // used in either an `extends`, `implements`, `with`, or `on` clause. The
+ // classes `bool`, `double`, `FutureOr`, `int`, `Null`, `num`, and `String`
+ // are all restricted in this way, to allow for more efficient
+ // implementations.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because `String` is used in an
+ // `extends` clause:
+ //
+ // ```dart
+ // class A extends [!String!] {}
+ // ```
+ //
+ // The following code produces this diagnostic because `String` is used in an
+ // `implements` clause:
+ //
+ // ```dart
+ // class B implements [!String!] {}
+ // ```
+ //
+ // The following code produces this diagnostic because `String` is used in a
+ // `with` clause:
+ //
+ // ```dart
+ // class C with [!String!] {}
+ // ```
+ //
+ // The following code produces this diagnostic because `String` is used in an
+ // `on` clause:
+ //
+ // ```dart
+ // mixin M on [!String!] {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If a different type should be specified, then replace the type:
+ //
+ // ```dart
+ // class A extends Object {}
+ // ```
+ //
+ // If there isn't a different type that would be appropriate, then remove the
+ // type, and possibly the whole clause:
+ //
+ // ```dart
+ // class B {}
+ // ```
+ static const CompileTimeErrorCode EXTENDS_DISALLOWED_CLASS =
+ CompileTimeErrorCode(
+ 'SUBTYPE_OF_DISALLOWED_TYPE',
+ "Classes can't extend '{0}'.",
+ correction:
+ "Try specifying a different superclass, or removing the extends clause.",
+ hasPublishedDocs: true,
+ uniqueName: 'EXTENDS_DISALLOWED_CLASS',
+ );
+
+ /**
+ * Parameters:
+ * 0: the name in the extends clause
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an `extends` clause contains a
+ // name that is declared to be something other than a class.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `f` is declared to be a
+ // function:
+ //
+ // ```dart
+ // void f() {}
+ //
+ // class C extends [!f!] {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you want the class to extend a class other than `Object`, then replace
+ // the name in the `extends` clause with the name of that class:
+ //
+ // ```dart
+ // void f() {}
+ //
+ // class C extends B {}
+ //
+ // class B {}
+ // ```
+ //
+ // If you want the class to extend `Object`, then remove the `extends` clause:
+ //
+ // ```dart
+ // void f() {}
+ //
+ // class C {}
+ // ```
+ static const CompileTimeErrorCode EXTENDS_NON_CLASS = CompileTimeErrorCode(
+ 'EXTENDS_NON_CLASS',
+ "Classes can only extend other classes.",
+ correction:
+ "Try specifying a different superclass, or removing the extends clause.",
+ hasPublishedDocs: true,
+ isUnresolvedIdentifier: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a type alias that expands to a
+ // type parameter is used in an `extends`, `implements`, `with`, or `on`
+ // clause.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the type alias `T`,
+ // which expands to the type parameter `S`, is used in the `extends` clause of
+ // the class `C`:
+ //
+ // ```dart
+ // typedef T<S> = S;
+ //
+ // class C extends [!T!]<Object> {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Use the value of the type argument directly:
+ //
+ // ```dart
+ // typedef T<S> = S;
+ //
+ // class C extends Object {}
+ // ```
+ static const CompileTimeErrorCode
+ EXTENDS_TYPE_ALIAS_EXPANDS_TO_TYPE_PARAMETER = CompileTimeErrorCode(
+ 'SUPERTYPE_EXPANDS_TO_TYPE_PARAMETER',
+ "A type alias that expands to a type parameter can't be used as a superclass.",
+ correction:
+ "Try specifying a different superclass, or removing the extends clause.",
+ hasPublishedDocs: true,
+ uniqueName: 'EXTENDS_TYPE_ALIAS_EXPANDS_TO_TYPE_PARAMETER',
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the extension
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the name of an extension is used
+ // in an expression other than in an extension override or to qualify an
+ // access to a static member of the extension. Because classes define a type,
+ // the name of a class can be used to refer to the instance of `Type`
+ // representing the type of the class. Extensions, on the other hand, don't
+ // define a type and can't be used as a type literal.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `E` is an extension:
+ //
+ // ```dart
+ // extension E on int {
+ // static String m() => '';
+ // }
+ //
+ // var x = [!E!];
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Replace the name of the extension with a name that can be referenced, such
+ // as a static member defined on the extension:
+ //
+ // ```dart
+ // extension E on int {
+ // static String m() => '';
+ // }
+ //
+ // var x = E.m();
+ // ```
+ static const CompileTimeErrorCode EXTENSION_AS_EXPRESSION =
+ CompileTimeErrorCode(
+ 'EXTENSION_AS_EXPRESSION',
+ "Extension '{0}' can't be used as an expression.",
+ correction: "Try replacing it with a valid expression.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the extension defining the conflicting member
+ * 1: the name of the conflicting static member
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an extension declaration
+ // contains both an instance member and a static member that have the same
+ // name. The instance member and the static member can't have the same name
+ // because it's unclear which member is being referenced by an unqualified use
+ // of the name within the body of the extension.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because the name `a` is being
+ // used for two different members:
+ //
+ // ```dart
+ // extension E on Object {
+ // int get a => 0;
+ // static int [!a!]() => 0;
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Rename or remove one of the members:
+ //
+ // ```dart
+ // extension E on Object {
+ // int get a => 0;
+ // static int b() => 0;
+ // }
+ // ```
+ static const CompileTimeErrorCode EXTENSION_CONFLICTING_STATIC_AND_INSTANCE =
+ CompileTimeErrorCode(
+ 'EXTENSION_CONFLICTING_STATIC_AND_INSTANCE',
+ "Extension '{0}' can't define static member '{1}' and an instance member with the same name.",
+ correction: "Try renaming the member to a name that doesn't conflict.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an extension declaration
+ // declares a member with the same name as a member declared in the class
+ // `Object`. Such a member can never be used because the member in `Object` is
+ // always found first.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `toString` is defined
+ // by `Object`:
+ //
+ // ```dart
+ // extension E on String {
+ // String [!toString!]() => this;
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Remove the member or rename it so that the name doesn't conflict with the
+ // member in `Object`:
+ //
+ // ```dart
+ // extension E on String {
+ // String displayString() => this;
+ // }
+ // ```
+ static const CompileTimeErrorCode EXTENSION_DECLARES_MEMBER_OF_OBJECT =
+ CompileTimeErrorCode(
+ 'EXTENSION_DECLARES_MEMBER_OF_OBJECT',
+ "Extensions can't declare members with the same name as a member declared by 'Object'.",
+ correction: "Try specifying a different name for the member.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an extension override is the
+ // receiver of the invocation of a static member. Similar to static members in
+ // classes, the static members of an extension should be accessed using the
+ // name of the extension, not an extension override.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `m` is static:
+ //
+ // ```dart
+ // extension E on String {
+ // static void m() {}
+ // }
+ //
+ // void f() {
+ // E('').[!m!]();
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Replace the extension override with the name of the extension:
+ //
+ // ```dart
+ // extension E on String {
+ // static void m() {}
+ // }
+ //
+ // void f() {
+ // E.m();
+ // }
+ // ```
+ static const CompileTimeErrorCode EXTENSION_OVERRIDE_ACCESS_TO_STATIC_MEMBER =
+ CompileTimeErrorCode(
+ 'EXTENSION_OVERRIDE_ACCESS_TO_STATIC_MEMBER',
+ "An extension override can't be used to access a static member from an extension.",
+ correction: "Try using just the name of the extension.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the type of the argument
+ * 1: the extended type
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the argument to an extension
+ // override isn't assignable to the type being extended by the extension.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `3` isn't a `String`:
+ //
+ // ```dart
+ // extension E on String {
+ // void method() {}
+ // }
+ //
+ // void f() {
+ // E([!3!]).method();
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you're using the correct extension, then update the argument to have the
+ // correct type:
+ //
+ // ```dart
+ // extension E on String {
+ // void method() {}
+ // }
+ //
+ // void f() {
+ // E(3.toString()).method();
+ // }
+ // ```
+ //
+ // If there's a different extension that's valid for the type of the argument,
+ // then either replace the name of the extension or unwrap the argument so
+ // that the correct extension is found.
+ static const CompileTimeErrorCode EXTENSION_OVERRIDE_ARGUMENT_NOT_ASSIGNABLE =
+ CompileTimeErrorCode(
+ 'EXTENSION_OVERRIDE_ARGUMENT_NOT_ASSIGNABLE',
+ "The type of the argument to the extension override '{0}' isn't assignable to the extended type '{1}'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an extension override is found
+ // that isn't being used to access one of the members of the extension. The
+ // extension override syntax doesn't have any runtime semantics; it only
+ // controls which member is selected at compile time.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `E(i)` isn't an
+ // expression:
+ //
+ // ```dart
+ // extension E on int {
+ // int get a => 0;
+ // }
+ //
+ // void f(int i) {
+ // print([!E(i)!]);
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you want to invoke one of the members of the extension, then add the
+ // invocation:
+ //
+ // ```dart
+ // extension E on int {
+ // int get a => 0;
+ // }
+ //
+ // void f(int i) {
+ // print(E(i).a);
+ // }
+ // ```
+ //
+ // If you don't want to invoke a member, then unwrap the argument:
+ //
+ // ```dart
+ // extension E on int {
+ // int get a => 0;
+ // }
+ //
+ // void f(int i) {
+ // print(i);
+ // }
+ // ```
+ static const CompileTimeErrorCode EXTENSION_OVERRIDE_WITHOUT_ACCESS =
+ CompileTimeErrorCode(
+ 'EXTENSION_OVERRIDE_WITHOUT_ACCESS',
+ "An extension override can only be used to access instance members.",
+ correction: "Consider adding an access to an instance member.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an extension override is used as
+ // the receiver of a cascade expression. The value of a cascade expression
+ // `e..m` is the value of the receiver `e`, but extension overrides aren't
+ // expressions and don't have a value.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `E(3)` isn't an
+ // expression:
+ //
+ // ```dart
+ // extension E on int {
+ // void m() {}
+ // }
+ // f() {
+ // [!E!](3)..m();
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Use `.` rather than `..`:
+ //
+ // ```dart
+ // extension E on int {
+ // void m() {}
+ // }
+ // f() {
+ // E(3).m();
+ // }
+ // ```
+ //
+ // If there are multiple cascaded accesses, you'll need to duplicate the
+ // extension override for each one.
+ static const CompileTimeErrorCode EXTENSION_OVERRIDE_WITH_CASCADE =
+ CompileTimeErrorCode(
+ 'EXTENSION_OVERRIDE_WITH_CASCADE',
+ "Extension overrides have no value so they can't be used as the receiver of a cascade expression.",
+ correction: "Try using '.' instead of '..'.",
+ hasPublishedDocs: true,
+ );
+
+ static const CompileTimeErrorCode EXTERNAL_FIELD_CONSTRUCTOR_INITIALIZER =
+ CompileTimeErrorCode(
+ 'EXTERNAL_FIELD_CONSTRUCTOR_INITIALIZER',
+ "External fields cannot have initializers.",
+ correction:
+ "Try removing the field initializer or the 'external' keyword from the field declaration.",
+ );
+
+ static const CompileTimeErrorCode EXTERNAL_FIELD_INITIALIZER =
+ CompileTimeErrorCode(
+ 'EXTERNAL_FIELD_INITIALIZER',
+ "External fields cannot have initializers.",
+ correction: "Try removing the initializer or the 'external' keyword.",
+ );
+
+ static const CompileTimeErrorCode EXTERNAL_VARIABLE_INITIALIZER =
+ CompileTimeErrorCode(
+ 'EXTERNAL_VARIABLE_INITIALIZER',
+ "External variables cannot have initializers.",
+ correction: "Try removing the initializer or the 'external' keyword.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the maximum number of positional arguments
+ * 1: the actual number of positional arguments given
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a method or function invocation
+ // has more positional arguments than the method or function allows.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `f` defines 2
+ // parameters but is invoked with 3 arguments:
+ //
+ // ```dart
+ // void f(int a, int b) {}
+ // void g() {
+ // f(1, 2, [!3!]);
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Remove the arguments that don't correspond to parameters:
+ //
+ // ```dart
+ // void f(int a, int b) {}
+ // void g() {
+ // f(1, 2);
+ // }
+ // ```
+ static const CompileTimeErrorCode EXTRA_POSITIONAL_ARGUMENTS =
+ CompileTimeErrorCode(
+ 'EXTRA_POSITIONAL_ARGUMENTS',
+ "Too many positional arguments: {0} expected, but {1} found.",
+ correction: "Try removing the extra arguments.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the maximum number of positional arguments
+ * 1: the actual number of positional arguments given
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a method or function invocation
+ // has more positional arguments than the method or function allows, but the
+ // method or function defines named parameters.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `f` defines 2
+ // positional parameters but has a named parameter that could be used for the
+ // third argument:
+ //
+ // ```dart
+ // %language=2.9
+ // void f(int a, int b, {int c}) {}
+ // void g() {
+ // f(1, 2, [!3!]);
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If some of the arguments should be values for named parameters, then add
+ // the names before the arguments:
+ //
+ // ```dart
+ // %language=2.9
+ // void f(int a, int b, {int c}) {}
+ // void g() {
+ // f(1, 2, c: 3);
+ // }
+ // ```
+ //
+ // Otherwise, remove the arguments that don't correspond to positional
+ // parameters:
+ //
+ // ```dart
+ // %language=2.9
+ // void f(int a, int b, {int c}) {}
+ // void g() {
+ // f(1, 2);
+ // }
+ // ```
+ static const CompileTimeErrorCode EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED =
+ CompileTimeErrorCode(
+ 'EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED',
+ "Too many positional arguments: {0} expected, but {1} found.",
+ correction:
+ "Try removing the extra positional arguments, or specifying the name for named arguments.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the field being initialized multiple times
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the initializer list of a
+ // constructor initializes a field more than once. There is no value to allow
+ // both initializers because only the last value is preserved.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the field `f` is being
+ // initialized twice:
+ //
+ // ```dart
+ // class C {
+ // int f;
+ //
+ // C() : f = 0, [!f!] = 1;
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Remove one of the initializers:
+ //
+ // ```dart
+ // class C {
+ // int f;
+ //
+ // C() : f = 0;
+ // }
+ // ```
+ static const CompileTimeErrorCode FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS =
+ CompileTimeErrorCode(
+ 'FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS',
+ "The field '{0}' can't be initialized twice in the same constructor.",
+ correction: "Try removing one of the initializations.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a final field is initialized in
+ // both the declaration of the field and in an initializer in a constructor.
+ // Final fields can only be assigned once, so it can't be initialized in both
+ // places.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because `f` is :
+ //
+ // ```dart
+ // class C {
+ // final int f = 0;
+ // C() : [!f!] = 1;
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the initialization doesn't depend on any values passed to the
+ // constructor, and if all of the constructors need to initialize the field to
+ // the same value, then remove the initializer from the constructor:
+ //
+ // ```dart
+ // class C {
+ // final int f = 0;
+ // C();
+ // }
+ // ```
+ //
+ // If the initialization depends on a value passed to the constructor, or if
+ // different constructors need to initialize the field differently, then
+ // remove the initializer in the field's declaration:
+ //
+ // ```dart
+ // class C {
+ // final int f;
+ // C() : f = 1;
+ // }
+ // ```
+ static const CompileTimeErrorCode
+ FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION = CompileTimeErrorCode(
+ 'FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION',
+ "Fields can't be initialized in the constructor if they are final and were already initialized at their declaration.",
+ correction: "Try removing one of the initializations.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a field is initialized in both
+ // the parameter list and in the initializer list of a constructor.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the field `f` is
+ // initialized both by a field formal parameter and in the initializer list:
+ //
+ // ```dart
+ // class C {
+ // int f;
+ //
+ // C(this.f) : [!f!] = 0;
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the field should be initialized by the parameter, then remove the
+ // initialization in the initializer list:
+ //
+ // ```dart
+ // class C {
+ // int f;
+ //
+ // C(this.f);
+ // }
+ // ```
+ //
+ // If the field should be initialized in the initializer list and the
+ // parameter isn't needed, then remove the parameter:
+ //
+ // ```dart
+ // class C {
+ // int f;
+ //
+ // C() : f = 0;
+ // }
+ // ```
+ //
+ // If the field should be initialized in the initializer list and the
+ // parameter is needed, then make it a normal parameter:
+ //
+ // ```dart
+ // class C {
+ // int f;
+ //
+ // C(int g) : f = g * 2;
+ // }
+ // ```
+ static const CompileTimeErrorCode
+ FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER = CompileTimeErrorCode(
+ 'FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER',
+ "Fields can't be initialized in both the parameter list and the initializers.",
+ correction: "Try removing one of the initializations.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a factory constructor has a
+ // field formal parameter. Factory constructors can't assign values to fields
+ // because no instance is created; hence, there is no field to assign.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the factory constructor
+ // uses a field formal parameter:
+ //
+ // ```dart
+ // class C {
+ // int? f;
+ //
+ // factory C([!this.f!]) => throw 0;
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Replace the field formal parameter with a normal parameter:
+ //
+ // ```dart
+ // class C {
+ // int? f;
+ //
+ // factory C(int f) => throw 0;
+ // }
+ // ```
+ static const CompileTimeErrorCode FIELD_INITIALIZER_FACTORY_CONSTRUCTOR =
+ CompileTimeErrorCode(
+ 'FIELD_INITIALIZER_FACTORY_CONSTRUCTOR',
+ "Initializing formal parameters can't be used in factory constructors.",
+ correction: "Try using a normal parameter.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the type of the initializer expression
+ * 1: the name of the type of the field
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the initializer list of a
+ // constructor initializes a field to a value that isn't assignable to the
+ // field.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because `0` has the type `int`,
+ // and an `int` can't be assigned to a field of type `String`:
+ //
+ // ```dart
+ // class C {
+ // String s;
+ //
+ // C() : s = [!0!];
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the type of the field is correct, then change the value assigned to it
+ // so that the value has a valid type:
+ //
+ // ```dart
+ // class C {
+ // String s;
+ //
+ // C() : s = '0';
+ // }
+ // ```
+ //
+ // If the type of the value is correct, then change the type of the field to
+ // allow the assignment:
+ //
+ // ```dart
+ // class C {
+ // int s;
+ //
+ // C() : s = 0;
+ // }
+ // ```
+ static const CompileTimeErrorCode FIELD_INITIALIZER_NOT_ASSIGNABLE =
+ CompileTimeErrorCode(
+ 'FIELD_INITIALIZER_NOT_ASSIGNABLE',
+ "The initializer type '{0}' can't be assigned to the field type '{1}'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * 7.6.1 Generative Constructors: It is a compile-time error if an
+ * initializing formal is used by a function other than a non-redirecting
+ * generative constructor.
+ */
+ static const CompileTimeErrorCode FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR =
+ CompileTimeErrorCode(
+ 'FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR',
+ "Initializing formal parameters can only be used in constructors.",
+ correction: "Try using a normal parameter.",
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a redirecting constructor
+ // initializes a field in the object. This isn't allowed because the instance
+ // that has the field hasn't been created at the point at which it should be
+ // initialized.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the constructor
+ // `C.zero`, which redirects to the constructor `C`, has a field formal
+ // parameter that initializes the field `f`:
+ //
+ // ```dart
+ // class C {
+ // int f;
+ //
+ // C(this.f);
+ //
+ // C.zero([!this.f!]) : this(f);
+ // }
+ // ```
+ //
+ // The following code produces this diagnostic because the constructor
+ // `C.zero`, which redirects to the constructor `C`, has an initializer that
+ // initializes the field `f`:
+ //
+ // ```dart
+ // class C {
+ // int f;
+ //
+ // C(this.f);
+ //
+ // C.zero() : [!f = 0!], this(1);
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the initialization is done by a field formal parameter, then use a
+ // normal parameter:
+ //
+ // ```dart
+ // class C {
+ // int f;
+ //
+ // C(this.f);
+ //
+ // C.zero(int f) : this(f);
+ // }
+ // ```
+ //
+ // If the initialization is done in an initializer, then remove the
+ // initializer:
+ //
+ // ```dart
+ // class C {
+ // int f;
+ //
+ // C(this.f);
+ //
+ // C.zero() : this(0);
+ // }
+ // ```
+ static const CompileTimeErrorCode FIELD_INITIALIZER_REDIRECTING_CONSTRUCTOR =
+ CompileTimeErrorCode(
+ 'FIELD_INITIALIZER_REDIRECTING_CONSTRUCTOR',
+ "The redirecting constructor can't have a field initializer.",
+ correction:
+ "Try initializing the field in the constructor being redirected to.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the type of the field formal parameter
+ * 1: the name of the type of the field
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the type of a field formal
+ // parameter isn't assignable to the type of the field being initialized.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the field formal
+ // parameter has the type `String`, but the type of the field is `int`. The
+ // parameter must have a type that is a subtype of the field's type.
+ //
+ // ```dart
+ // class C {
+ // int f;
+ //
+ // C([!String this.f!]);
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the type of the field is incorrect, then change the type of the field to
+ // match the type of the parameter, and consider removing the type from the
+ // parameter:
+ //
+ // ```dart
+ // class C {
+ // String f;
+ //
+ // C(this.f);
+ // }
+ // ```
+ //
+ // If the type of the parameter is incorrect, then remove the type of the
+ // parameter:
+ //
+ // ```dart
+ // class C {
+ // int f;
+ //
+ // C(this.f);
+ // }
+ // ```
+ //
+ // If the types of both the field and the parameter are correct, then use an
+ // initializer rather than a field formal parameter to convert the parameter
+ // value into a value of the correct type:
+ //
+ // ```dart
+ // class C {
+ // int f;
+ //
+ // C(String s) : f = int.parse(s);
+ // }
+ // ```
+ static const CompileTimeErrorCode FIELD_INITIALIZING_FORMAL_NOT_ASSIGNABLE =
+ CompileTimeErrorCode(
+ 'FIELD_INITIALIZING_FORMAL_NOT_ASSIGNABLE',
+ "The parameter type '{0}' is incompatible with the field type '{1}'.",
+ correction:
+ "Try changing or removing the parameter's type, or changing the field's type.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the field in question
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a final field is initialized
+ // twice: once where it's declared and once by a constructor's parameter.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the field `f` is
+ // initialized twice:
+ //
+ // ```dart
+ // class C {
+ // final int f = 0;
+ //
+ // C(this.[!f!]);
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the field should have the same value for all instances, then remove the
+ // initialization in the parameter list:
+ //
+ // ```dart
+ // class C {
+ // final int f = 0;
+ //
+ // C();
+ // }
+ // ```
+ //
+ // If the field can have different values in different instances, then remove
+ // the initialization in the declaration:
+ //
+ // ```dart
+ // class C {
+ // final int f;
+ //
+ // C(this.f);
+ // }
+ // ```
+ static const CompileTimeErrorCode
+ FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR = CompileTimeErrorCode(
+ 'FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR',
+ "'{0}' is final and was given a value when it was declared, so it can't be set to a new value.",
+ correction: "Try removing one of the initializations.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the uninitialized final variable
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a final field or variable isn't
+ // initialized.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `x` doesn't have an
+ // initializer:
+ //
+ // ```dart
+ // final [!x!];
+ // ```
+ //
+ // #### Common fixes
+ //
+ // For variables and static fields, you can add an initializer:
+ //
+ // ```dart
+ // final x = 0;
+ // ```
+ //
+ // For instance fields, you can add an initializer as shown in the previous
+ // example, or you can initialize the field in every constructor. You can
+ // initialize the field by using a field formal parameter:
+ //
+ // ```dart
+ // class C {
+ // final int x;
+ // C(this.x);
+ // }
+ // ```
+ //
+ // You can also initialize the field by using an initializer in the
+ // constructor:
+ //
+ // ```dart
+ // class C {
+ // final int x;
+ // C(int y) : x = y * 2;
+ // }
+ // ```
+ static const CompileTimeErrorCode FINAL_NOT_INITIALIZED =
+ CompileTimeErrorCode(
+ 'FINAL_NOT_INITIALIZED',
+ "The final variable '{0}' must be initialized.",
+ correction: "Try initializing the variable.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the uninitialized final variable
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a class defines one or more
+ // final instance fields without initializers and has at least one constructor
+ // that doesn't initialize those fields. All final instance fields must be
+ // initialized when the instance is created, either by the field's initializer
+ // or by the constructor.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic:
+ //
+ // ```dart
+ // class C {
+ // final String value;
+ //
+ // [!C!]();
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the value should be passed in to the constructor directly, then use a
+ // field formal parameter to initialize the field `value`:
+ //
+ // ```dart
+ // class C {
+ // final String value;
+ //
+ // C(this.value);
+ // }
+ // ```
+ //
+ // If the value should be computed indirectly from a value provided by the
+ // caller, then add a parameter and include an initializer:
+ //
+ // ```dart
+ // class C {
+ // final String value;
+ //
+ // C(Object o) : value = o.toString();
+ // }
+ // ```
+ //
+ // If the value of the field doesn't depend on values that can be passed to
+ // the constructor, then add an initializer for the field as part of the field
+ // declaration:
+ //
+ // ```dart
+ // class C {
+ // final String value = '';
+ //
+ // C();
+ // }
+ // ```
+ //
+ // If the value of the field doesn't depend on values that can be passed to
+ // the constructor but different constructors need to initialize it to
+ // different values, then add an initializer for the field in the initializer
+ // list:
+ //
+ // ```dart
+ // class C {
+ // final String value;
+ //
+ // C() : value = '';
+ //
+ // C.named() : value = 'c';
+ // }
+ // ```
+ //
+ // However, if the value is the same for all instances, then consider using a
+ // static field instead of an instance field:
+ //
+ // ```dart
+ // class C {
+ // static const String value = '';
+ //
+ // C();
+ // }
+ // ```
+ static const CompileTimeErrorCode FINAL_NOT_INITIALIZED_CONSTRUCTOR_1 =
+ CompileTimeErrorCode(
+ 'FINAL_NOT_INITIALIZED_CONSTRUCTOR',
+ "All final variables must be initialized, but '{0}' isn't.",
+ correction: "Try adding an initializer for the field.",
+ hasPublishedDocs: true,
+ uniqueName: 'FINAL_NOT_INITIALIZED_CONSTRUCTOR_1',
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the uninitialized final variable
+ * 1: the name of the uninitialized final variable
+ */
+ static const CompileTimeErrorCode FINAL_NOT_INITIALIZED_CONSTRUCTOR_2 =
+ CompileTimeErrorCode(
+ 'FINAL_NOT_INITIALIZED_CONSTRUCTOR',
+ "All final variables must be initialized, but '{0}' and '{1}' aren't.",
+ correction: "Try adding initializers for the fields.",
+ hasPublishedDocs: true,
+ uniqueName: 'FINAL_NOT_INITIALIZED_CONSTRUCTOR_2',
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the uninitialized final variable
+ * 1: the name of the uninitialized final variable
+ * 2: the number of additional not initialized variables that aren't listed
+ */
+ static const CompileTimeErrorCode FINAL_NOT_INITIALIZED_CONSTRUCTOR_3_PLUS =
+ CompileTimeErrorCode(
+ 'FINAL_NOT_INITIALIZED_CONSTRUCTOR',
+ "All final variables must be initialized, but '{0}', '{1}', and {2} others aren't.",
+ correction: "Try adding initializers for the fields.",
+ hasPublishedDocs: true,
+ uniqueName: 'FINAL_NOT_INITIALIZED_CONSTRUCTOR_3_PLUS',
+ );
+
+ /**
+ * 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 type argument that can be assigned to '{2}'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the type of the iterable expression.
+ * 1: the sequence type -- Iterable for `for` or Stream for `await for`.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the expression following `in` in
+ // a for-in loop has a type that isn't a subclass of `Iterable`.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `m` is a `Map`, and
+ // `Map` isn't a subclass of `Iterable`:
+ //
+ // ```dart
+ // void f(Map<String, String> m) {
+ // for (String s in [!m!]) {
+ // print(s);
+ // }
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Replace the expression with one that produces an iterable value:
+ //
+ // ```dart
+ // void f(Map<String, String> m) {
+ // for (String s in m.values) {
+ // print(s);
+ // }
+ // }
+ // ```
+ static const CompileTimeErrorCode FOR_IN_OF_INVALID_TYPE =
+ CompileTimeErrorCode(
+ 'FOR_IN_OF_INVALID_TYPE',
+ "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 a 'const'.",
+ correction:
+ "Try removing the 'const' modifier from the variable, or use a different variable.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * It is a compile-time error if a generic function type is used as a bound
+ * for a formal type parameter of a class or a function.
+ */
+ static const CompileTimeErrorCode GENERIC_FUNCTION_TYPE_CANNOT_BE_BOUND =
+ CompileTimeErrorCode(
+ 'GENERIC_FUNCTION_TYPE_CANNOT_BE_BOUND',
+ "Generic function types can't be used as type parameter bounds",
+ correction:
+ "Try making the free variable in the function type part of the larger declaration signature",
+ );
+
+ /**
+ * It is a compile-time error if a generic function type is used as an actual
+ * type argument.
+ */
+ static const CompileTimeErrorCode
+ GENERIC_FUNCTION_TYPE_CANNOT_BE_TYPE_ARGUMENT = CompileTimeErrorCode(
+ 'GENERIC_FUNCTION_TYPE_CANNOT_BE_TYPE_ARGUMENT',
+ "A generic function type can't be a type argument.",
+ correction:
+ "Try removing type parameters from the generic function type, or using 'dynamic' as the type argument here.",
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an instance method is being torn
+ // off from a receiver whose type is `dynamic`, and the tear-off includes type
+ // arguments. Because the analyzer can't know how many type parameters the
+ // method has, or whether it has any type parameters, there's no way it can
+ // validate that the type arguments are correct. As a result, the type
+ // arguments aren't allowed.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the type of `p` is
+ // `dynamic` and the tear-off of `m` has type arguments:
+ //
+ // ```dart
+ // void f(dynamic list) {
+ // [!list.fold!]<int>;
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you can use a more specific type than `dynamic`, then change the type of
+ // the receiver:
+ //
+ // ```dart
+ // void f(List<Object> list) {
+ // list.fold<int>;
+ // }
+ // ```
+ //
+ // If you can't use a more specific type, then remove the type arguments:
+ //
+ // ```dart
+ // void f(dynamic list) {
+ // list.cast;
+ // }
+ // ```
+ static const CompileTimeErrorCode
+ GENERIC_METHOD_TYPE_INSTANTIATION_ON_DYNAMIC = CompileTimeErrorCode(
+ 'GENERIC_METHOD_TYPE_INSTANTIATION_ON_DYNAMIC',
+ "A method tear-off on a receiver whose type is 'dynamic' can't have type arguments.",
+ correction:
+ "Specify the type of the receiver, or remove the type arguments from the method tear-off.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the getter
+ * 1: the type of the getter
+ * 2: the type of the setter
+ * 3: the name of the setter
+ */
+ static const CompileTimeErrorCode GETTER_NOT_ASSIGNABLE_SETTER_TYPES =
+ CompileTimeErrorCode(
+ 'GETTER_NOT_ASSIGNABLE_SETTER_TYPES',
+ "The return type of getter '{0}' is '{1}' which isn't assignable to the type '{2}' of its setter '{3}'.",
+ correction: "Try changing the types so that they are compatible.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the getter
+ * 1: the type of the getter
+ * 2: the type of the setter
+ * 3: the name of the setter
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the return type of a getter
+ // isn't a subtype of the type of the parameter of a setter with the same
+ // name.
+ //
+ // The subtype relationship is a requirement whether the getter and setter are
+ // in the same class or whether one of them is in a superclass of the other.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the return type of the
+ // getter `x` is `num`, the parameter type of the setter `x` is `int`, and
+ // `num` isn't a subtype of `int`:
+ //
+ // ```dart
+ // class C {
+ // num get [!x!] => 0;
+ //
+ // set x(int y) {}
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the type of the getter is correct, then change the type of the setter:
+ //
+ // ```dart
+ // class C {
+ // num get x => 0;
+ //
+ // set x(num y) {}
+ // }
+ // ```
+ //
+ // If the type of the setter is correct, then change the type of the getter:
+ //
+ // ```dart
+ // class C {
+ // int get x => 0;
+ //
+ // set x(int y) {}
+ // }
+ // ```
+ static const CompileTimeErrorCode GETTER_NOT_SUBTYPE_SETTER_TYPES =
+ CompileTimeErrorCode(
+ 'GETTER_NOT_SUBTYPE_SETTER_TYPES',
+ "The return type of getter '{0}' is '{1}' which isn't a subtype of the type '{2}' of its setter '{3}'.",
+ correction: "Try changing the types so that they are compatible.",
+ hasPublishedDocs: true,
+ );
+
+ static const CompileTimeErrorCode IF_ELEMENT_CONDITION_FROM_DEFERRED_LIBRARY =
+ CompileTimeErrorCode(
+ 'IF_ELEMENT_CONDITION_FROM_DEFERRED_LIBRARY',
+ "Constant values from a deferred library can't be used as values in an if condition inside a const collection literal.",
+ correction: "Try making the deferred import non-deferred.",
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the body of a function has the
+ // `async*` modifier even though the return type of the function isn't either
+ // `Stream` or a supertype of `Stream`.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the body of the
+ // function `f` has the 'async*' modifier even though the return type `int`
+ // isn't a supertype of `Stream`:
+ //
+ // ```dart
+ // [!int!] f() async* {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the function should be asynchronous, then change the return type to be
+ // either `Stream` or a supertype of `Stream`:
+ //
+ // ```dart
+ // Stream<int> f() async* {}
+ // ```
+ //
+ // If the function should be synchronous, then remove the `async*` modifier:
+ //
+ // ```dart
+ // int f() => 0;
+ // ```
+ static const CompileTimeErrorCode ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE =
+ CompileTimeErrorCode(
+ 'ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE',
+ "Functions marked 'async*' must have a return type that is a supertype of 'Stream<T>' for some type 'T'.",
+ correction:
+ "Try fixing the return type of the function, or removing the modifier 'async*' from the function body.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the body of a function has the
+ // `async` modifier even though the return type of the function isn't
+ // assignable to `Future`.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the body of the
+ // function `f` has the `async` modifier even though the return type isn't
+ // assignable to `Future`:
+ //
+ // ```dart
+ // [!int!] f() async {
+ // return 0;
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the function should be asynchronous, then change the return type to be
+ // assignable to `Future`:
+ //
+ // ```dart
+ // Future<int> f() async {
+ // return 0;
+ // }
+ // ```
+ //
+ // If the function should be synchronous, then remove the `async` modifier:
+ //
+ // ```dart
+ // int f() => 0;
+ // ```
+ static const CompileTimeErrorCode ILLEGAL_ASYNC_RETURN_TYPE =
+ CompileTimeErrorCode(
+ 'ILLEGAL_ASYNC_RETURN_TYPE',
+ "Functions marked 'async' must have a return type assignable to 'Future'.",
+ correction:
+ "Try fixing the return type of the function, or removing the modifier 'async' from the function body.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the body of a function has the
+ // `sync*` modifier even though the return type of the function isn't either
+ // `Iterable` or a supertype of `Iterable`.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the body of the
+ // function `f` has the 'sync*' modifier even though the return type `int`
+ // isn't a supertype of `Iterable`:
+ //
+ // ```dart
+ // [!int!] f() sync* {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the function should return an iterable, then change the return type to
+ // be either `Iterable` or a supertype of `Iterable`:
+ //
+ // ```dart
+ // Iterable<int> f() sync* {}
+ // ```
+ //
+ // If the function should return a single value, then remove the `sync*`
+ // modifier:
+ //
+ // ```dart
+ // int f() => 0;
+ // ```
+ static const CompileTimeErrorCode ILLEGAL_SYNC_GENERATOR_RETURN_TYPE =
+ CompileTimeErrorCode(
+ 'ILLEGAL_SYNC_GENERATOR_RETURN_TYPE',
+ "Functions marked 'sync*' must have a return type that is a supertype of 'Iterable<T>' for some type 'T'.",
+ correction:
+ "Try fixing the return type of the function, or removing the modifier 'sync*' from the function body.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ static const CompileTimeErrorCode IMPLEMENTS_DEFERRED_CLASS =
+ CompileTimeErrorCode(
+ 'SUBTYPE_OF_DEFERRED_CLASS',
+ "Classes and mixins can't implement deferred classes.",
+ correction:
+ "Try specifying a different interface, removing the class from the list, or changing the import to not be deferred.",
+ hasPublishedDocs: true,
+ uniqueName: 'IMPLEMENTS_DEFERRED_CLASS',
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the disallowed type
+ */
+ static const CompileTimeErrorCode IMPLEMENTS_DISALLOWED_CLASS =
+ CompileTimeErrorCode(
+ 'SUBTYPE_OF_DISALLOWED_TYPE',
+ "Classes and mixins can't implement '{0}'.",
+ correction:
+ "Try specifying a different interface, or remove the class from the list.",
+ hasPublishedDocs: true,
+ uniqueName: 'IMPLEMENTS_DISALLOWED_CLASS',
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the interface that was not found
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a name used in the `implements`
+ // clause of a class or mixin declaration is defined to be something other
+ // than a class or mixin.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `x` is a variable
+ // rather than a class or mixin:
+ //
+ // ```dart
+ // var x;
+ // class C implements [!x!] {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the name is the name of an existing class or mixin that's already being
+ // imported, then add a prefix to the import so that the local definition of
+ // the name doesn't shadow the imported name.
+ //
+ // If the name is the name of an existing class or mixin that isn't being
+ // imported, then add an import, with a prefix, for the library in which it’s
+ // declared.
+ //
+ // Otherwise, either replace the name in the `implements` clause with the name
+ // of an existing class or mixin, or remove the name from the `implements`
+ // clause.
+ static const CompileTimeErrorCode IMPLEMENTS_NON_CLASS = CompileTimeErrorCode(
+ 'IMPLEMENTS_NON_CLASS',
+ "Classes and mixins can only implement other classes and mixins.",
+ correction:
+ "Try specifying a class or mixin, or remove the name from the list.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the interface that is implemented more than once
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a single class is specified more
+ // than once in an `implements` clause.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `A` is in the list
+ // twice:
+ //
+ // ```dart
+ // class A {}
+ // class B implements A, [!A!] {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Remove all except one occurrence of the class name:
+ //
+ // ```dart
+ // class A {}
+ // class B implements A {}
+ // ```
+ static const CompileTimeErrorCode IMPLEMENTS_REPEATED = CompileTimeErrorCode(
+ 'IMPLEMENTS_REPEATED',
+ "'{0}' can only be implemented once.",
+ correction: "Try removing all but one occurrence of the class name.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the class that appears in both "extends" and "implements"
+ * clauses
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when one class is listed in both the
+ // `extends` and `implements` clauses of another class.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the class `A` is used
+ // in both the `extends` and `implements` clauses for the class `B`:
+ //
+ // ```dart
+ // class A {}
+ //
+ // class B extends A implements [!A!] {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you want to inherit the implementation from the class, then remove the
+ // class from the `implements` clause:
+ //
+ // ```dart
+ // class A {}
+ //
+ // class B extends A {}
+ // ```
+ //
+ // If you don't want to inherit the implementation from the class, then remove
+ // the `extends` clause:
+ //
+ // ```dart
+ // class A {}
+ //
+ // class B implements A {}
+ // ```
+ static const CompileTimeErrorCode IMPLEMENTS_SUPER_CLASS =
+ CompileTimeErrorCode(
+ 'IMPLEMENTS_SUPER_CLASS',
+ "'{0}' can't be used in both the 'extends' and 'implements' clauses.",
+ correction: "Try removing one of the occurrences.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ static const CompileTimeErrorCode
+ IMPLEMENTS_TYPE_ALIAS_EXPANDS_TO_TYPE_PARAMETER = CompileTimeErrorCode(
+ 'SUPERTYPE_EXPANDS_TO_TYPE_PARAMETER',
+ "A type alias that expands to a type parameter can't be implemented.",
+ correction: "Try specifying a class or mixin, or removing the list.",
+ hasPublishedDocs: true,
+ uniqueName: 'IMPLEMENTS_TYPE_ALIAS_EXPANDS_TO_TYPE_PARAMETER',
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the instance member
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when it finds a reference to an
+ // instance member in a constructor's initializer list.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `defaultX` is an
+ // instance member:
+ //
+ // ```dart
+ // class C {
+ // int x;
+ //
+ // C() : x = [!defaultX!];
+ //
+ // int get defaultX => 0;
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the member can be made static, then do so:
+ //
+ // ```dart
+ // class C {
+ // int x;
+ //
+ // C() : x = defaultX;
+ //
+ // static int get defaultX => 0;
+ // }
+ // ```
+ //
+ // If not, then replace the reference in the initializer with a different
+ // expression that doesn't use an instance member:
+ //
+ // ```dart
+ // class C {
+ // int x;
+ //
+ // C() : x = 0;
+ //
+ // int get defaultX => 0;
+ // }
+ // ```
+ static const CompileTimeErrorCode IMPLICIT_THIS_REFERENCE_IN_INITIALIZER =
+ CompileTimeErrorCode(
+ 'IMPLICIT_THIS_REFERENCE_IN_INITIALIZER',
+ "The instance member '{0}' can't be accessed in an initializer.",
+ correction:
+ "Try replacing the reference to the instance member with a different expression",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the uri pointing to a library
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when it finds an import whose `dart:`
+ // URI references an internal library.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because `_interceptors` is an
+ // internal library:
+ //
+ // ```dart
+ // import [!'dart:_interceptors'!];
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Remove the import directive.
+ static const CompileTimeErrorCode IMPORT_INTERNAL_LIBRARY =
+ CompileTimeErrorCode(
+ 'IMPORT_INTERNAL_LIBRARY',
+ "The library '{0}' is internal and can't be imported.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * 14.1 Imports: It is a compile-time error if the specified URI of an
+ * immediate import does not refer to a library declaration.
+ *
+ * Parameters:
+ * 0: the uri pointing to a non-library declaration
+ */
+ static const CompileTimeErrorCode IMPORT_OF_NON_LIBRARY =
+ CompileTimeErrorCode(
+ 'IMPORT_OF_NON_LIBRARY',
+ "The imported library '{0}' can't have a part-of directive.",
+ correction: "Try importing the library that the part is a part of.",
+ );
+
+ /**
+ * 13.9 Switch: It is a compile-time error if values of the expressions
+ * <i>e<sub>k</sub></i> are not instances of the same class <i>C</i>, for all
+ * <i>1 <= k <= n</i>.
+ *
+ * Parameters:
+ * 0: the expression source code that is the unexpected type
+ * 1: the name of the expected type
+ */
+ static const CompileTimeErrorCode INCONSISTENT_CASE_EXPRESSION_TYPES =
+ CompileTimeErrorCode(
+ 'INCONSISTENT_CASE_EXPRESSION_TYPES',
+ "Case expressions must have the same types, '{0}' isn't a '{1}'.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the instance member with inconsistent inheritance.
+ * 1: the list of all inherited signatures for this member.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a class inherits two or more
+ // conflicting signatures for a member and doesn't provide an implementation
+ // that satisfies all the inherited signatures.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because `C` is inheriting the
+ // declaration of `m` from `A`, and that implementation isn't consistent with
+ // the signature of `m` that's inherited from `B`:
+ //
+ // ```dart
+ // %language=2.9
+ // class A {
+ // void m({int a}) {}
+ // }
+ //
+ // class B {
+ // void m({int b}) {}
+ // }
+ //
+ // class [!C!] extends A implements B {
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Add an implementation of the method that satisfies all the inherited
+ // signatures:
+ //
+ // ```dart
+ // %language=2.9
+ // class A {
+ // void m({int a}) {}
+ // }
+ //
+ // class B {
+ // void m({int b}) {}
+ // }
+ //
+ // class C extends A implements B {
+ // void m({int a, int b}) {}
+ // }
+ // ```
+ static const CompileTimeErrorCode INCONSISTENT_INHERITANCE =
+ CompileTimeErrorCode(
+ 'INCONSISTENT_INHERITANCE',
+ "Superinterfaces don't have a valid override for '{0}': {1}.",
+ correction:
+ "Try adding an explicit override that is consistent with all of the inherited members.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * 11.1.1 Inheritance and Overriding. Let `I` be the implicit interface of a
+ * class `C` declared in library `L`. `I` inherits all members of
+ * `inherited(I, L)` and `I` overrides `m'` if `m' ∈ overrides(I, L)`. It is
+ * a compile-time error if `m` is a method and `m'` is a getter, or if `m`
+ * is a getter and `m'` is a method.
+ *
+ * Parameters:
+ * 0: the name of the the instance member with inconsistent inheritance.
+ * 1: the name of the superinterface that declares the name as a getter.
+ * 2: the name of the superinterface that declares the name as a method.
+ */
+ static const CompileTimeErrorCode INCONSISTENT_INHERITANCE_GETTER_AND_METHOD =
+ CompileTimeErrorCode(
+ 'INCONSISTENT_INHERITANCE_GETTER_AND_METHOD',
+ "'{0}' is inherited as a getter (from '{1}') and also a method (from '{2}').",
+ correction:
+ "Try adjusting the supertypes of this class to remove the inconsistency.",
+ );
+
+ /**
+ * It is a compile-time error if a part file has a different language version
+ * override than its library.
+ *
+ * https://github.com/dart-lang/language/blob/master/accepted/
+ * future-releases/language-versioning/feature-specification.md
+ * #individual-library-language-version-override
+ */
+ static const CompileTimeErrorCode INCONSISTENT_LANGUAGE_VERSION_OVERRIDE =
+ CompileTimeErrorCode(
+ 'INCONSISTENT_LANGUAGE_VERSION_OVERRIDE',
+ "Parts must have exactly the same language version override as the library.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the initializing formal that is not an instance variable in
+ * the immediately enclosing class
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a constructor initializes a
+ // field that isn't declared in the class containing the constructor.
+ // Constructors can't initialize fields that aren't declared and fields that
+ // are inherited from superclasses.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because the initializer is
+ // initializing `x`, but `x` isn't a field in the class:
+ //
+ // ```dart
+ // %language=2.9
+ // class C {
+ // int y;
+ //
+ // C() : [!x = 0!];
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If a different field should be initialized, then change the name to the
+ // name of the field:
+ //
+ // ```dart
+ // %language=2.9
+ // class C {
+ // int y;
+ //
+ // C() : y = 0;
+ // }
+ // ```
+ //
+ // If the field must be declared, then add a declaration:
+ //
+ // ```dart
+ // %language=2.9
+ // class C {
+ // int x;
+ // int y;
+ //
+ // C() : x = 0;
+ // }
+ // ```
+ static const CompileTimeErrorCode INITIALIZER_FOR_NON_EXISTENT_FIELD =
+ CompileTimeErrorCode(
+ 'INITIALIZER_FOR_NON_EXISTENT_FIELD',
+ "'{0}' isn't a field in the enclosing class.",
+ correction:
+ "Try correcting the name to match an existing field, or defining a field named '{0}'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the initializing formal that is a static variable in the
+ * immediately enclosing class
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a static field is initialized in
+ // a constructor using either a field formal parameter or an assignment in the
+ // initializer list.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the static field `a` is
+ // being initialized by the field formal parameter `this.a`:
+ //
+ // ```dart
+ // class C {
+ // static int? a;
+ // C([!this.a!]);
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the field should be an instance field, then remove the keyword `static`:
+ //
+ // ```dart
+ // class C {
+ // int? a;
+ // C(this.a);
+ // }
+ // ```
+ //
+ // If you intended to initialize an instance field and typed the wrong name,
+ // then correct the name of the field being initialized:
+ //
+ // ```dart
+ // class C {
+ // static int? a;
+ // int? b;
+ // C(this.b);
+ // }
+ // ```
+ //
+ // If you really want to initialize the static field, then move the
+ // initialization into the constructor body:
+ //
+ // ```dart
+ // class C {
+ // static int? a;
+ // C(int? c) {
+ // a = c;
+ // }
+ // }
+ // ```
+ static const CompileTimeErrorCode INITIALIZER_FOR_STATIC_FIELD =
+ CompileTimeErrorCode(
+ 'INITIALIZER_FOR_STATIC_FIELD',
+ "'{0}' is a static field in the enclosing class. Fields initialized in a constructor can't be static.",
+ correction: "Try removing the initialization.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the initializing formal that is not an instance variable in
+ * the immediately enclosing class
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a field formal parameter is
+ // found in a constructor in a class that doesn't declare the field being
+ // initialized. Constructors can't initialize fields that aren't declared and
+ // fields that are inherited from superclasses.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because the field `x` isn't
+ // defined:
+ //
+ // ```dart
+ // %language=2.9
+ // class C {
+ // int y;
+ //
+ // C([!this.x!]);
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the field name was wrong, then change it to the name of an existing
+ // field:
+ //
+ // ```dart
+ // %language=2.9
+ // class C {
+ // int y;
+ //
+ // C(this.y);
+ // }
+ // ```
+ //
+ // If the field name is correct but hasn't yet been defined, then declare the
+ // field:
+ //
+ // ```dart
+ // %language=2.9
+ // class C {
+ // int x;
+ // int y;
+ //
+ // C(this.x);
+ // }
+ // ```
+ //
+ // If the parameter is needed but shouldn't initialize a field, then convert
+ // it to a normal parameter and use it:
+ //
+ // ```dart
+ // %language=2.9
+ // class C {
+ // int y;
+ //
+ // C(int x) : y = x * 2;
+ // }
+ // ```
+ //
+ // If the parameter isn't needed, then remove it:
+ //
+ // ```dart
+ // %language=2.9
+ // class C {
+ // int y;
+ //
+ // C();
+ // }
+ // ```
+ static const CompileTimeErrorCode INITIALIZING_FORMAL_FOR_NON_EXISTENT_FIELD =
+ CompileTimeErrorCode(
+ 'INITIALIZING_FORMAL_FOR_NON_EXISTENT_FIELD',
+ "'{0}' isn't a field in the enclosing class.",
+ correction:
+ "Try correcting the name to match an existing field, or defining a field named '{0}'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the static member
+ * 1: the kind of the static member (field, getter, setter, or method)
+ * 2: the name of the defining class
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an access operator is used to
+ // access a static member through an instance of the class.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `zero` is a static
+ // field, but it’s being accessed as if it were an instance field:
+ //
+ // ```dart
+ // void f(C c) {
+ // c.[!zero!];
+ // }
+ //
+ // class C {
+ // static int zero = 0;
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Use the class to access the static member:
+ //
+ // ```dart
+ // void f(C c) {
+ // C.zero;
+ // }
+ //
+ // class C {
+ // static int zero = 0;
+ // }
+ // ```
+ static const CompileTimeErrorCode INSTANCE_ACCESS_TO_STATIC_MEMBER =
+ CompileTimeErrorCode(
+ 'INSTANCE_ACCESS_TO_STATIC_MEMBER',
+ "Static {1} '{0}' can't be accessed through an instance.",
+ correction: "Try using the class '{2}' to access the {1}.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a factory constructor contains
+ // an unqualified reference to an instance member. In a generative
+ // constructor, the instance of the class is created and initialized before
+ // the body of the constructor is executed, so the instance can be bound to
+ // `this` and accessed just like it would be in an instance method. But, in a
+ // factory constructor, the instance isn't created before executing the body,
+ // so `this` can't be used to reference it.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `x` isn't in scope in
+ // the factory constructor:
+ //
+ // ```dart
+ // class C {
+ // int x;
+ // factory C() {
+ // return C._([!x!]);
+ // }
+ // C._(this.x);
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Rewrite the code so that it doesn't reference the instance member:
+ //
+ // ```dart
+ // class C {
+ // int x;
+ // factory C() {
+ // return C._(0);
+ // }
+ // C._(this.x);
+ // }
+ // ```
+ static const CompileTimeErrorCode INSTANCE_MEMBER_ACCESS_FROM_FACTORY =
+ CompileTimeErrorCode(
+ 'INSTANCE_MEMBER_ACCESS_FROM_FACTORY',
+ "Instance members can't be accessed from a factory constructor.",
+ correction: "Try removing the reference to the instance member.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a static method contains an
+ // unqualified reference to an instance member.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because the instance field `x`
+ // is being referenced in a static method:
+ //
+ // ```dart
+ // %language=2.9
+ // class C {
+ // int x;
+ //
+ // static int m() {
+ // return [!x!];
+ // }
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the method must reference the instance member, then it can't be static,
+ // so remove the keyword:
+ //
+ // ```dart
+ // %language=2.9
+ // class C {
+ // int x;
+ //
+ // int m() {
+ // return x;
+ // }
+ // }
+ // ```
+ //
+ // If the method can't be made an instance method, then add a parameter so
+ // that an instance of the class can be passed in:
+ //
+ // ```dart
+ // %language=2.9
+ // class C {
+ // int x;
+ //
+ // static int m(C c) {
+ // return c.x;
+ // }
+ // }
+ // ```
+ static const CompileTimeErrorCode INSTANCE_MEMBER_ACCESS_FROM_STATIC =
+ CompileTimeErrorCode(
+ 'INSTANCE_MEMBER_ACCESS_FROM_STATIC',
+ "Instance members can't be accessed from a static method.",
+ correction:
+ "Try removing the reference to the instance member, or removing the keyword 'static' from the method.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when it finds a constructor
+ // invocation and the constructor is declared in an abstract class. Even
+ // though you can't create an instance of an abstract class, abstract classes
+ // can declare constructors that can be invoked by subclasses.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `C` is an abstract
+ // class:
+ //
+ // ```dart
+ // abstract class C {}
+ //
+ // var c = new [!C!]();
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If there's a concrete subclass of the abstract class that can be used, then
+ // create an instance of the concrete subclass.
+ static const CompileTimeErrorCode INSTANTIATE_ABSTRACT_CLASS =
+ CompileTimeErrorCode(
+ 'INSTANTIATE_ABSTRACT_CLASS',
+ "Abstract classes can't be instantiated.",
+ correction: "Try creating an instance of a concrete subtype.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * 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.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a constructor invocation is
+ // found where the type being instantiated is a type alias for one of the type
+ // parameters of the type alias. This isn’t allowed because the value of the
+ // type parameter is a type rather than a class.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because it creates an instance
+ // of `A`, even though `A` is a type alias that is defined to be equivalent to
+ // a type parameter:
+ //
+ // ```dart
+ // typedef A<T> = T;
+ //
+ // void f() {
+ // const [!A!]<int>();
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Use either a class name or a type alias defined to be a class, rather than
+ // a type alias defined to be a type parameter:
+ //
+ // ```dart
+ // typedef A<T> = C<T>;
+ //
+ // void f() {
+ // const A<int>();
+ // }
+ //
+ // class C<T> {
+ // const C();
+ // }
+ // ```
+ static const CompileTimeErrorCode
+ INSTANTIATE_TYPE_ALIAS_EXPANDS_TO_TYPE_PARAMETER = CompileTimeErrorCode(
+ 'INSTANTIATE_TYPE_ALIAS_EXPANDS_TO_TYPE_PARAMETER',
+ "Type aliases that expand to a type parameter can't be instantiated.",
+ correction: "Try replacing it with a class.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the lexeme of the integer
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an integer literal is being
+ // implicitly converted to a double, but can't be represented as a 64-bit
+ // double without overflow or loss of precision. Integer literals are
+ // implicitly converted to a double if the context requires the type `double`.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the integer value
+ // `9223372036854775807` can't be represented exactly as a double:
+ //
+ // ```dart
+ // double x = [!9223372036854775807!];
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you need to use the exact value, then use the class `BigInt` to
+ // represent the value:
+ //
+ // ```dart
+ // var x = BigInt.parse('9223372036854775807');
+ // ```
+ //
+ // If you need to use a double, then change the value to one that can be
+ // represented exactly:
+ //
+ // ```dart
+ // double x = 9223372036854775808;
+ // ```
+ static const CompileTimeErrorCode INTEGER_LITERAL_IMPRECISE_AS_DOUBLE =
+ CompileTimeErrorCode(
+ 'INTEGER_LITERAL_IMPRECISE_AS_DOUBLE',
+ "The integer literal is being used as a double, but can't be represented as a 64-bit double without overflow or loss of precision: '{0}'.",
+ correction:
+ "Try using the class 'BigInt', or switch to the closest valid double: '{1}'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an integer literal has a value
+ // that is too large (positive) or too small (negative) to be represented in a
+ // 64-bit word.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the value can't be
+ // represented in 64 bits:
+ //
+ // ```dart
+ // var x = [!9223372036854775810!];
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you need to represent the current value, then wrap it in an instance of
+ // the class `BigInt`:
+ //
+ // ```dart
+ // var x = BigInt.parse('9223372036854775810');
+ // ```
+ static const CompileTimeErrorCode INTEGER_LITERAL_OUT_OF_RANGE =
+ CompileTimeErrorCode(
+ 'INTEGER_LITERAL_OUT_OF_RANGE',
+ "The integer literal {0} can't be represented in 64 bits.",
+ correction:
+ "Try using the 'BigInt' class if you need an integer larger than 9,223,372,036,854,775,807 or less than -9,223,372,036,854,775,808.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an annotation is found that is
+ // using something that is neither a variable marked as `const` or the
+ // invocation of a `const` constructor.
+ //
+ // Getters can't be used as annotations.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the variable `v` isn't
+ // a `const` variable:
+ //
+ // ```dart
+ // var v = 0;
+ //
+ // [!@v!]
+ // void f() {
+ // }
+ // ```
+ //
+ // The following code produces this diagnostic because `f` isn't a variable:
+ //
+ // ```dart
+ // [!@f!]
+ // void f() {
+ // }
+ // ```
+ //
+ // The following code produces this diagnostic because `f` isn't a
+ // constructor:
+ //
+ // ```dart
+ // [!@f()!]
+ // void f() {
+ // }
+ // ```
+ //
+ // The following code produces this diagnostic because `g` is a getter:
+ //
+ // ```dart
+ // [!@g!]
+ // int get g => 0;
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the annotation is referencing a variable that isn't a `const`
+ // constructor, add the keyword `const` to the variable's declaration:
+ //
+ // ```dart
+ // const v = 0;
+ //
+ // @v
+ // void f() {
+ // }
+ // ```
+ //
+ // If the annotation isn't referencing a variable, then remove it:
+ //
+ // ```dart
+ // int v = 0;
+ //
+ // void f() {
+ // }
+ // ```
+ static const CompileTimeErrorCode INVALID_ANNOTATION = CompileTimeErrorCode(
+ 'INVALID_ANNOTATION',
+ "Annotation must be either a const variable reference or const constructor invocation.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a constant defined in a library
+ // that is imported as a deferred library is referenced in the argument list
+ // of an annotation. Annotations 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 constant `pi` is
+ // being referenced in the argument list of an annotation, even though the
+ // library that defines it is being imported as a deferred library:
+ //
+ // ```dart
+ // import 'dart:math' deferred as math;
+ //
+ // class C {
+ // const C(double d);
+ // }
+ //
+ // @C([!math.pi!])
+ // void f () {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you need to reference the imported constant, then remove the `deferred`
+ // keyword:
+ //
+ // ```dart
+ // import 'dart:math' as math;
+ //
+ // class C {
+ // const C(double d);
+ // }
+ //
+ // @C(math.pi)
+ // void f () {}
+ // ```
+ //
+ // If the import is required to be deferred and there's another constant that
+ // is appropriate, then use that constant in place of the constant from the
+ // deferred library.
+ static const CompileTimeErrorCode
+ INVALID_ANNOTATION_CONSTANT_VALUE_FROM_DEFERRED_LIBRARY =
+ CompileTimeErrorCode(
+ 'INVALID_ANNOTATION_CONSTANT_VALUE_FROM_DEFERRED_LIBRARY',
+ "Constant values from a deferred library can't be used in annotations.",
+ correction:
+ "Try moving the constant from the deferred library, or removing 'deferred' from the import.",
+ );
+
+ /**
+ * 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',
+ "Constant values from a deferred library can't be used as annotations.",
+ correction:
+ "Try removing the annotation, or changing the import to not be deferred.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the right hand side type
+ * 1: the name of the left hand side type
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the static type of an expression
+ // that is assigned to a variable isn't assignable to the type of the
+ // variable.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because the type of the
+ // initializer (`int`) isn't assignable to the type of the variable
+ // (`String`):
+ //
+ // ```dart
+ // int i = 0;
+ // String s = [!i!];
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the value being assigned is always assignable at runtime, even though
+ // the static types don't reflect that, then add an explicit cast.
+ //
+ // Otherwise, change the value being assigned so that it has the expected
+ // type. In the previous example, this might look like:
+ //
+ // ```dart
+ // int i = 0;
+ // String s = i.toString();
+ // ```
+ //
+ // If you can’t change the value, then change the type of the variable to be
+ // compatible with the type of the value being assigned:
+ //
+ // ```dart
+ // int i = 0;
+ // int s = i;
+ // ```
+ static const CompileTimeErrorCode INVALID_ASSIGNMENT = CompileTimeErrorCode(
+ 'INVALID_ASSIGNMENT',
+ "A value of type '{0}' can't be assigned to a variable of type '{1}'.",
+ correction:
+ "Try changing the type of the variable, or casting the right-hand type to '{1}'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the type of the function
+ * 1: the expected function type
+ */
+ static const CompileTimeErrorCode INVALID_CAST_FUNCTION =
+ CompileTimeErrorCode(
+ 'INVALID_CAST_FUNCTION',
+ "The function '{0}' has type '{1}' that isn't of expected type '{2}'. This means its parameter or return type doesn't match what is expected.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the type of the torn-off function expression
+ * 1: the expected function type
+ */
+ static const CompileTimeErrorCode INVALID_CAST_FUNCTION_EXPR =
+ CompileTimeErrorCode(
+ 'INVALID_CAST_FUNCTION_EXPR',
+ "The function expression type '{0}' isn't of type '{1}'. This means its parameter or return type doesn't match what is expected. Consider changing parameter type(s) or the returned type(s).",
+ );
+
+ /**
+ * Parameters:
+ * 0: the type of the literal
+ * 1: the expected type
+ */
+ static const CompileTimeErrorCode INVALID_CAST_LITERAL = CompileTimeErrorCode(
+ 'INVALID_CAST_LITERAL',
+ "The literal '{0}' with type '{1}' isn't of expected type '{2}'.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the type of the list literal
+ * 1: the expected type
+ */
+ static const CompileTimeErrorCode INVALID_CAST_LITERAL_LIST =
+ CompileTimeErrorCode(
+ 'INVALID_CAST_LITERAL_LIST',
+ "The list literal type '{0}' isn't of expected type '{1}'. The list's type can be changed with an explicit generic type argument or by changing the element types.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the type of the map literal
+ * 1: the expected type
+ */
+ static const CompileTimeErrorCode INVALID_CAST_LITERAL_MAP =
+ CompileTimeErrorCode(
+ 'INVALID_CAST_LITERAL_MAP',
+ "The map literal type '{0}' isn't of expected type '{1}'. The maps's type can be changed with an explicit generic type arguments or by changing the key and value types.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the type of the set literal
+ * 1: the expected type
+ */
+ static const CompileTimeErrorCode INVALID_CAST_LITERAL_SET =
+ CompileTimeErrorCode(
+ 'INVALID_CAST_LITERAL_SET',
+ "The set literal type '{0}' isn't of expected type '{1}'. The set's type can be changed with an explicit generic type argument or by changing the element types.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the type of the torn-off method
+ * 1: the expected function type
+ */
+ static const CompileTimeErrorCode INVALID_CAST_METHOD = CompileTimeErrorCode(
+ 'INVALID_CAST_METHOD',
+ "The method tear-off '{0}' has type '{1}' that isn't of expected type '{2}'. This means its parameter or return type doesn't match what is expected.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the type of the instantiated object
+ * 1: the expected type
+ */
+ static const CompileTimeErrorCode INVALID_CAST_NEW_EXPR =
+ CompileTimeErrorCode(
+ 'INVALID_CAST_NEW_EXPR',
+ "The constructor returns type '{0}' that isn't of expected type '{1}'.",
+ );
+
+ /**
+ * TODO(brianwilkerson) Remove this when we have decided on how to report
+ * errors in compile-time constants. Until then, this acts as a placeholder
+ * for more informative errors.
+ *
+ * See TODOs in ConstantVisitor
+ */
+ static const CompileTimeErrorCode INVALID_CONSTANT = CompileTimeErrorCode(
+ 'INVALID_CONSTANT',
+ "Invalid constant value.",
+ );
+
+ /**
+ * 7.6 Constructors: It is a compile-time error if the name of a constructor
+ * is not a constructor name.
+ */
+ static const CompileTimeErrorCode INVALID_CONSTRUCTOR_NAME =
+ CompileTimeErrorCode(
+ 'INVALID_CONSTRUCTOR_NAME',
+ "Invalid constructor name.",
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an extension override doesn't
+ // have exactly one argument. The argument is the expression used to compute
+ // the value of `this` within the extension method, so there must be one
+ // argument.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because there are no arguments:
+ //
+ // ```dart
+ // extension E on String {
+ // String join(String other) => '$this $other';
+ // }
+ //
+ // void f() {
+ // E[!()!].join('b');
+ // }
+ // ```
+ //
+ // And, the following code produces this diagnostic because there's more than
+ // one argument:
+ //
+ // ```dart
+ // extension E on String {
+ // String join(String other) => '$this $other';
+ // }
+ //
+ // void f() {
+ // E[!('a', 'b')!].join('c');
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Provide one argument for the extension override:
+ //
+ // ```dart
+ // extension E on String {
+ // String join(String other) => '$this $other';
+ // }
+ //
+ // void f() {
+ // E('a').join('b');
+ // }
+ // ```
+ static const CompileTimeErrorCode INVALID_EXTENSION_ARGUMENT_COUNT =
+ CompileTimeErrorCode(
+ 'INVALID_EXTENSION_ARGUMENT_COUNT',
+ "Extension overrides must have exactly one argument: the value of 'this' in the extension method.",
+ correction: "Try specifying exactly one argument.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the name of a factory
+ // constructor isn't the same as the name of the surrounding class.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because the name of the factory
+ // constructor (`A`) isn't the same as the surrounding class (`C`):
+ //
+ // ```dart
+ // class A {}
+ //
+ // class C {
+ // factory [!A!]() => throw 0;
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the factory returns an instance of the surrounding class, then rename
+ // the factory:
+ //
+ // ```dart
+ // class A {}
+ //
+ // class C {
+ // factory C() => throw 0;
+ // }
+ // ```
+ //
+ // If the factory returns an instance of a different class, then move the
+ // factory to that class:
+ //
+ // ```dart
+ // class A {
+ // factory A() => throw 0;
+ // }
+ //
+ // class C {}
+ // ```
+ //
+ // If the factory returns an instance of a different class, but you can't
+ // modify that class or don't want to move the factory, then convert it to be
+ // a static method:
+ //
+ // ```dart
+ // class A {}
+ //
+ // class C {
+ // static A a() => throw 0;
+ // }
+ // ```
+ static const CompileTimeErrorCode INVALID_FACTORY_NAME_NOT_A_CLASS =
+ CompileTimeErrorCode(
+ 'INVALID_FACTORY_NAME_NOT_A_CLASS',
+ "The name of a factory constructor must be the same as the name of the immediately enclosing class.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the declared member that is not a valid override.
+ * 1: the name of the interface that declares the member.
+ * 2: the type of the declared member in the interface.
+ * 3. the name of the interface with the overridden member.
+ * 4. the type of the overridden member.
+ *
+ * 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',
+ "'{1}.{0}' ('{2}') isn't a valid concrete implementation of '{3}.{0}' ('{4}').",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a generic function type has a
+ // function-valued parameter that is written using the older inline function
+ // type syntax.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the parameter `f`, in
+ // the generic function type used to define `F`, uses the inline function
+ // type syntax:
+ //
+ // ```dart
+ // typedef F = int Function(int f[!(!]String s));
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Use the generic function syntax for the parameter's type:
+ //
+ // ```dart
+ // typedef F = int Function(int Function(String));
+ // ```
+ static const CompileTimeErrorCode INVALID_INLINE_FUNCTION_TYPE =
+ CompileTimeErrorCode(
+ 'INVALID_INLINE_FUNCTION_TYPE',
+ "Inline function types can't be used for parameters in a generic function type.",
+ correction:
+ "Try using a generic function type (returnType 'Function(' parameters ')').",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the invalid modifier
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the body of a constructor is
+ // prefixed by one of the following modifiers: `async`, `async*`, or `sync*`.
+ // Constructor bodies must be synchronous.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the body of the
+ // constructor for `C` is marked as being `async`:
+ //
+ // ```dart
+ // class C {
+ // C() [!async!] {}
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the constructor can be synchronous, then remove the modifier:
+ //
+ // ```dart
+ // class C {
+ // C();
+ // }
+ // ```
+ //
+ // If the constructor can't be synchronous, then use a static method to create
+ // the instance instead:
+ //
+ // ```dart
+ // class C {
+ // C();
+ // static Future<C> c() async {
+ // return C();
+ // }
+ // }
+ // ```
+ static const CompileTimeErrorCode INVALID_MODIFIER_ON_CONSTRUCTOR =
+ CompileTimeErrorCode(
+ 'INVALID_MODIFIER_ON_CONSTRUCTOR',
+ "The modifier '{0}' can't be applied to the body of a constructor.",
+ correction: "Try removing the modifier.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the invalid modifier
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the body of a setter is prefixed
+ // by one of the following modifiers: `async`, `async*`, or `sync*`. Setter
+ // bodies must be synchronous.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the body of the setter
+ // `x` is marked as being `async`:
+ //
+ // ```dart
+ // class C {
+ // set x(int i) [!async!] {}
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the setter can be synchronous, then remove the modifier:
+ //
+ // ```dart
+ // class C {
+ // set x(int i) {}
+ // }
+ // ```
+ //
+ // If the setter can't be synchronous, then use a method to set the value
+ // instead:
+ //
+ // ```dart
+ // class C {
+ // void x(int i) async {}
+ // }
+ // ```
+ static const CompileTimeErrorCode INVALID_MODIFIER_ON_SETTER =
+ CompileTimeErrorCode(
+ 'INVALID_MODIFIER_ON_SETTER',
+ "Setters can't use 'async', 'async*', or 'sync*'.",
+ correction: "Try removing the modifier.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the declared member that is not a valid override.
+ * 1: the name of the interface that declares the member.
+ * 2: the type of the declared member in the interface.
+ * 3. the name of the interface with the overridden member.
+ * 4. the type of the overridden member.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a member of a class is found
+ // that overrides a member from a supertype and the override isn't valid. An
+ // override is valid if all of these are true:
+ // * It allows all of the arguments allowed by the overridden member.
+ // * It doesn't require any arguments that aren't required by the overridden
+ // member.
+ // * The type of every parameter of the overridden member is assignable to the
+ // corresponding parameter of the override.
+ // * The return type of the override is assignable to the return type of the
+ // overridden member.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because the type of the
+ // parameter `s` (`String`) isn't assignable to the type of the parameter `i`
+ // (`int`):
+ //
+ // ```dart
+ // class A {
+ // void m(int i) {}
+ // }
+ //
+ // class B extends A {
+ // void [!m!](String s) {}
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the invalid method is intended to override the method from the
+ // superclass, then change it to conform:
+ //
+ // ```dart
+ // class A {
+ // void m(int i) {}
+ // }
+ //
+ // class B extends A {
+ // void m(int i) {}
+ // }
+ // ```
+ //
+ // If it isn't intended to override the method from the superclass, then
+ // rename it:
+ //
+ // ```dart
+ // class A {
+ // void m(int i) {}
+ // }
+ //
+ // class B extends A {
+ // void m2(String s) {}
+ // }
+ // ```
+ static const CompileTimeErrorCode INVALID_OVERRIDE = CompileTimeErrorCode(
+ 'INVALID_OVERRIDE',
+ "'{1}.{0}' ('{2}') isn't a valid override of '{3}.{0}' ('{4}').",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when `this` is used outside of an
+ // instance method or a generative constructor. The reserved word `this` is
+ // only defined in the context of an instance method or a generative
+ // constructor.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `v` is a top-level
+ // variable:
+ //
+ // ```dart
+ // C f() => [!this!];
+ //
+ // class C {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Use a variable of the appropriate type in place of `this`, declaring it if
+ // necessary:
+ //
+ // ```dart
+ // C f(C c) => c;
+ //
+ // class C {}
+ // ```
+ static const CompileTimeErrorCode INVALID_REFERENCE_TO_THIS =
+ CompileTimeErrorCode(
+ 'INVALID_REFERENCE_TO_THIS',
+ "Invalid reference to 'this' expression.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the initializer list of a
+ // constructor contains an invocation of a constructor in the superclass, but
+ // the invocation isn't the last item in the initializer list.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the invocation of the
+ // superclass' constructor isn't the last item in the initializer list:
+ //
+ // ```dart
+ // class A {
+ // A(int x);
+ // }
+ //
+ // class B extends A {
+ // B(int x) : [!super!](x), assert(x >= 0);
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Move the invocation of the superclass' constructor to the end of the
+ // initializer list:
+ //
+ // ```dart
+ // class A {
+ // A(int x);
+ // }
+ //
+ // class B extends A {
+ // B(int x) : assert(x >= 0), super(x);
+ // }
+ // ```
+ static const CompileTimeErrorCode INVALID_SUPER_INVOCATION =
+ CompileTimeErrorCode(
+ 'INVALID_SUPER_INVOCATION',
+ "The superclass call must be last in an initializer list: '{0}'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the type parameter
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a type parameter is used as a
+ // type argument in a list, map, or set literal that is prefixed by `const`.
+ // 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 list:
+ //
+ // ```dart
+ // List<T> newList<T>() => const <[!T!]>[];
+ // ```
+ //
+ // The following code produces this diagnostic because the type parameter `T`
+ // is being used as a type argument when creating a constant map:
+ //
+ // ```dart
+ // Map<String, T> newSet<T>() => const <String, [!T!]>{};
+ // ```
+ //
+ // The following code produces this diagnostic because the type parameter `T`
+ // is being used as a type argument when creating a constant set:
+ //
+ // ```dart
+ // Set<T> newSet<T>() => const <[!T!]>{};
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the type that will be used for the type parameter can be known at
+ // compile time, then remove the type parameter:
+ //
+ // ```dart
+ // List<int> newList() => const <int>[];
+ // ```
+ //
+ // If the type that will be used for the type parameter can't be known until
+ // runtime, then remove the keyword `const`:
+ //
+ // ```dart
+ // List<T> newList<T>() => <T>[];
+ // ```
+ static const CompileTimeErrorCode INVALID_TYPE_ARGUMENT_IN_CONST_LIST =
+ CompileTimeErrorCode(
+ 'INVALID_TYPE_ARGUMENT_IN_CONST_LITERAL',
+ "Constant list literals can't include a type parameter as a type argument, such as '{0}'.",
+ correction: "Try replacing the type parameter with a different type.",
+ hasPublishedDocs: true,
+ uniqueName: 'INVALID_TYPE_ARGUMENT_IN_CONST_LIST',
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the type parameter
+ */
+ static const CompileTimeErrorCode INVALID_TYPE_ARGUMENT_IN_CONST_MAP =
+ CompileTimeErrorCode(
+ 'INVALID_TYPE_ARGUMENT_IN_CONST_LITERAL',
+ "Constant map literals can't include a type parameter as a type argument, such as '{0}'.",
+ correction: "Try replacing the type parameter with a different type.",
+ hasPublishedDocs: true,
+ uniqueName: 'INVALID_TYPE_ARGUMENT_IN_CONST_MAP',
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the type parameter
+ */
+ static const CompileTimeErrorCode INVALID_TYPE_ARGUMENT_IN_CONST_SET =
+ CompileTimeErrorCode(
+ 'INVALID_TYPE_ARGUMENT_IN_CONST_LITERAL',
+ "Constant set literals can't include a type parameter as a type argument, such as '{0}'.",
+ correction: "Try replacing the type parameter with a different type.",
+ hasPublishedDocs: true,
+ uniqueName: 'INVALID_TYPE_ARGUMENT_IN_CONST_SET',
+ );
+
+ /**
+ * Parameters:
+ * 0: the URI that is invalid
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a URI in a directive doesn't
+ // conform to the syntax of a valid URI.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `'#'` isn't a valid
+ // URI:
+ //
+ // ```dart
+ // import [!'#'!];
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Replace the invalid URI with a valid URI.
+ static const CompileTimeErrorCode INVALID_URI = CompileTimeErrorCode(
+ 'INVALID_URI',
+ "Invalid URI syntax: '{0}'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * The 'covariant' keyword was found in an inappropriate location.
+ */
+ static const CompileTimeErrorCode INVALID_USE_OF_COVARIANT =
+ CompileTimeErrorCode(
+ 'INVALID_USE_OF_COVARIANT',
+ "The 'covariant' keyword can only be used for parameters in instance methods or before non-final instance fields.",
+ correction: "Try removing the 'covariant' keyword.",
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an expression whose value will
+ // always be `null` is dereferenced.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because `x` will always be
+ // `null`:
+ //
+ // ```dart
+ // int f(Null x) {
+ // return [!x!].length;
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the value is allowed to be something other than `null`, then change the
+ // type of the expression:
+ //
+ // ```dart
+ // int f(String? x) {
+ // return x!.length;
+ // }
+ // ```
+ static const CompileTimeErrorCode INVALID_USE_OF_NULL_VALUE =
+ CompileTimeErrorCode(
+ 'INVALID_USE_OF_NULL_VALUE',
+ "An expression whose value is always 'null' can't be dereferenced.",
+ correction: "Try changing the type of the expression.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the extension
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an extension override is used to
+ // invoke a function but the extension doesn't declare a `call` method.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because the extension `E`
+ // doesn't define a `call` method:
+ //
+ // ```dart
+ // extension E on String {}
+ //
+ // void f() {
+ // [!E('')!]();
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the extension is intended to define a `call` method, then declare it:
+ //
+ // ```dart
+ // extension E on String {
+ // int call() => 0;
+ // }
+ //
+ // void f() {
+ // E('')();
+ // }
+ // ```
+ //
+ // If the extended type defines a `call` method, then remove the extension
+ // override.
+ //
+ // If the `call` method isn't defined, then rewrite the code so that it
+ // doesn't invoke the `call` method.
+ static const CompileTimeErrorCode INVOCATION_OF_EXTENSION_WITHOUT_CALL =
+ CompileTimeErrorCode(
+ 'INVOCATION_OF_EXTENSION_WITHOUT_CALL',
+ "The extension '{0}' doesn't define a 'call' method so the override can't be used in an invocation.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the identifier that is not a function type
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when it finds a function invocation,
+ // but the name of the function being invoked is defined to be something other
+ // than a function.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `Binary` is the name of
+ // a function type, not a function:
+ //
+ // ```dart
+ // typedef Binary = int Function(int, int);
+ //
+ // int f() {
+ // return [!Binary!](1, 2);
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Replace the name with the name of a function.
+ static const CompileTimeErrorCode INVOCATION_OF_NON_FUNCTION =
+ CompileTimeErrorCode(
+ 'INVOCATION_OF_NON_FUNCTION',
+ "'{0}' isn't a function.",
+ correction:
+ "Try correcting the name to match an existing function, or define a method or function named '{0}'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a function invocation is found,
+ // but the name being referenced isn't the name of a function, or when the
+ // expression computing the function doesn't compute a function.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `x` isn't a function:
+ //
+ // ```dart
+ // int x = 0;
+ //
+ // int f() => x;
+ //
+ // var y = [!x!]();
+ // ```
+ //
+ // The following code produces this diagnostic because `f()` doesn't return a
+ // function:
+ //
+ // ```dart
+ // int x = 0;
+ //
+ // int f() => x;
+ //
+ // var y = [!f()!]();
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you need to invoke a function, then replace the code before the argument
+ // list with the name of a function or with an expression that computes a
+ // function:
+ //
+ // ```dart
+ // int x = 0;
+ //
+ // int f() => x;
+ //
+ // var y = f();
+ // ```
+ static const CompileTimeErrorCode INVOCATION_OF_NON_FUNCTION_EXPRESSION =
+ CompileTimeErrorCode(
+ 'INVOCATION_OF_NON_FUNCTION_EXPRESSION',
+ "The expression doesn't evaluate to a function, so it can't be invoked.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the unresolvable label
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a `break` or `continue`
+ // statement references a label that is declared in a method or function
+ // containing the function in which the `break` or `continue` statement
+ // appears. The `break` and `continue` statements can't be used to transfer
+ // control outside the function that contains them.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the label `loop` is
+ // declared outside the local function `g`:
+ //
+ // ```dart
+ // void f() {
+ // loop:
+ // while (true) {
+ // void g() {
+ // break [!loop!];
+ // }
+ //
+ // g();
+ // }
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Try rewriting the code so that it isn't necessary to transfer control
+ // outside the local function, possibly by inlining the local function:
+ //
+ // ```dart
+ // void f() {
+ // loop:
+ // while (true) {
+ // break loop;
+ // }
+ // }
+ // ```
+ //
+ // If that isn't possible, then try rewriting the local function so that a
+ // value returned by the function can be used to determine whether control is
+ // transferred:
+ //
+ // ```dart
+ // void f() {
+ // loop:
+ // while (true) {
+ // bool g() {
+ // return true;
+ // }
+ //
+ // if (g()) {
+ // break loop;
+ // }
+ // }
+ // }
+ // ```
+ static const CompileTimeErrorCode LABEL_IN_OUTER_SCOPE = CompileTimeErrorCode(
+ 'LABEL_IN_OUTER_SCOPE',
+ "Can't reference label '{0}' declared in an outer method.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the unresolvable label
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when it finds a reference to a label
+ // that isn't defined in the scope of the `break` or `continue` statement that
+ // is referencing it.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the label `loop` isn't
+ // defined anywhere:
+ //
+ // ```dart
+ // void f() {
+ // for (int i = 0; i < 10; i++) {
+ // for (int j = 0; j < 10; j++) {
+ // break [!loop!];
+ // }
+ // }
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the label should be on the innermost enclosing `do`, `for`, `switch`, or
+ // `while` statement, then remove the label:
+ //
+ // ```dart
+ // void f() {
+ // for (int i = 0; i < 10; i++) {
+ // for (int j = 0; j < 10; j++) {
+ // break;
+ // }
+ // }
+ // }
+ // ```
+ //
+ // If the label should be on some other statement, then add the label:
+ //
+ // ```dart
+ // void f() {
+ // loop: for (int i = 0; i < 10; i++) {
+ // for (int j = 0; j < 10; j++) {
+ // break loop;
+ // }
+ // }
+ // }
+ // ```
+ static const CompileTimeErrorCode LABEL_UNDEFINED = CompileTimeErrorCode(
+ 'LABEL_UNDEFINED',
+ "Can't reference an undefined label '{0}'.",
+ correction:
+ "Try defining the label, or correcting the name to match an existing label.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a class that has at least one
+ // `const` constructor also has a field marked both `late` and `final`.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the class `A` has a
+ // `const` constructor and the `final` field `f` is marked as `late`:
+ //
+ // ```dart
+ // class A {
+ // [!late!] final int f;
+ //
+ // const A();
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the field doesn't need to be marked `late`, then remove the `late`
+ // modifier from the field:
+ //
+ // ```dart
+ // class A {
+ // final int f = 0;
+ //
+ // const A();
+ // }
+ // ```
+ //
+ // If the field must be marked `late`, then remove the `const` modifier from
+ // the constructors:
+ //
+ // ```dart
+ // class A {
+ // late final int f;
+ //
+ // A();
+ // }
+ // ```
+ static const CompileTimeErrorCode LATE_FINAL_FIELD_WITH_CONST_CONSTRUCTOR =
+ CompileTimeErrorCode(
+ 'LATE_FINAL_FIELD_WITH_CONST_CONSTRUCTOR',
+ "Can't have a late final field in a class with a generative const constructor.",
+ correction:
+ "Try removing the 'late' modifier, or don't declare 'const' constructors.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the analyzer can prove that a
+ // local variable marked as both `late` and `final` was already assigned a
+ // value at the point where another assignment occurs.
+ //
+ // Because `final` variables can only be assigned once, subsequent assignments
+ // are guaranteed to fail, so they're flagged.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the `final` variable
+ // `v` is assigned a value in two places:
+ //
+ // ```dart
+ // int f() {
+ // late final int v;
+ // v = 0;
+ // [!v!] += 1;
+ // return v;
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you need to be able to reassign the variable, then remove the `final`
+ // keyword:
+ //
+ // ```dart
+ // int f() {
+ // late int v;
+ // v = 0;
+ // v += 1;
+ // return v;
+ // }
+ // ```
+ //
+ // If you don't need to reassign the variable, then remove all except the
+ // first of the assignments:
+ //
+ // ```dart
+ // int f() {
+ // late final int v;
+ // v = 0;
+ // return v;
+ // }
+ // ```
+ static const CompileTimeErrorCode LATE_FINAL_LOCAL_ALREADY_ASSIGNED =
+ CompileTimeErrorCode(
+ 'LATE_FINAL_LOCAL_ALREADY_ASSIGNED',
+ "The late final local variable is already assigned.",
+ correction:
+ "Try removing the 'final' modifier, or don't reassign the value.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the actual type of the list element
+ * 1: the expected type of the list element
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the type of an element in a list
+ // literal isn't assignable to the element type of the list.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `2.5` is a double, and
+ // the list can hold only integers:
+ //
+ // ```dart
+ // List<int> x = [1, [!2.5!], 3];
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you intended to add a different object to the list, then replace the
+ // element with an expression that computes the intended object:
+ //
+ // ```dart
+ // List<int> x = [1, 2, 3];
+ // ```
+ //
+ // If the object shouldn't be in the list, then remove the element:
+ //
+ // ```dart
+ // List<int> x = [1, 3];
+ // ```
+ //
+ // If the object being computed is correct, then widen the element type of the
+ // list to allow all of the different types of objects it needs to contain:
+ //
+ // ```dart
+ // List<num> x = [1, 2.5, 3];
+ // ```
+ static const CompileTimeErrorCode LIST_ELEMENT_TYPE_NOT_ASSIGNABLE =
+ CompileTimeErrorCode(
+ 'LIST_ELEMENT_TYPE_NOT_ASSIGNABLE',
+ "The element type '{0}' can't be assigned to the list type '{1}'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the first positional parameter
+ // of a function named `main` isn't a supertype of `List<String>`.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because `List<int>` isn't a
+ // supertype of `List<String>`:
+ //
+ // ```dart
+ // void main([!List<int>!] args) {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the function is an entry point, then change the type of the first
+ // positional parameter to be a supertype of `List<String>`:
+ //
+ // ```dart
+ // void main(List<String> args) {}
+ // ```
+ //
+ // If the function isn't an entry point, then change the name of the function:
+ //
+ // ```dart
+ // void f(List<int> args) {}
+ // ```
+ static const CompileTimeErrorCode MAIN_FIRST_POSITIONAL_PARAMETER_TYPE =
+ CompileTimeErrorCode(
+ 'MAIN_FIRST_POSITIONAL_PARAMETER_TYPE',
+ "The type of the first positional parameter of the 'main' function must be a supertype of 'List<String>'.",
+ correction: "Try changing the type of the parameter.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a function named `main` has one
+ // or more required named parameters.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the function named
+ // `main` has a required named parameter (`x`):
+ //
+ // ```dart
+ // void [!main!]({required int x}) {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the function is an entry point, then remove the `required` keyword:
+ //
+ // ```dart
+ // void main({int? x}) {}
+ // ```
+ //
+ // If the function isn't an entry point, then change the name of the function:
+ //
+ // ```dart
+ // void f({required int x}) {}
+ // ```
+ static const CompileTimeErrorCode MAIN_HAS_REQUIRED_NAMED_PARAMETERS =
+ CompileTimeErrorCode(
+ 'MAIN_HAS_REQUIRED_NAMED_PARAMETERS',
+ "The function 'main' can't have any required named parameters.",
+ correction:
+ "Try using a different name for the function, or removing the 'required' modifier.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a function named `main` has more
+ // than two required positional parameters.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the function `main` has
+ // three required positional parameters:
+ //
+ // ```dart
+ // void [!main!](List<String> args, int x, int y) {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the function is an entry point and the extra parameters aren't used,
+ // then remove them:
+ //
+ // ```dart
+ // void main(List<String> args, int x) {}
+ // ```
+ //
+ // If the function is an entry point, but the extra parameters used are for
+ // when the function isn't being used as an entry point, then make the extra
+ // parameters optional:
+ //
+ // ```dart
+ // void main(List<String> args, int x, [int y = 0]) {}
+ // ```
+ //
+ // If the function isn't an entry point, then change the name of the function:
+ //
+ // ```dart
+ // void f(List<String> args, int x, int y) {}
+ // ```
+ static const CompileTimeErrorCode
+ MAIN_HAS_TOO_MANY_REQUIRED_POSITIONAL_PARAMETERS = CompileTimeErrorCode(
+ 'MAIN_HAS_TOO_MANY_REQUIRED_POSITIONAL_PARAMETERS',
+ "The function 'main' can't have more than two required positional parameters.",
+ correction:
+ "Try using a different name for the function, or removing extra parameters.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a library contains a declaration
+ // of the name `main` that isn't the declaration of a top-level function.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the name `main` is
+ // being used to declare a top-level variable:
+ //
+ // ```dart
+ // var [!main!] = 3;
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Use a different name for the declaration:
+ //
+ // ```dart
+ // var mainIndex = 3;
+ // ```
+ static const CompileTimeErrorCode MAIN_IS_NOT_FUNCTION = CompileTimeErrorCode(
+ 'MAIN_IS_NOT_FUNCTION',
+ "The declaration named 'main' must be a function.",
+ correction: "Try using a different name for this declaration.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a map entry (a key/value pair)
+ // is found in a set literal.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because the literal has a map
+ // entry even though it's a set literal:
+ //
+ // ```dart
+ // const collection = <String>{[!'a' : 'b'!]};
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you intended for the collection to be a map, then change the code so
+ // that it is a map. In the previous example, you could do this by adding
+ // another type argument:
+ //
+ // ```dart
+ // const collection = <String, String>{'a' : 'b'};
+ // ```
+ //
+ // In other cases, you might need to change the explicit type from `Set` to
+ // `Map`.
+ //
+ // If you intended for the collection to be a set, then remove the map entry,
+ // possibly by replacing the colon with a comma if both values should be
+ // included in the set:
+ //
+ // ```dart
+ // const collection = <String>{'a', 'b'};
+ // ```
+ static const CompileTimeErrorCode MAP_ENTRY_NOT_IN_MAP = CompileTimeErrorCode(
+ 'MAP_ENTRY_NOT_IN_MAP',
+ "Map entries can only be used in a map literal.",
+ correction:
+ "Try converting the collection to a map or removing the map entry.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the type of the expression being used as a key
+ * 1: the type of keys declared for the map
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a key of a key-value pair in a
+ // map literal has a type that isn't assignable to the key type of the map.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `2` is an `int`, but
+ // the keys of the map are required to be `String`s:
+ //
+ // ```dart
+ // var m = <String, String>{[!2!] : 'a'};
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the type of the map is correct, then change the key to have the correct
+ // type:
+ //
+ // ```dart
+ // var m = <String, String>{'2' : 'a'};
+ // ```
+ //
+ // If the type of the key is correct, then change the key type of the map:
+ //
+ // ```dart
+ // var m = <int, String>{2 : 'a'};
+ // ```
+ static const CompileTimeErrorCode MAP_KEY_TYPE_NOT_ASSIGNABLE =
+ CompileTimeErrorCode(
+ 'MAP_KEY_TYPE_NOT_ASSIGNABLE',
+ "The element type '{0}' can't be assigned to the map key type '{1}'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the type of the expression being used as a value
+ * 1: the type of values declared for the map
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a value of a key-value pair in a
+ // map literal has a type that isn't assignable to the the value type of the
+ // map.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `2` is an `int`, but/
+ // the values of the map are required to be `String`s:
+ //
+ // ```dart
+ // var m = <String, String>{'a' : [!2!]};
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the type of the map is correct, then change the value to have the
+ // correct type:
+ //
+ // ```dart
+ // var m = <String, String>{'a' : '2'};
+ // ```
+ //
+ // If the type of the value is correct, then change the value type of the map:
+ //
+ // ```dart
+ // var m = <String, int>{'a' : 2};
+ // ```
+ static const CompileTimeErrorCode MAP_VALUE_TYPE_NOT_ASSIGNABLE =
+ CompileTimeErrorCode(
+ 'MAP_VALUE_TYPE_NOT_ASSIGNABLE',
+ "The element type '{0}' can't be assigned to the map value type '{1}'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * 12.1 Constants: A constant expression is ... a constant list literal.
+ */
+ static const CompileTimeErrorCode MISSING_CONST_IN_LIST_LITERAL =
+ CompileTimeErrorCode(
+ 'MISSING_CONST_IN_LIST_LITERAL',
+ "List literals must be prefixed with 'const' when used as a constant expression.",
+ correction: "Try adding the keyword 'const' before the literal.",
+ );
+
+ /**
+ * 12.1 Constants: A constant expression is ... a constant map literal.
+ */
+ static const CompileTimeErrorCode MISSING_CONST_IN_MAP_LITERAL =
+ CompileTimeErrorCode(
+ 'MISSING_CONST_IN_MAP_LITERAL',
+ "Map literals must be prefixed with 'const' when used as a constant expression.",
+ correction: "Try adding the keyword 'const' before the literal.",
+ );
+
+ /**
+ * 12.1 Constants: A constant expression is ... a constant set literal.
+ */
+ static const CompileTimeErrorCode MISSING_CONST_IN_SET_LITERAL =
+ CompileTimeErrorCode(
+ 'MISSING_CONST_IN_SET_LITERAL',
+ "Set literals must be prefixed with 'const' when used as a constant 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: "Re-install the Dart or Flutter SDK.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an optional parameter, whether
+ // positional or named, has a [potentially non-nullable][] type and doesn't
+ // specify a default value. Optional parameters that have no explicit default
+ // value have an implicit default value of `null`. If the type of the
+ // parameter doesn't allow the parameter to have a value of `null`, then the
+ // implicit default value isn't valid.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because `x` can't be `null`,
+ // and no non-`null` default value is specified:
+ //
+ // ```dart
+ // void f([int [!x!]]) {}
+ // ```
+ //
+ // As does this:
+ //
+ // ```dart
+ // void g({int [!x!]}) {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you want to use `null` to indicate that no value was provided, then you
+ // need to make the type nullable:
+ //
+ // ```dart
+ // void f([int? x]) {}
+ // void g({int? x}) {}
+ // ```
+ //
+ // If the parameter can't be null, then either provide a default value:
+ //
+ // ```dart
+ // void f([int x = 1]) {}
+ // void g({int x = 2}) {}
+ // ```
+ //
+ // or make the parameter a required parameter:
+ //
+ // ```dart
+ // void f(int x) {}
+ // void g({required int x}) {}
+ // ```
+ static const CompileTimeErrorCode MISSING_DEFAULT_VALUE_FOR_PARAMETER =
+ CompileTimeErrorCode(
+ 'MISSING_DEFAULT_VALUE_FOR_PARAMETER',
+ "The parameter '{0}' can't have a value of 'null' because of its type, but the implicit default value is 'null'.",
+ correction:
+ "Try adding either an explicit non-'null' default value or the 'required' modifier.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the parameter
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an invocation of a function is
+ // missing a required named parameter.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the invocation of `f`
+ // doesn't include a value for the required named parameter `end`:
+ //
+ // ```dart
+ // void f(int start, {required int end}) {}
+ // void g() {
+ // [!f!](3);
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Add a named argument corresponding to the missing required parameter:
+ //
+ // ```dart
+ // void f(int start, {required int end}) {}
+ // void g() {
+ // f(3, end: 5);
+ // }
+ // ```
+ static const CompileTimeErrorCode MISSING_REQUIRED_ARGUMENT =
+ CompileTimeErrorCode(
+ 'MISSING_REQUIRED_ARGUMENT',
+ "The named parameter '{0}' is required, but there's no corresponding argument.",
+ correction: "Try adding the required argument.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Technically this is [IMPLEMENTS_SUPER_CLASS].
+ * See https://github.com/dart-lang/sdk/issues/25765#issuecomment-307422593
+ *
+ * Parameters:
+ * 0: the name of the class that appears in both "extends" and "with" clauses
+ */
+ static const CompileTimeErrorCode MIXINS_SUPER_CLASS = CompileTimeErrorCode(
+ 'MIXINS_SUPER_CLASS',
+ "'{0}' can't be used in both 'extends' and 'with' clauses.",
+ correction: "Try removing one of the occurrences.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the super-invoked member
+ * 1: the display name of the type of the super-invoked member in the mixin
+ * 2: the display name of the type of the concrete member in the class
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a mixin that invokes a method
+ // using `super` is used in a class where the concrete implementation of that
+ // method has a different signature than the signature defined for that method
+ // by the mixin's `on` type. The reason this is an error is because the
+ // invocation in the mixin might invoke the method in a way that's
+ // incompatible with the method that will actually be executed.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the class `C` uses the
+ // mixin `M`, the mixin `M` invokes `foo` using `super`, and the abstract
+ // version of `foo` declared in `I` (the mixin's `on` type) doesn't have the
+ // same signature as the concrete version of `foo` declared in `A`:
+ //
+ // ```dart
+ // class I {
+ // void foo([int? p]) {}
+ // }
+ //
+ // class A {
+ // void foo(int p) {}
+ // }
+ //
+ // abstract class B extends A implements I {
+ // @override
+ // void foo([int? p]);
+ // }
+ //
+ // mixin M on I {
+ // void bar() {
+ // super.foo(42);
+ // }
+ // }
+ //
+ // abstract class C extends B with [!M!] {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the class doesn't need to use the mixin, then remove it from the `with`
+ // clause:
+ //
+ // ```dart
+ // class I {
+ // void foo([int? p]) {}
+ // }
+ //
+ // class A {
+ // void foo(int? p) {}
+ // }
+ //
+ // abstract class B extends A implements I {
+ // @override
+ // void foo([int? p]);
+ // }
+ //
+ // mixin M on I {
+ // void bar() {
+ // super.foo(42);
+ // }
+ // }
+ //
+ // abstract class C extends B {}
+ // ```
+ //
+ // If the class needs to use the mixin, then ensure that there's a concrete
+ // implementation of the method that conforms to the signature expected by the
+ // mixin:
+ //
+ // ```dart
+ // class I {
+ // void foo([int? p]) {}
+ // }
+ //
+ // class A {
+ // void foo(int? p) {}
+ // }
+ //
+ // abstract class B extends A implements I {
+ // @override
+ // void foo([int? p]) {
+ // super.foo(p);
+ // }
+ // }
+ //
+ // mixin M on I {
+ // void bar() {
+ // super.foo(42);
+ // }
+ // }
+ //
+ // abstract class C extends B with M {}
+ // ```
+ static const CompileTimeErrorCode
+ MIXIN_APPLICATION_CONCRETE_SUPER_INVOKED_MEMBER_TYPE =
+ CompileTimeErrorCode(
+ 'MIXIN_APPLICATION_CONCRETE_SUPER_INVOKED_MEMBER_TYPE',
+ "The super-invoked member '{0}' has the type '{1}', and the concrete member in the class has the type '{2}'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the display name of the mixin
+ * 1: the display name of the superclass
+ * 2: the display name of the type that is not implemented
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a mixin that has a superclass
+ // constraint is used in a [mixin application][] with a superclass that
+ // doesn't implement the required constraint.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the mixin `M` requires
+ // that the class to which it's applied be a subclass of `A`, but `Object`
+ // isn't a subclass of `A`:
+ //
+ // ```dart
+ // class A {}
+ //
+ // mixin M on A {}
+ //
+ // class X = Object with [!M!];
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you need to use the mixin, then change the superclass to be either the
+ // same as or a subclass of the superclass constraint:
+ //
+ // ```dart
+ // class A {}
+ //
+ // mixin M on A {}
+ //
+ // class X = A with M;
+ // ```
+ static const CompileTimeErrorCode
+ MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE = CompileTimeErrorCode(
+ 'MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE',
+ "'{0}' can't be mixed onto '{1}' because '{1}' doesn't implement '{2}'.",
+ correction: "Try extending the class '{0}'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * 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',
+ "The class doesn't have a concrete implementation of the super-invoked member '{0}'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the mixin that is invalid
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a class is used as a mixin and
+ // the mixed-in class defines a constructor.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the class `A`, which
+ // defines a constructor, is being used as a mixin:
+ //
+ // ```dart
+ // class A {
+ // A();
+ // }
+ //
+ // class B with [!A!] {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If it's possible to convert the class to a mixin, then do so:
+ //
+ // ```dart
+ // mixin A {
+ // }
+ //
+ // class B with A {}
+ // ```
+ //
+ // If the class can't be a mixin and it's possible to remove the constructor,
+ // then do so:
+ //
+ // ```dart
+ // class A {
+ // }
+ //
+ // class B with A {}
+ // ```
+ //
+ // If the class can't be a mixin and you can't remove the constructor, then
+ // try extending or implementing the class rather than mixing it in:
+ //
+ // ```dart
+ // class A {
+ // A();
+ // }
+ //
+ // class B extends A {}
+ // ```
+ static const CompileTimeErrorCode MIXIN_CLASS_DECLARES_CONSTRUCTOR =
+ CompileTimeErrorCode(
+ 'MIXIN_CLASS_DECLARES_CONSTRUCTOR',
+ "The class '{0}' can't be used as a mixin because it declares a constructor.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * The <i>mixinMember</i> production allows the same instance or static
+ * members that a class would allow, but no constructors (for now).
+ */
+ static const CompileTimeErrorCode MIXIN_DECLARES_CONSTRUCTOR =
+ CompileTimeErrorCode(
+ 'MIXIN_DECLARES_CONSTRUCTOR',
+ "Mixins can't declare constructors.",
+ );
+
+ /**
+ * No parameters.
+ */
+ static const CompileTimeErrorCode MIXIN_DEFERRED_CLASS = CompileTimeErrorCode(
+ 'SUBTYPE_OF_DEFERRED_CLASS',
+ "Classes can't mixin deferred classes.",
+ correction: "Try changing the import to not be deferred.",
+ hasPublishedDocs: true,
+ uniqueName: 'MIXIN_DEFERRED_CLASS',
+ );
+
+ static const CompileTimeErrorCode
+ MIXIN_INFERENCE_INCONSISTENT_MATCHING_CLASSES = CompileTimeErrorCode(
+ 'MIXIN_INFERENCE_INCONSISTENT_MATCHING_CLASSES',
+ "Type parameters couldn't be inferred for the mixin '{0}' because the base class implements the mixin's supertype constraint '{1}' in multiple conflicting ways",
+ );
+
+ static const CompileTimeErrorCode MIXIN_INFERENCE_NO_MATCHING_CLASS =
+ CompileTimeErrorCode(
+ 'MIXIN_INFERENCE_NO_MATCHING_CLASS',
+ "Type parameters couldn't be inferred for the mixin '{0}' because the base class doesn't implement the mixin's supertype constraint '{1}'",
+ );
+
+ static const CompileTimeErrorCode MIXIN_INFERENCE_NO_POSSIBLE_SUBSTITUTION =
+ CompileTimeErrorCode(
+ 'MIXIN_INFERENCE_NO_POSSIBLE_SUBSTITUTION',
+ "Type parameters couldn't be inferred for the mixin '{0}' because no type parameter substitution could be found matching the mixin's supertype constraints",
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the mixin that is invalid
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a class that extends a class
+ // other than `Object` is used as a mixin.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the class `B`, which
+ // extends `A`, is being used as a mixin by `C`:
+ //
+ // ```dart
+ // class A {}
+ //
+ // class B extends A {}
+ //
+ // class C with [!B!] {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the class being used as a mixin can be changed to extend `Object`, then
+ // change it:
+ //
+ // ```dart
+ // class A {}
+ //
+ // class B {}
+ //
+ // class C with B {}
+ // ```
+ //
+ // If the class being used as a mixin can't be changed and the class that's
+ // using it extends `Object`, then extend the class being used as a mixin:
+ //
+ // ```dart
+ // class A {}
+ //
+ // class B extends A {}
+ //
+ // class C extends B {}
+ // ```
+ //
+ // If the class doesn't extend `Object` or if you want to be able to mix in
+ // the behavior from `B` in other places, then create a real mixin:
+ //
+ // ```dart
+ // class A {}
+ //
+ // mixin M on A {}
+ //
+ // class B extends A with M {}
+ //
+ // class C extends A with M {}
+ // ```
+ static const CompileTimeErrorCode MIXIN_INHERITS_FROM_NOT_OBJECT =
+ CompileTimeErrorCode(
+ 'MIXIN_INHERITS_FROM_NOT_OBJECT',
+ "The class '{0}' can't be used as a mixin because it extends a class other than 'Object'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * 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.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the disallowed type
+ */
+ static const CompileTimeErrorCode MIXIN_OF_DISALLOWED_CLASS =
+ CompileTimeErrorCode(
+ 'SUBTYPE_OF_DISALLOWED_TYPE',
+ "Classes can't mixin '{0}'.",
+ correction:
+ "Try specifying a different class or mixin, or remove the class or mixin from the list.",
+ hasPublishedDocs: true,
+ uniqueName: 'MIXIN_OF_DISALLOWED_CLASS',
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a name in a `with` clause is
+ // defined to be something other than a mixin or a class.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `F` is defined to be a
+ // function type:
+ //
+ // ```dart
+ // typedef F = int Function(String);
+ //
+ // class C with [!F!] {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Remove the invalid name from the list, possibly replacing it with the name
+ // of the intended mixin or class:
+ //
+ // ```dart
+ // typedef F = int Function(String);
+ //
+ // class C {}
+ // ```
+ static const CompileTimeErrorCode MIXIN_OF_NON_CLASS = CompileTimeErrorCode(
+ 'MIXIN_OF_NON_CLASS',
+ "Classes can only mix in mixins and classes.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ static const CompileTimeErrorCode
+ MIXIN_OF_TYPE_ALIAS_EXPANDS_TO_TYPE_PARAMETER = CompileTimeErrorCode(
+ 'SUPERTYPE_EXPANDS_TO_TYPE_PARAMETER',
+ "A type alias that expands to a type parameter can't be mixed in.",
+ hasPublishedDocs: true,
+ uniqueName: 'MIXIN_OF_TYPE_ALIAS_EXPANDS_TO_TYPE_PARAMETER',
+ );
+
+ /**
+ * No parameters.
+ */
+ static const CompileTimeErrorCode
+ MIXIN_ON_TYPE_ALIAS_EXPANDS_TO_TYPE_PARAMETER = CompileTimeErrorCode(
+ 'SUPERTYPE_EXPANDS_TO_TYPE_PARAMETER',
+ "A type alias that expands to a type parameter can't be used as a superclass constraint.",
+ hasPublishedDocs: true,
+ uniqueName: 'MIXIN_ON_TYPE_ALIAS_EXPANDS_TO_TYPE_PARAMETER',
+ );
+
+ /**
+ * No parameters.
+ */
+ static const CompileTimeErrorCode
+ MIXIN_SUPER_CLASS_CONSTRAINT_DEFERRED_CLASS = CompileTimeErrorCode(
+ 'MIXIN_SUPER_CLASS_CONSTRAINT_DEFERRED_CLASS',
+ "Deferred classes can't be used as super-class constraints.",
+ correction: "Try changing the import to not be deferred.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the disallowed type
+ */
+ static const CompileTimeErrorCode
+ MIXIN_SUPER_CLASS_CONSTRAINT_DISALLOWED_CLASS = CompileTimeErrorCode(
+ 'SUBTYPE_OF_DISALLOWED_TYPE',
+ "''{0}' can't be used as a superclass constraint.",
+ correction:
+ "Try specifying a different super-class constraint, or remove the 'on' clause.",
+ hasPublishedDocs: true,
+ uniqueName: 'MIXIN_SUPER_CLASS_CONSTRAINT_DISALLOWED_CLASS',
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a type following the `on`
+ // keyword in a mixin declaration is neither a class nor a mixin.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `F` is neither a class
+ // nor a mixin:
+ //
+ // ```dart
+ // typedef F = void Function();
+ //
+ // mixin M on [!F!] {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the type was intended to be a class but was mistyped, then replace the
+ // name.
+ //
+ // Otherwise, remove the type from the `on` clause.
+ static const CompileTimeErrorCode MIXIN_SUPER_CLASS_CONSTRAINT_NON_INTERFACE =
+ CompileTimeErrorCode(
+ 'MIXIN_SUPER_CLASS_CONSTRAINT_NON_INTERFACE',
+ "Only classes and mixins can be used as superclass constraints.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * 9.1 Mixin Application: It is a compile-time error if <i>S</i> does not
+ * denote a class available in the immediately enclosing scope.
+ */
+ static const CompileTimeErrorCode MIXIN_WITH_NON_CLASS_SUPERCLASS =
+ CompileTimeErrorCode(
+ 'MIXIN_WITH_NON_CLASS_SUPERCLASS',
+ "Mixin can only be applied to class.",
+ );
+
+ /**
+ * 7.6.1 Generative Constructors: A generative constructor may be redirecting,
+ * in which case its only action is to invoke another generative constructor.
+ */
+ static const CompileTimeErrorCode
+ MULTIPLE_REDIRECTING_CONSTRUCTOR_INVOCATIONS = CompileTimeErrorCode(
+ 'MULTIPLE_REDIRECTING_CONSTRUCTOR_INVOCATIONS',
+ "Constructors can have at most one 'this' redirection.",
+ correction: "Try removing all but one of the redirections.",
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the initializer list of a
+ // constructor contains more than one invocation of a constructor from the
+ // superclass. The initializer list is required to have exactly one such call,
+ // which can either be explicit or implicit.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the initializer list
+ // for `B`’s constructor invokes both the constructor `one` and the
+ // constructor `two` from the superclass `A`:
+ //
+ // ```dart
+ // class A {
+ // int? x;
+ // String? s;
+ // A.one(this.x);
+ // A.two(this.s);
+ // }
+ //
+ // class B extends A {
+ // B() : super.one(0), [!super.two('')!];
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If one of the super constructors will initialize the instance fully, then
+ // remove the other:
+ //
+ // ```dart
+ // class A {
+ // int? x;
+ // String? s;
+ // A.one(this.x);
+ // A.two(this.s);
+ // }
+ //
+ // class B extends A {
+ // B() : super.one(0);
+ // }
+ // ```
+ //
+ // If the initialization achieved by one of the super constructors can be
+ // performed in the body of the constructor, then remove its super invocation
+ // and perform the initialization in the body:
+ //
+ // ```dart
+ // class A {
+ // int? x;
+ // String? s;
+ // A.one(this.x);
+ // A.two(this.s);
+ // }
+ //
+ // class B extends A {
+ // B() : super.one(0) {
+ // s = '';
+ // }
+ // }
+ // ```
+ //
+ // If the initialization can only be performed in a constructor in the
+ // superclass, then either add a new constructor or modify one of the existing
+ // constructors so there's a constructor that allows all the required
+ // initialization to occur in a single call:
+ //
+ // ```dart
+ // class A {
+ // int? x;
+ // String? s;
+ // A.one(this.x);
+ // A.two(this.s);
+ // A.three(this.x, this.s);
+ // }
+ //
+ // class B extends A {
+ // B() : super.three(0, '');
+ // }
+ // ```
+ static const CompileTimeErrorCode MULTIPLE_SUPER_INITIALIZERS =
+ CompileTimeErrorCode(
+ 'MULTIPLE_SUPER_INITIALIZERS',
+ "A constructor can have at most one 'super' initializer.",
+ correction: "Try removing all but one of the 'super' initializers.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the non-type element
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an instance creation using
+ // either `new` or `const` specifies a name that isn't defined as a class.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because `f` is a function
+ // rather than a class:
+ //
+ // ```dart
+ // int f() => 0;
+ //
+ // void g() {
+ // new [!f!]();
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If a class should be created, then replace the invalid name with the name
+ // of a valid class:
+ //
+ // ```dart
+ // int f() => 0;
+ //
+ // void g() {
+ // new Object();
+ // }
+ // ```
+ //
+ // If the name is the name of a function and you want that function to be
+ // invoked, then remove the `new` or `const` keyword:
+ //
+ // ```dart
+ // int f() => 0;
+ //
+ // void g() {
+ // f();
+ // }
+ // ```
+ static const CompileTimeErrorCode NEW_WITH_NON_TYPE = CompileTimeErrorCode(
+ 'CREATION_WITH_NON_TYPE',
+ "The name '{0}' isn't a class.",
+ correction: "Try correcting the name to match an existing class.",
+ hasPublishedDocs: true,
+ isUnresolvedIdentifier: true,
+ uniqueName: 'NEW_WITH_NON_TYPE',
+ );
+
+ /**
+ * 12.11.1 New: If <i>T</i> is a class or parameterized type accessible in the
+ * current scope then:
+ * 1. If <i>e</i> is of the form <i>new T.id(a<sub>1</sub>, …,
+ * a<sub>n</sub>, x<sub>n+1</sub>: a<sub>n+1</sub>, …,
+ * x<sub>n+k</sub>: a<sub>n+k</sub>)</i> it is a static warning if
+ * <i>T.id</i> is not the name of a constructor declared by the type
+ * <i>T</i>.
+ * If <i>e</i> of the form <i>new T(a<sub>1</sub>, …, a<sub>n</sub>,
+ * x<sub>n+1</sub>: a<sub>n+1</sub>, …, x<sub>n+k</sub>:
+ * a<sub>n+kM/sub>)</i> it is a static warning if the type <i>T</i> does not
+ * declare a constructor with the same name as the declaration of <i>T</i>.
+ */
+ static const CompileTimeErrorCode NEW_WITH_UNDEFINED_CONSTRUCTOR =
+ CompileTimeErrorCode(
+ 'NEW_WITH_UNDEFINED_CONSTRUCTOR',
+ "The class '{0}' doesn't have a constructor named '{1}'.",
+ correction:
+ "Try invoking a different constructor, or define a constructor named '{1}'.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the class being instantiated
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an unnamed constructor is
+ // invoked on a class that defines named constructors but the class doesn’t
+ // have an unnamed constructor.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `A` doesn't define an
+ // unnamed constructor:
+ //
+ // ```dart
+ // class A {
+ // A.a();
+ // }
+ //
+ // A f() => [!A!]();
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If one of the named constructors does what you need, then use it:
+ //
+ // ```dart
+ // class A {
+ // A.a();
+ // }
+ //
+ // A f() => A.a();
+ // ```
+ //
+ // If none of the named constructors does what you need, and you're able to
+ // add an unnamed constructor, then add the constructor:
+ //
+ // ```dart
+ // class A {
+ // A();
+ // A.a();
+ // }
+ //
+ // A f() => A();
+ // ```
+ static const CompileTimeErrorCode NEW_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT =
+ CompileTimeErrorCode(
+ 'NEW_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT',
+ "The class '{0}' doesn't have an unnamed constructor.",
+ correction: "Try using one of the named constructors defined in '{0}'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the first member
+ * 1: the name of the second member
+ * 2: the name of the third member
+ * 3: the name of the fourth member
+ * 4: the number of additional missing members that aren't listed
+ */
+ static const CompileTimeErrorCode
+ NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FIVE_PLUS =
+ CompileTimeErrorCode(
+ 'NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER',
+ "Missing concrete implementations of '{0}', '{1}', '{2}', '{3}', and {4} more.",
+ correction:
+ "Try implementing the missing methods, or make the class abstract.",
+ hasPublishedDocs: true,
+ uniqueName: 'NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FIVE_PLUS',
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the first member
+ * 1: the name of the second member
+ * 2: the name of the third member
+ * 3: the name of the fourth member
+ */
+ static const CompileTimeErrorCode
+ NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FOUR = CompileTimeErrorCode(
+ 'NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER',
+ "Missing concrete implementations of '{0}', '{1}', '{2}', and '{3}'.",
+ correction:
+ "Try implementing the missing methods, or make the class abstract.",
+ hasPublishedDocs: true,
+ uniqueName: 'NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FOUR',
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the member
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a concrete class inherits one or
+ // more abstract members, and doesn't provide or inherit an implementation for
+ // at least one of those abstract members.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because the class `B` doesn't
+ // have a concrete implementation of `m`:
+ //
+ // ```dart
+ // abstract class A {
+ // void m();
+ // }
+ //
+ // class [!B!] extends A {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the subclass can provide a concrete implementation for some or all of
+ // the abstract inherited members, then add the concrete implementations:
+ //
+ // ```dart
+ // abstract class A {
+ // void m();
+ // }
+ //
+ // class B extends A {
+ // void m() {}
+ // }
+ // ```
+ //
+ // If there is a mixin that provides an implementation of the inherited
+ // methods, then apply the mixin to the subclass:
+ //
+ // ```dart
+ // abstract class A {
+ // void m();
+ // }
+ //
+ // class B extends A with M {}
+ //
+ // mixin M {
+ // void m() {}
+ // }
+ // ```
+ //
+ // If the subclass can't provide a concrete implementation for all of the
+ // abstract inherited members, then mark the subclass as being abstract:
+ //
+ // ```dart
+ // abstract class A {
+ // void m();
+ // }
+ //
+ // abstract class B extends A {}
+ // ```
+ static const CompileTimeErrorCode
+ NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE = CompileTimeErrorCode(
+ 'NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER',
+ "Missing concrete implementation of '{0}'.",
+ correction:
+ "Try implementing the missing method, or make the class abstract.",
+ hasPublishedDocs: true,
+ uniqueName: 'NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE',
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the first member
+ * 1: the name of the second member
+ * 2: the name of the third member
+ */
+ static const CompileTimeErrorCode
+ NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_THREE = CompileTimeErrorCode(
+ 'NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER',
+ "Missing concrete implementations of '{0}', '{1}', and '{2}'.",
+ correction:
+ "Try implementing the missing methods, or make the class abstract.",
+ hasPublishedDocs: true,
+ uniqueName: 'NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_THREE',
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the first member
+ * 1: the name of the second member
+ */
+ static const CompileTimeErrorCode
+ NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_TWO = CompileTimeErrorCode(
+ 'NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER',
+ "Missing concrete implementations of '{0}' and '{1}'.",
+ correction:
+ "Try implementing the missing methods, or make the class abstract.",
+ hasPublishedDocs: true,
+ uniqueName: 'NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_TWO',
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a condition, such as an `if` or
+ // `while` loop, doesn't have the static type `bool`.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `x` has the static type
+ // `int`:
+ //
+ // ```dart
+ // void f(int x) {
+ // if ([!x!]) {
+ // // ...
+ // }
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Change the condition so that it produces a Boolean value:
+ //
+ // ```dart
+ // void f(int x) {
+ // if (x == 0) {
+ // // ...
+ // }
+ // }
+ // ```
+ static const CompileTimeErrorCode NON_BOOL_CONDITION = CompileTimeErrorCode(
+ 'NON_BOOL_CONDITION',
+ "Conditions must have a static type of 'bool'.",
+ correction: "Try changing the condition.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the first expression in an
+ // assert has a type other than `bool`.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because the type of `p` is
+ // `int`, but a `bool` is required:
+ //
+ // ```dart
+ // void f(int p) {
+ // assert([!p!]);
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Change the expression so that it has the type `bool`:
+ //
+ // ```dart
+ // void f(int p) {
+ // assert(p > 0);
+ // }
+ // ```
+ static const CompileTimeErrorCode NON_BOOL_EXPRESSION = CompileTimeErrorCode(
+ 'NON_BOOL_EXPRESSION',
+ "The expression in an assert must be of type 'bool'.",
+ correction: "Try changing the expression.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the operand of the unary
+ // negation operator (`!`) doesn't have the type `bool`.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `x` is an `int` when it
+ // must be a `bool`:
+ //
+ // ```dart
+ // int x = 0;
+ // bool y = ![!x!];
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Replace the operand with an expression that has the type `bool`:
+ //
+ // ```dart
+ // int x = 0;
+ // bool y = !(x > 0);
+ // ```
+ static const CompileTimeErrorCode NON_BOOL_NEGATION_EXPRESSION =
+ CompileTimeErrorCode(
+ 'NON_BOOL_NEGATION_EXPRESSION',
+ "A negation operand must have a static type of 'bool'.",
+ correction: "Try changing the operand to the '!' operator.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the lexeme of the logical operator
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when one of the operands of either
+ // the `&&` or `||` operator doesn't have the type `bool`.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `a` isn't a Boolean
+ // value:
+ //
+ // ```dart
+ // int a = 3;
+ // bool b = [!a!] || a > 1;
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Change the operand to a Boolean value:
+ //
+ // ```dart
+ // int a = 3;
+ // bool b = a == 0 || a > 1;
+ // ```
+ static const CompileTimeErrorCode NON_BOOL_OPERAND = CompileTimeErrorCode(
+ 'NON_BOOL_OPERAND',
+ "The operands of the operator '{0}' must be assignable to 'bool'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an annotation is the invocation
+ // of an existing constructor even though the invoked constructor isn't a
+ // const constructor.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the constructor for `C`
+ // isn't a const constructor:
+ //
+ // ```dart
+ // [!@C()!]
+ // void f() {
+ // }
+ //
+ // class C {
+ // C();
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If it's valid for the class to have a const constructor, then create a
+ // const constructor that can be used for the annotation:
+ //
+ // ```dart
+ // @C()
+ // void f() {
+ // }
+ //
+ // class C {
+ // const C();
+ // }
+ // ```
+ //
+ // If it isn't valid for the class to have a const constructor, then either
+ // remove the annotation or use a different class for the annotation.
+ static const CompileTimeErrorCode NON_CONSTANT_ANNOTATION_CONSTRUCTOR =
+ CompileTimeErrorCode(
+ 'NON_CONSTANT_ANNOTATION_CONSTRUCTOR',
+ "Annotation creation can only call a const constructor.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the expression in a `case`
+ // clause isn't a constant expression.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `j` isn't a constant:
+ //
+ // ```dart
+ // void f(int i, int j) {
+ // switch (i) {
+ // case [!j!]:
+ // // ...
+ // break;
+ // }
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Either make the expression a constant expression, or rewrite the `switch`
+ // statement as a sequence of `if` statements:
+ //
+ // ```dart
+ // void f(int i, int j) {
+ // if (i == j) {
+ // // ...
+ // }
+ // }
+ // ```
+ static const CompileTimeErrorCode NON_CONSTANT_CASE_EXPRESSION =
+ CompileTimeErrorCode(
+ 'NON_CONSTANT_CASE_EXPRESSION',
+ "Case expressions must be constant.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * 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',
+ "Constant values from a deferred library can't be used as a case expression.",
+ correction:
+ "Try re-writing the switch as a series of if statements, or changing the import to not be deferred.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an optional parameter, either
+ // named or positional, has a default value that isn't a compile-time
+ // constant.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic:
+ //
+ // ```dart
+ // %language=2.9
+ // var defaultValue = 3;
+ //
+ // void f([int value = [!defaultValue!]]) {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the default value can be converted to be a constant, then convert it:
+ //
+ // ```dart
+ // %language=2.9
+ // const defaultValue = 3;
+ //
+ // void f([int value = defaultValue]) {}
+ // ```
+ //
+ // If the default value needs to change over time, then apply the default
+ // value inside the function:
+ //
+ // ```dart
+ // %language=2.9
+ // var defaultValue = 3;
+ //
+ // void f([int value]) {
+ // value ??= defaultValue;
+ // }
+ // ```
+ static const CompileTimeErrorCode NON_CONSTANT_DEFAULT_VALUE =
+ CompileTimeErrorCode(
+ 'NON_CONSTANT_DEFAULT_VALUE',
+ "The default value of an optional parameter must be constant.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * 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',
+ "Constant values from a deferred library can't be used as a default parameter value.",
+ correction:
+ "Try leaving the default as null and initializing the parameter inside the function body.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an element in a constant list
+ // literal isn't a constant value. The list literal can be constant either
+ // explicitly (because it's prefixed by the `const` keyword) or implicitly
+ // (because it appears in a [constant context][]).
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `x` isn't a constant,
+ // even though it appears in an implicitly constant list literal:
+ //
+ // ```dart
+ // var x = 2;
+ // var y = const <int>[0, 1, [!x!]];
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the list needs to be a constant list, then convert the element to be a
+ // constant. In the example above, you might add the `const` keyword to the
+ // declaration of `x`:
+ //
+ // ```dart
+ // const x = 2;
+ // var y = const <int>[0, 1, x];
+ // ```
+ //
+ // If the expression can't be made a constant, then the list can't be a
+ // constant either, so you must change the code so that the list isn't a
+ // constant. In the example above this means removing the `const` keyword
+ // before the list literal:
+ //
+ // ```dart
+ // var x = 2;
+ // var y = <int>[0, 1, x];
+ // ```
+ static const CompileTimeErrorCode NON_CONSTANT_LIST_ELEMENT =
+ CompileTimeErrorCode(
+ 'NON_CONSTANT_LIST_ELEMENT',
+ "The values in a const list literal must be constants.",
+ correction: "Try removing the keyword 'const' from the list literal.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * 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 literal.",
+ correction:
+ "Try removing the keyword 'const' from the list literal or removing the keyword 'deferred' from the import.",
+ hasPublishedDocs: true,
+ uniqueName: 'NON_CONSTANT_LIST_ELEMENT_FROM_DEFERRED_LIBRARY',
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an `if` element or a spread
+ // element in a constant map isn't a constant element.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because it's attempting to
+ // spread a non-constant map:
+ //
+ // ```dart
+ // var notConst = <int, int>{};
+ // var map = const <int, int>{...[!notConst!]};
+ // ```
+ //
+ // Similarly, the following code produces this diagnostic because the
+ // condition in the `if` element isn't a constant expression:
+ //
+ // ```dart
+ // bool notConst = true;
+ // var map = const <int, int>{if ([!notConst!]) 1 : 2};
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the map needs to be a constant map, then make the elements constants.
+ // In the spread example, you might do that by making the collection being
+ // spread a constant:
+ //
+ // ```dart
+ // const notConst = <int, int>{};
+ // var map = const <int, int>{...notConst};
+ // ```
+ //
+ // If the map doesn't need to be a constant map, then remove the `const`
+ // keyword:
+ //
+ // ```dart
+ // bool notConst = true;
+ // var map = <int, int>{if (notConst) 1 : 2};
+ // ```
+ static const CompileTimeErrorCode NON_CONSTANT_MAP_ELEMENT =
+ CompileTimeErrorCode(
+ 'NON_CONSTANT_MAP_ELEMENT',
+ "The elements in a const map literal must be constant.",
+ correction: "Try removing the keyword 'const' from the map literal.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a key in a constant map literal
+ // isn't a constant value.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic beause `a` isn't a constant:
+ //
+ // ```dart
+ // var a = 'a';
+ // var m = const {[!a!]: 0};
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the map needs to be a constant map, then make the key a constant:
+ //
+ // ```dart
+ // const a = 'a';
+ // var m = const {a: 0};
+ // ```
+ //
+ // If the map doesn't need to be a constant map, then remove the `const`
+ // keyword:
+ //
+ // ```dart
+ // var a = 'a';
+ // var m = {a: 0};
+ // ```
+ static const CompileTimeErrorCode NON_CONSTANT_MAP_KEY = CompileTimeErrorCode(
+ 'NON_CONSTANT_MAP_KEY',
+ "The keys in a const map literal must be constant.",
+ correction: "Try removing the keyword 'const' from the map literal.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * 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 or removing the keyword 'deferred' from the import.",
+ hasPublishedDocs: true,
+ uniqueName: 'NON_CONSTANT_MAP_KEY_FROM_DEFERRED_LIBRARY',
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a value in a constant map
+ // literal isn't a constant value.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `a` isn't a constant:
+ //
+ // ```dart
+ // var a = 'a';
+ // var m = const {0: [!a!]};
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the map needs to be a constant map, then make the key a constant:
+ //
+ // ```dart
+ // const a = 'a';
+ // var m = const {0: a};
+ // ```
+ //
+ // If the map doesn't need to be a constant map, then remove the `const`
+ // keyword:
+ //
+ // ```dart
+ // var a = 'a';
+ // var m = {0: a};
+ // ```
+ static const CompileTimeErrorCode NON_CONSTANT_MAP_VALUE =
+ CompileTimeErrorCode(
+ 'NON_CONSTANT_MAP_VALUE',
+ "The values in a const map literal must be constant.",
+ correction: "Try removing the keyword 'const' from the map literal.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * 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 or removing the keyword 'deferred' from the import.",
+ hasPublishedDocs: true,
+ uniqueName: 'NON_CONSTANT_MAP_VALUE_FROM_DEFERRED_LIBRARY',
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a constant set literal contains
+ // an element that isn't a compile-time constant.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `i` isn't a constant:
+ //
+ // ```dart
+ // var i = 0;
+ //
+ // var s = const {[!i!]};
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the element can be changed to be a constant, then change it:
+ //
+ // ```dart
+ // const i = 0;
+ //
+ // var s = const {i};
+ // ```
+ //
+ // If the element can't be a constant, then remove the keyword `const`:
+ //
+ // ```dart
+ // var i = 0;
+ //
+ // var s = {i};
+ // ```
+ static const CompileTimeErrorCode NON_CONSTANT_SET_ELEMENT =
+ CompileTimeErrorCode(
+ 'NON_CONSTANT_SET_ELEMENT',
+ "The values in a const set literal must be constants.",
+ correction: "Try removing the keyword 'const' from the set literal.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * 13.2 Expression Statements: It is a compile-time error if a non-constant
+ * map literal that has no explicit type arguments appears in a place where a
+ * statement is expected.
+ */
+ static const CompileTimeErrorCode NON_CONST_MAP_AS_EXPRESSION_STATEMENT =
+ CompileTimeErrorCode(
+ 'NON_CONST_MAP_AS_EXPRESSION_STATEMENT',
+ "A non-constant map or set literal without type arguments can't be used as an expression statement.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the non-generative constructor
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the initializer list of a
+ // constructor invokes a constructor from the superclass, and the invoked
+ // constructor is a factory constructor. Only a generative constructor can be
+ // invoked in the initializer list.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the invocation of the
+ // constructor `super.one()` is invoking a factory constructor:
+ //
+ // ```dart
+ // class A {
+ // factory A.one() = B;
+ // A.two();
+ // }
+ //
+ // class B extends A {
+ // B() : [!super.one()!];
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Change the super invocation to invoke a generative constructor:
+ //
+ // ```dart
+ // class A {
+ // factory A.one() = B;
+ // A.two();
+ // }
+ //
+ // class B extends A {
+ // B() : super.two();
+ // }
+ // ```
+ //
+ // If the generative constructor is the unnamed constructor, and if there are
+ // no arguments being passed to it, then you can remove the super invocation.
+ static const CompileTimeErrorCode NON_GENERATIVE_CONSTRUCTOR =
+ CompileTimeErrorCode(
+ 'NON_GENERATIVE_CONSTRUCTOR',
+ "The generative constructor '{0}' is expected, but a factory was found.",
+ correction:
+ "Try calling a different constructor of the superclass, or making the called constructor not be a factory constructor.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * An error code for when a class has no explicit constructor, and therefore
+ * a constructor is implicitly defined which uses a factory as a
+ * superinitializer. See [NON_GENERATIVE_CONSTRUCTOR].
+ *
+ * Parameters:
+ * 0: the name of the superclass
+ * 1: the name of the current class
+ * 2: the implicitly called factory constructor of the superclass
+ */
+ static const CompileTimeErrorCode NON_GENERATIVE_IMPLICIT_CONSTRUCTOR =
+ CompileTimeErrorCode(
+ 'NON_GENERATIVE_IMPLICIT_CONSTRUCTOR',
+ "The unnamed constructor of superclass '{0}' (called by the default constructor of '{1}') must be a generative constructor, but factory found.",
+ correction:
+ "Try adding an explicit constructor that has a different superinitializer or changing the superclass constructor '{2}' to not be a factory constructor.",
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the body of a factory
+ // constructor is marked with `async`, `async*`, or `sync*`. All constructors,
+ // including factory constructors, are required to return an instance of the
+ // class in which they're declared, not a `Future`, `Stream`, or `Iterator`.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the body of the factory
+ // constructor is marked with `async`:
+ //
+ // ```dart
+ // class C {
+ // factory C() [!async!] {
+ // return C._();
+ // }
+ // C._();
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the member must be declared as a factory constructor, then remove the
+ // keyword appearing before the body:
+ //
+ // ```dart
+ // class C {
+ // factory C() {
+ // return C._();
+ // }
+ // C._();
+ // }
+ // ```
+ //
+ // If the member must return something other than an instance of the enclosing
+ // class, then make the member a static method:
+ //
+ // ```dart
+ // class C {
+ // static Future<C> m() async {
+ // return C._();
+ // }
+ // C._();
+ // }
+ // ```
+ static const CompileTimeErrorCode NON_SYNC_FACTORY = CompileTimeErrorCode(
+ 'NON_SYNC_FACTORY',
+ "Factory bodies can't use 'async', 'async*', or 'sync*'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name appearing where a type is expected
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an identifier that isn't a type
+ // is used as a type argument.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `x` is a variable, not
+ // a type:
+ //
+ // ```dart
+ // var x = 0;
+ // List<[!x!]> xList = [];
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Change the type argument to be a type:
+ //
+ // ```dart
+ // var x = 0;
+ // List<int> xList = [];
+ // ```
+ static const CompileTimeErrorCode NON_TYPE_AS_TYPE_ARGUMENT =
+ CompileTimeErrorCode(
+ 'NON_TYPE_AS_TYPE_ARGUMENT',
+ "The name '{0}' isn't a type so it can't be used as a type argument.",
+ correction:
+ "Try correcting the name to an existing type, or defining a type named '{0}'.",
+ hasPublishedDocs: true,
+ isUnresolvedIdentifier: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the non-type element
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the identifier following the
+ // `on` in a `catch` clause is defined to be something other than a type.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `f` is a function, not
+ // a type:
+ //
+ // ```dart
+ // %language=2.9
+ // void f() {
+ // try {
+ // // ...
+ // } on [!f!] {
+ // // ...
+ // }
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Change the name to the type of object that should be caught:
+ //
+ // ```dart
+ // %language=2.9
+ // void f() {
+ // try {
+ // // ...
+ // } on FormatException {
+ // // ...
+ // }
+ // }
+ // ```
+ static const CompileTimeErrorCode NON_TYPE_IN_CATCH_CLAUSE =
+ CompileTimeErrorCode(
+ 'NON_TYPE_IN_CATCH_CLAUSE',
+ "The name '{0}' isn't a type and can't be used in an on-catch clause.",
+ correction: "Try correcting the name to match an existing class.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a declaration of the operator
+ // `[]=` has a return type other than `void`.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the declaration of the
+ // operator `[]=` has a return type of `int`:
+ //
+ // ```dart
+ // class C {
+ // [!int!] operator []=(int index, int value) => 0;
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Change the return type to `void`:
+ //
+ // ```dart
+ // class C {
+ // void operator []=(int index, int value) => 0;
+ // }
+ // ```
+ static const CompileTimeErrorCode NON_VOID_RETURN_FOR_OPERATOR =
+ CompileTimeErrorCode(
+ 'NON_VOID_RETURN_FOR_OPERATOR',
+ "The return type of the operator []= must be 'void'.",
+ correction: "Try changing the return type to 'void'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a setter is defined with a
+ // return type other than `void`.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the setter `p` has a
+ // return type of `int`:
+ //
+ // ```dart
+ // class C {
+ // [!int!] set p(int i) => 0;
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Change the return type to `void` or omit the return type:
+ //
+ // ```dart
+ // class C {
+ // set p(int i) => 0;
+ // }
+ // ```
+ static const CompileTimeErrorCode NON_VOID_RETURN_FOR_SETTER =
+ CompileTimeErrorCode(
+ 'NON_VOID_RETURN_FOR_SETTER',
+ "The return type of the setter must be 'void' or absent.",
+ correction:
+ "Try removing the return type, or define a method rather than a setter.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the variable that is invalid
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a local variable is referenced
+ // and has all these characteristics:
+ // - Has a type that's [potentially non-nullable][].
+ // - Doesn't have an initializer.
+ // - Isn't marked as `late`.
+ // - The analyzer can't prove that the local variable will be assigned before
+ // the reference based on the specification of [definite assignment][].
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because `x` can't have a value
+ // of `null`, but is referenced before a value was assigned to it:
+ //
+ // ```dart
+ // String f() {
+ // int x;
+ // return [!x!].toString();
+ // }
+ // ```
+ //
+ // The following code produces this diagnostic because the assignment to `x`
+ // might not be executed, so it might have a value of `null`:
+ //
+ // ```dart
+ // int g(bool b) {
+ // int x;
+ // if (b) {
+ // x = 1;
+ // }
+ // return [!x!] * 2;
+ // }
+ // ```
+ //
+ // The following code produces this diagnostic because the analyzer can't
+ // prove, based on definite assignment analysis, that `x` won't be referenced
+ // without having a value assigned to it:
+ //
+ // ```dart
+ // int h(bool b) {
+ // int x;
+ // if (b) {
+ // x = 1;
+ // }
+ // if (b) {
+ // return [!x!] * 2;
+ // }
+ // return 0;
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If `null` is a valid value, then make the variable nullable:
+ //
+ // ```dart
+ // String f() {
+ // int? x;
+ // return x!.toString();
+ // }
+ // ```
+ //
+ // If `null` isn’t a valid value, and there's a reasonable default value, then
+ // add an initializer:
+ //
+ // ```dart
+ // int g(bool b) {
+ // int x = 2;
+ // if (b) {
+ // x = 1;
+ // }
+ // return x * 2;
+ // }
+ // ```
+ //
+ // Otherwise, ensure that a value was assigned on every possible code path
+ // before the value is accessed:
+ //
+ // ```dart
+ // int g(bool b) {
+ // int x;
+ // if (b) {
+ // x = 1;
+ // } else {
+ // x = 2;
+ // }
+ // return x * 2;
+ // }
+ // ```
+ //
+ // You can also mark the variable as `late`, which removes the diagnostic, but
+ // if the variable isn't assigned a value before it's accessed, then it
+ // results in an exception being thrown at runtime. This approach should only
+ // be used if you're sure that the variable will always be assigned, even
+ // though the analyzer can't prove it based on definite assignment analysis.
+ //
+ // ```dart
+ // int h(bool b) {
+ // late int x;
+ // if (b) {
+ // x = 1;
+ // }
+ // if (b) {
+ // return x * 2;
+ // }
+ // return 0;
+ // }
+ // ```
+ static const CompileTimeErrorCode
+ NOT_ASSIGNED_POTENTIALLY_NON_NULLABLE_LOCAL_VARIABLE =
+ CompileTimeErrorCode(
+ 'NOT_ASSIGNED_POTENTIALLY_NON_NULLABLE_LOCAL_VARIABLE',
+ "The non-nullable local variable '{0}' must be assigned before it can be used.",
+ correction:
+ "Try giving it an initializer expression, or ensure that it's assigned on every execution path.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name that is not a type
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a name is used as a type but
+ // declared to be something other than a type.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `f` is a function:
+ //
+ // ```dart
+ // f() {}
+ // g([!f!] v) {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Replace the name with the name of a type.
+ static const CompileTimeErrorCode NOT_A_TYPE = CompileTimeErrorCode(
+ 'NOT_A_TYPE',
+ "{0} isn't a type.",
+ correction: "Try correcting the name to match an existing type.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the operator that is not a binary operator.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an operator that can only be
+ // used as a unary operator is used as a binary operator.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the operator `~` can
+ // only be used as a unary operator:
+ //
+ // ```dart
+ // var a = 5 [!~!] 3;
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Replace the operator with the correct binary operator:
+ //
+ // ```dart
+ // var a = 5 - 3;
+ // ```
+ static const CompileTimeErrorCode NOT_BINARY_OPERATOR = CompileTimeErrorCode(
+ 'NOT_BINARY_OPERATOR',
+ "'{0}' isn't a binary operator.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the expected number of required arguments
+ * 1: the actual number of positional arguments given
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a method or function invocation
+ // has fewer positional arguments than the number of required positional
+ // parameters.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `f` declares two
+ // required parameters, but only one argument is provided:
+ //
+ // ```dart
+ // void f(int a, int b) {}
+ // void g() {
+ // f[!(0)!];
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Add arguments corresponding to the remaining parameters:
+ //
+ // ```dart
+ // void f(int a, int b) {}
+ // void g() {
+ // f(0, 1);
+ // }
+ // ```
+ static const CompileTimeErrorCode NOT_ENOUGH_POSITIONAL_ARGUMENTS =
+ CompileTimeErrorCode(
+ 'NOT_ENOUGH_POSITIONAL_ARGUMENTS',
+ "{0} positional argument(s) expected, but {1} found.",
+ correction: "Try adding the missing arguments.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the field that is not initialized
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a field is declared and has all
+ // these characteristics:
+ // - Has a type that's [potentially non-nullable][]
+ // - Doesn't have an initializer
+ // - Isn't marked as `late`
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because `x` is implicitly
+ // initialized to `null` when it isn't allowed to be `null`:
+ //
+ // ```dart
+ // class C {
+ // int [!x!];
+ // }
+ // ```
+ //
+ // Similarly, the following code produces this diagnostic because `x` is
+ // implicitly initialized to `null`, when it isn't allowed to be `null`, by
+ // one of the constructors, even though it's initialized by other
+ // constructors:
+ //
+ // ```dart
+ // class C {
+ // int x;
+ //
+ // C(this.x);
+ //
+ // [!C!].n();
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If there's a reasonable default value for the field that’s the same for all
+ // instances, then add an initializer expression:
+ //
+ // ```dart
+ // class C {
+ // int x = 0;
+ // }
+ // ```
+ //
+ // If the value of the field should be provided when an instance is created,
+ // then add a constructor that sets the value of the field or update an
+ // existing constructor:
+ //
+ // ```dart
+ // class C {
+ // int x;
+ //
+ // C(this.x);
+ // }
+ // ```
+ //
+ // You can also mark the field as `late`, which removes the diagnostic, but if
+ // the field isn't assigned a value before it's accessed, then it results in
+ // an exception being thrown at runtime. This approach should only be used if
+ // you're sure that the field will always be assigned before it's referenced.
+ //
+ // ```dart
+ // class C {
+ // late int x;
+ // }
+ // ```
+ static const CompileTimeErrorCode
+ NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD = CompileTimeErrorCode(
+ 'NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD',
+ "Non-nullable instance field '{0}' must be initialized.",
+ correction:
+ "Try adding an initializer expression, or a generative constructor that initializes it, or mark it 'late'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the field that is not initialized
+ */
+ static const CompileTimeErrorCode
+ NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD_CONSTRUCTOR =
+ CompileTimeErrorCode(
+ 'NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD',
+ "Non-nullable instance field '{0}' must be initialized.",
+ correction:
+ "Try adding an initializer expression, or add a field initializer in this constructor, or mark it 'late'.",
+ hasPublishedDocs: true,
+ uniqueName: 'NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD_CONSTRUCTOR',
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the variable that is invalid
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a static field or top-level
+ // variable has a type that's non-nullable and doesn't have an initializer.
+ // Fields and variables that don't have an initializer are normally
+ // initialized to `null`, but the type of the field or variable doesn't allow
+ // it to be set to `null`, so an explicit initializer must be provided.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the field `f` can't be
+ // initialized to `null`:
+ //
+ // ```dart
+ // class C {
+ // static int [!f!];
+ // }
+ // ```
+ //
+ // Similarly, the following code produces this diagnostic because the
+ // top-level variable `v` can't be initialized to `null`:
+ //
+ // ```dart
+ // int [!v!];
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the field or variable can't be initialized to `null`, then add an
+ // initializer that sets it to a non-null value:
+ //
+ // ```dart
+ // class C {
+ // static int f = 0;
+ // }
+ // ```
+ //
+ // If the field or variable should be initialized to `null`, then change the
+ // type to be nullable:
+ //
+ // ```dart
+ // int? v;
+ // ```
+ //
+ // If the field or variable can't be initialized in the declaration but will
+ // always be initialized before it's referenced, then mark it as being `late`:
+ //
+ // ```dart
+ // class C {
+ // static late int f;
+ // }
+ // ```
+ static const CompileTimeErrorCode NOT_INITIALIZED_NON_NULLABLE_VARIABLE =
+ CompileTimeErrorCode(
+ 'NOT_INITIALIZED_NON_NULLABLE_VARIABLE',
+ "The non-nullable variable '{0}' must be initialized.",
+ correction: "Try adding an initializer expression.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ static const CompileTimeErrorCode NOT_INSTANTIATED_BOUND =
+ CompileTimeErrorCode(
+ 'NOT_INSTANTIATED_BOUND',
+ "Type parameter bound types must be instantiated.",
+ correction: "Try adding type arguments to the type parameter bound.",
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the static type of the
+ // expression of a spread element that appears in either a list literal or a
+ // set literal doesn't implement the type `Iterable`.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic:
+ //
+ // ```dart
+ // var m = <String, int>{'a': 0, 'b': 1};
+ // var s = <String>{...[!m!]};
+ // ```
+ //
+ // #### Common fixes
+ //
+ // The most common fix is to replace the expression with one that produces an
+ // iterable object:
+ //
+ // ```dart
+ // var m = <String, int>{'a': 0, 'b': 1};
+ // var s = <String>{...m.keys};
+ // ```
+ static const CompileTimeErrorCode NOT_ITERABLE_SPREAD = CompileTimeErrorCode(
+ 'NOT_ITERABLE_SPREAD',
+ "Spread elements in list or set literals must implement 'Iterable'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the static type of the
+ // expression of a spread element that appears in a map literal doesn't
+ // implement the type `Map`.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `l` isn't a `Map`:
+ //
+ // ```dart
+ // var l = <String>['a', 'b'];
+ // var m = <int, String>{...[!l!]};
+ // ```
+ //
+ // #### Common fixes
+ //
+ // The most common fix is to replace the expression with one that produces a
+ // map:
+ //
+ // ```dart
+ // var l = <String>['a', 'b'];
+ // var m = <int, String>{...l.asMap()};
+ // ```
+ static const CompileTimeErrorCode NOT_MAP_SPREAD = CompileTimeErrorCode(
+ 'NOT_MAP_SPREAD',
+ "Spread elements in map literals must implement 'Map'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ static const CompileTimeErrorCode NOT_NULL_AWARE_NULL_SPREAD =
+ CompileTimeErrorCode(
+ 'NOT_NULL_AWARE_NULL_SPREAD',
+ "The Null typed expression can't be used with a non-null-aware spread.",
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an annotation consists of a
+ // single identifier, but that identifier is the name of a class rather than a
+ // variable. To create an instance of the class, the identifier must be
+ // followed by an argument list.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `C` is a class, and a
+ // class can't be used as an annotation without invoking a `const` constructor
+ // from the class:
+ //
+ // ```dart
+ // class C {
+ // const C();
+ // }
+ //
+ // [!@C!]
+ // var x;
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Add the missing argument list:
+ //
+ // ```dart
+ // class C {
+ // const C();
+ // }
+ //
+ // @C()
+ // var x;
+ // ```
+ static const CompileTimeErrorCode NO_ANNOTATION_CONSTRUCTOR_ARGUMENTS =
+ CompileTimeErrorCode(
+ 'NO_ANNOTATION_CONSTRUCTOR_ARGUMENTS',
+ "Annotation creation must have arguments.",
+ correction: "Try adding an empty argument list.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the class where override error was detected
+ * 1: the list of candidate signatures which cannot be combined
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when there is a method declaration
+ // for which one or more types needs to be inferred, and those types can't be
+ // inferred because none of the overridden methods has a function type that is
+ // a supertype of all the other overridden methods, as specified by
+ // [override inference][].
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the method `m` declared
+ // in the class `C` is missing both the return type and the type of the
+ // parameter `a`, and neither of the missing types can be inferred for it:
+ //
+ // ```dart
+ // abstract class A {
+ // A m(String a);
+ // }
+ //
+ // abstract class B {
+ // B m(int a);
+ // }
+ //
+ // abstract class C implements A, B {
+ // [!m!](a);
+ // }
+ // ```
+ //
+ // In this example, override inference can't be performed because the
+ // overridden methods are incompatible in these ways:
+ // - Neither parameter type (`String` and `int`) is a supertype of the other.
+ // - Neither return type is a subtype of the other.
+ //
+ // #### Common fixes
+ //
+ // If possible, add types to the method in the subclass that are consistent
+ // with the types from all the overridden methods:
+ //
+ // ```dart
+ // abstract class A {
+ // A m(String a);
+ // }
+ //
+ // abstract class B {
+ // B m(int a);
+ // }
+ //
+ // abstract class C implements A, B {
+ // C m(Object a);
+ // }
+ // ```
+ static const CompileTimeErrorCode NO_COMBINED_SUPER_SIGNATURE =
+ CompileTimeErrorCode(
+ 'NO_COMBINED_SUPER_SIGNATURE',
+ "Can't infer missing types in '{0}' from overridden methods: {1}.",
+ correction:
+ "Try providing explicit types for this method's parameters and return type.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the superclass that does not define an implicitly invoked
+ * constructor
+ */
+ static const CompileTimeErrorCode NO_DEFAULT_SUPER_CONSTRUCTOR_EXPLICIT =
+ CompileTimeErrorCode(
+ 'NO_DEFAULT_SUPER_CONSTRUCTOR',
+ "The superclass '{0}' doesn't have a zero argument constructor.",
+ correction:
+ "Try declaring a zero argument constructor in '{0}', or explicitly invoking a different constructor in '{0}'.",
+ uniqueName: 'NO_DEFAULT_SUPER_CONSTRUCTOR_EXPLICIT',
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the superclass that does not define an implicitly invoked
+ * constructor
+ * 1: the name of the subclass that does not contain any explicit constructors
+ */
+ static const CompileTimeErrorCode NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT =
+ CompileTimeErrorCode(
+ 'NO_DEFAULT_SUPER_CONSTRUCTOR',
+ "The superclass '{0}' doesn't have a zero argument constructor.",
+ correction:
+ "Try declaring a zero argument constructor in '{0}', or declaring a constructor in {1} that explicitly invokes a constructor in '{0}'.",
+ uniqueName: 'NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT',
+ );
+
+ /**
+ * User friendly specialized error for [NON_GENERATIVE_CONSTRUCTOR]. This
+ * handles the case of `class E extends Exception` which will never work
+ * because [Exception] has no generative constructors.
+ *
+ * Parameters:
+ * 0: the name of the subclass
+ * 1: the name of the superclass
+ */
+ static const CompileTimeErrorCode NO_GENERATIVE_CONSTRUCTORS_IN_SUPERCLASS =
+ CompileTimeErrorCode(
+ 'NO_GENERATIVE_CONSTRUCTORS_IN_SUPERCLASS',
+ "The class '{0}' cannot extend '{1}' because '{1}' only has factory constructors (no generative constructors), and '{0}' has at least one generative constructor.",
+ correction:
+ "Try implementing the class instead, adding a generative (not factory) constructor to the superclass {0}, or a factory constructor to the subclass.",
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a class declaration uses an
+ // `extends` clause to specify a superclass, and the superclass is followed by
+ // a `?`.
+ //
+ // It isn't valid to specify a nullable superclass because doing so would have
+ // no meaning; it wouldn't change either the interface or implementation being
+ // inherited by the class containing the `extends` clause.
+ //
+ // Note, however, that it _is_ valid to use a nullable type as a type argument
+ // to the superclass, such as `class A extends B<C?> {}`.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because `A?` is a nullable
+ // type, and nullable types can't be used in an `extends` clause:
+ //
+ // ```dart
+ // class A {}
+ // class B extends [!A?!] {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Remove the question mark from the type:
+ //
+ // ```dart
+ // class A {}
+ // class B extends A {}
+ // ```
+ static const CompileTimeErrorCode NULLABLE_TYPE_IN_EXTENDS_CLAUSE =
+ CompileTimeErrorCode(
+ 'NULLABLE_TYPE_IN_EXTENDS_CLAUSE',
+ "A class can't extend a nullable type.",
+ correction: "Try removing the question mark.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a class or mixin declaration has
+ // an `implements` clause, and an interface is followed by a `?`.
+ //
+ // It isn't valid to specify a nullable interface because doing so would have
+ // no meaning; it wouldn't change the interface being inherited by the class
+ // containing the `implements` clause.
+ //
+ // Note, however, that it _is_ valid to use a nullable type as a type argument
+ // to the interface, such as `class A implements B<C?> {}`.
+ //
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because `A?` is a nullable
+ // type, and nullable types can't be used in an `implements` clause:
+ //
+ // ```dart
+ // class A {}
+ // class B implements [!A?!] {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Remove the question mark from the type:
+ //
+ // ```dart
+ // class A {}
+ // class B implements A {}
+ // ```
+ static const CompileTimeErrorCode NULLABLE_TYPE_IN_IMPLEMENTS_CLAUSE =
+ CompileTimeErrorCode(
+ 'NULLABLE_TYPE_IN_IMPLEMENTS_CLAUSE',
+ "A class or mixin can't implement a nullable type.",
+ correction: "Try removing the question mark.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a mixin declaration uses an `on`
+ // clause to specify a superclass constraint, and the class that's specified
+ // is followed by a `?`.
+ //
+ // It isn't valid to specify a nullable superclass constraint because doing so
+ // would have no meaning; it wouldn't change the interface being depended on
+ // by the mixin containing the `on` clause.
+ //
+ // Note, however, that it _is_ valid to use a nullable type as a type argument
+ // to the superclass constraint, such as `mixin A on B<C?> {}`.
+ //
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because `A?` is a nullable type
+ // and nullable types can't be used in an `on` clause:
+ //
+ // ```dart
+ // class C {}
+ // mixin M on [!C?!] {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Remove the question mark from the type:
+ //
+ // ```dart
+ // class C {}
+ // mixin M on C {}
+ // ```
+ static const CompileTimeErrorCode NULLABLE_TYPE_IN_ON_CLAUSE =
+ CompileTimeErrorCode(
+ 'NULLABLE_TYPE_IN_ON_CLAUSE',
+ "A mixin can't have a nullable type as a superclass constraint.",
+ correction: "Try removing the question mark.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a class or mixin declaration has
+ // a `with` clause, and a mixin is followed by a `?`.
+ //
+ // It isn't valid to specify a nullable mixin because doing so would have no
+ // meaning; it wouldn't change either the interface or implementation being
+ // inherited by the class containing the `with` clause.
+ //
+ // Note, however, that it _is_ valid to use a nullable type as a type argument
+ // to the mixin, such as `class A with B<C?> {}`.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because `A?` is a nullable
+ // type, and nullable types can't be used in a `with` clause:
+ //
+ // ```dart
+ // mixin M {}
+ // class C with [!M?!] {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Remove the question mark from the type:
+ //
+ // ```dart
+ // mixin M {}
+ // class C with M {}
+ // ```
+ static const CompileTimeErrorCode NULLABLE_TYPE_IN_WITH_CLAUSE =
+ CompileTimeErrorCode(
+ 'NULLABLE_TYPE_IN_WITH_CLAUSE',
+ "A class or mixin can't mix in a nullable type.",
+ correction: "Try removing the question mark.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * 7.9 Superclasses: It is a compile-time error to specify an extends clause
+ * for class Object.
+ */
+ static const CompileTimeErrorCode OBJECT_CANNOT_EXTEND_ANOTHER_CLASS =
+ CompileTimeErrorCode(
+ 'OBJECT_CANNOT_EXTEND_ANOTHER_CLASS',
+ "The class 'Object' can't extend any other class.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the interface that is implemented more than once
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the same type is listed in the
+ // superclass constraints of a mixin multiple times.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because `A` is included twice
+ // in the superclass constraints for `M`:
+ //
+ // ```dart
+ // mixin M on A, [!A!] {
+ // }
+ //
+ // class A {}
+ // class B {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If a different type should be included in the superclass constraints, then
+ // replace one of the occurrences with the other type:
+ //
+ // ```dart
+ // mixin M on A, B {
+ // }
+ //
+ // class A {}
+ // class B {}
+ // ```
+ //
+ // If no other type was intended, then remove the repeated type name:
+ //
+ // ```dart
+ // mixin M on A {
+ // }
+ //
+ // class A {}
+ // class B {}
+ // ```
+ static const CompileTimeErrorCode ON_REPEATED = CompileTimeErrorCode(
+ 'ON_REPEATED',
+ "The type '{0}' can be included in the superclass constraints only once.",
+ correction: "Try removing all except one occurrence of the type name.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when one or more of the parameters in
+ // an operator declaration are optional.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the parameter `other`
+ // is an optional parameter:
+ //
+ // ```dart
+ // class C {
+ // C operator +([[!C? other!]]) => this;
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Make all of the parameters be required parameters:
+ //
+ // ```dart
+ // class C {
+ // C operator +(C other) => this;
+ // }
+ // ```
+ static const CompileTimeErrorCode OPTIONAL_PARAMETER_IN_OPERATOR =
+ CompileTimeErrorCode(
+ 'OPTIONAL_PARAMETER_IN_OPERATOR',
+ "Optional parameters aren't allowed when defining an operator.",
+ correction: "Try removing the optional parameters.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of expected library name
+ * 1: the non-matching actual library name from the "part of" declaration
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a library attempts to include a
+ // file as a part of itself when the other file is a part of a different
+ // library.
+ //
+ // #### Example
+ //
+ // Given a file named `part.dart` containing
+ //
+ // ```dart
+ // %uri="package:a/part.dart"
+ // part of 'library.dart';
+ // ```
+ //
+ // The following code, in any file other than `library.dart`, produces this
+ // diagnostic because it attempts to include `part.dart` as a part of itself
+ // when `part.dart` is a part of a different library:
+ //
+ // ```dart
+ // part [!'package:a/part.dart'!];
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the library should be using a different file as a part, then change the
+ // URI in the part directive to be the URI of the other file.
+ //
+ // If the part file should be a part of this library, then update the URI (or
+ // library name) in the part-of directive to be the URI (or name) of the
+ // correct library.
+ static const CompileTimeErrorCode PART_OF_DIFFERENT_LIBRARY =
+ CompileTimeErrorCode(
+ 'PART_OF_DIFFERENT_LIBRARY',
+ "Expected this library to be part of '{0}', not '{1}'.",
+ correction:
+ "Try including a different part, or changing the name of the library in the part's part-of directive.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the uri pointing to a non-library declaration
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a part directive is found and
+ // the referenced file doesn't have a part-of directive.
+ //
+ // #### Examples
+ //
+ // Given a file (`a.dart`) containing:
+ //
+ // ```dart
+ // %uri="lib/a.dart"
+ // class A {}
+ // ```
+ //
+ // The following code produces this diagnostic because `a.dart` doesn't
+ // contain a part-of directive:
+ //
+ // ```dart
+ // part [!'a.dart'!];
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the referenced file is intended to be a part of another library, then
+ // add a part-of directive to the file:
+ //
+ // ```dart
+ // part of 'test.dart';
+ //
+ // class A {}
+ // ```
+ //
+ // If the referenced file is intended to be a library, then replace the part
+ // directive with an import directive:
+ //
+ // ```dart
+ // import 'a.dart';
+ // ```
+ static const CompileTimeErrorCode PART_OF_NON_PART = CompileTimeErrorCode(
+ 'PART_OF_NON_PART',
+ "The included part '{0}' must have a part-of directive.",
+ correction: "Try adding a part-of directive to '{0}'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the URI of the expected library
+ * 1: the non-matching actual library name from the "part of" declaration
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a library that doesn't have a
+ // `library` directive (and hence has no name) contains a `part` directive and
+ // the `part of` directive in the part file uses a name to specify the library
+ // that it's a part of.
+ //
+ // #### Example
+ //
+ // Given a part file named `part_file.dart` containing the following code:
+ //
+ // ```dart
+ // %uri="lib/part_file.dart"
+ // part of lib;
+ // ```
+ //
+ // The following code produces this diagnostic because the library including
+ // the part file doesn't have a name even though the part file uses a name to
+ // specify which library it's a part of:
+ //
+ // ```dart
+ // part [!'part_file.dart'!];
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Change the `part of` directive in the part file to specify its library by
+ // URI:
+ //
+ // ```dart
+ // part of 'test.dart';
+ // ```
+ static const CompileTimeErrorCode PART_OF_UNNAMED_LIBRARY =
+ CompileTimeErrorCode(
+ 'PART_OF_UNNAMED_LIBRARY',
+ "The library is unnamed. A URI is expected, not a library name '{0}', in the part-of directive.",
+ correction:
+ "Try changing the part-of directive to a URI, or try including a different part.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the prefix
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a name is used as both an import
+ // prefix and the name of a top-level declaration in the same library.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because `f` is used as both an
+ // import prefix and the name of a function:
+ //
+ // ```dart
+ // import 'dart:math' as f;
+ //
+ // int [!f!]() => f.min(0, 1);
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you want to use the name for the import prefix, then rename the
+ // top-level declaration:
+ //
+ // ```dart
+ // import 'dart:math' as f;
+ //
+ // int g() => f.min(0, 1);
+ // ```
+ //
+ // If you want to use the name for the top-level declaration, then rename the
+ // import prefix:
+ //
+ // ```dart
+ // import 'dart:math' as math;
+ //
+ // int f() => math.min(0, 1);
+ // ```
+ static const CompileTimeErrorCode PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER =
+ CompileTimeErrorCode(
+ 'PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER',
+ "The name '{0}' is already used as an import prefix and can't be used to name a top-level element.",
+ correction: "Try renaming either the top-level element or the prefix.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the prefix
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an import prefix is used by
+ // itself, without accessing any of the names declared in the libraries
+ // associated with the prefix. Prefixes aren't variables, and therefore can't
+ // be used as a value.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the prefix `math` is
+ // being used as if it were a variable:
+ //
+ // ```dart
+ // import 'dart:math' as math;
+ //
+ // void f() {
+ // print([!math!]);
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the code is incomplete, then reference something in one of the libraries
+ // associated with the prefix:
+ //
+ // ```dart
+ // import 'dart:math' as math;
+ //
+ // void f() {
+ // print(math.pi);
+ // }
+ // ```
+ //
+ // If the name is wrong, then correct the name.
+ static const CompileTimeErrorCode PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT =
+ CompileTimeErrorCode(
+ 'PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT',
+ "The name '{0}' refers to an import prefix, so it must be followed by '.'.",
+ correction:
+ "Try correcting the name to refer to something other than a prefix, or renaming the prefix.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * From the `Static Types` section of the spec:
+ *
+ * A type T is malformed if:
+ * - T has the form id or the form prefix.id, and in the enclosing lexical
+ * scope, the name id (respectively prefix.id) does not denote a type.
+ *
+ * In particular, this means that if an import prefix is shadowed by a local
+ * declaration, it is an error to try to use it as a prefix for a type name.
+ */
+ static const CompileTimeErrorCode PREFIX_SHADOWED_BY_LOCAL_DECLARATION =
+ CompileTimeErrorCode(
+ 'PREFIX_SHADOWED_BY_LOCAL_DECLARATION',
+ "The prefix '{0}' can't be used here because it is shadowed by a local declaration.",
+ correction: "Try renaming either the prefix or the local declaration.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the private name that collides
+ * 1: the name of the first mixin
+ * 2: the name of the second mixin
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when two mixins that define the same
+ // private member are used together in a single class in a library other than
+ // the one that defines the mixins.
+ //
+ // #### Example
+ //
+ // Given a file named `a.dart` containing the following code:
+ //
+ // ```dart
+ // %uri="lib/a.dart"
+ // class A {
+ // void _foo() {}
+ // }
+ //
+ // class B {
+ // void _foo() {}
+ // }
+ // ```
+ //
+ // The following code produces this diagnostic because the classes `A` and `B`
+ // both define the method `_foo`:
+ //
+ // ```dart
+ // import 'a.dart';
+ //
+ // class C extends Object with A, [!B!] {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you don't need both of the mixins, then remove one of them from the
+ // `with` clause:
+ //
+ // ```dart
+ // import 'a.dart';
+ //
+ // class C extends Object with A, [!B!] {}
+ // ```
+ //
+ // If you need both of the mixins, then rename the conflicting member in one
+ // of the two mixins.
+ static const CompileTimeErrorCode PRIVATE_COLLISION_IN_MIXIN_APPLICATION =
+ CompileTimeErrorCode(
+ 'PRIVATE_COLLISION_IN_MIXIN_APPLICATION',
+ "The private name '{0}', defined by '{1}', conflicts with the same name defined by '{2}'.",
+ correction: "Try removing '{1}' from the 'with' clause.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the name of a named parameter
+ // starts with an underscore.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the named parameter
+ // `_x` starts with an underscore:
+ //
+ // ```dart
+ // class C {
+ // void m({int [!_x!] = 0}) {}
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Rename the parameter so that it doesn't start with an underscore:
+ //
+ // ```dart
+ // class C {
+ // void m({int x = 0}) {}
+ // }
+ // ```
+ static const CompileTimeErrorCode PRIVATE_OPTIONAL_PARAMETER =
+ CompileTimeErrorCode(
+ 'PRIVATE_OPTIONAL_PARAMETER',
+ "Named parameters can't start with an underscore.",
+ hasPublishedDocs: true,
+ );
+
+ static const CompileTimeErrorCode PRIVATE_SETTER = CompileTimeErrorCode(
+ 'PRIVATE_SETTER',
+ "The setter '{0}' is private and can't be accessed outside of the library that declares it.",
+ correction: "Try making it public.",
+ );
+
+ static const CompileTimeErrorCode READ_POTENTIALLY_UNASSIGNED_FINAL =
+ CompileTimeErrorCode(
+ 'READ_POTENTIALLY_UNASSIGNED_FINAL',
+ "The final variable '{0}' can't be read because it is potentially unassigned at this point.",
+ correction: "Ensure that it is assigned on necessary execution paths.",
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the value of a compile-time
+ // constant is defined in terms of itself, either directly or indirectly,
+ // creating an infinite loop.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic twice because both of the
+ // constants are defined in terms of the other:
+ //
+ // ```dart
+ // const [!secondsPerHour!] = minutesPerHour * 60;
+ // const [!minutesPerHour!] = secondsPerHour / 60;
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Break the cycle by finding an alternative way of defining at least one of
+ // the constants:
+ //
+ // ```dart
+ // const secondsPerHour = minutesPerHour * 60;
+ // const minutesPerHour = 60;
+ // ```
+ static const CompileTimeErrorCode RECURSIVE_COMPILE_TIME_CONSTANT =
+ CompileTimeErrorCode(
+ 'RECURSIVE_COMPILE_TIME_CONSTANT',
+ "The compile-time constant expression depends on itself.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ *
+ * TODO(scheglov) review this later, there are no explicit "it is a
+ * compile-time error" in specification. But it was added to the co19 and
+ * there is same error for factories.
+ *
+ * https://code.google.com/p/dart/issues/detail?id=954
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a constructor redirects to
+ // itself, either directly or indirectly, creating an infinite loop.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the generative
+ // constructors `C.a` and `C.b` each redirect to the other:
+ //
+ // ```dart
+ // class C {
+ // C.a() : [!this.b()!];
+ // C.b() : [!this.a()!];
+ // }
+ // ```
+ //
+ // The following code produces this diagnostic because the factory
+ // constructors `A` and `B` each redirect to the other:
+ //
+ // ```dart
+ // abstract class A {
+ // factory A() = [!B!];
+ // }
+ // class B implements A {
+ // factory B() = [!A!];
+ // B.named();
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // In the case of generative constructors, break the cycle by finding defining
+ // at least one of the constructors to not redirect to another constructor:
+ //
+ // ```dart
+ // class C {
+ // C.a() : this.b();
+ // C.b();
+ // }
+ // ```
+ //
+ // In the case of factory constructors, break the cycle by defining at least
+ // one of the factory constructors to do one of the following:
+ //
+ // - Redirect to a generative constructor:
+ //
+ // ```dart
+ // abstract class A {
+ // factory A() = B;
+ // }
+ // class B implements A {
+ // factory B() = B.named;
+ // B.named();
+ // }
+ // ```
+ //
+ // - Not redirect to another constructor:
+ //
+ // ```dart
+ // abstract class A {
+ // factory A() = B;
+ // }
+ // class B implements A {
+ // factory B() {
+ // return B.named();
+ // }
+ //
+ // B.named();
+ // }
+ // ```
+ //
+ // - Not be a factory constructor:
+ //
+ // ```dart
+ // abstract class A {
+ // factory A() = B;
+ // }
+ // class B implements A {
+ // B();
+ // B.named();
+ // }
+ // ```
+ static const CompileTimeErrorCode RECURSIVE_CONSTRUCTOR_REDIRECT =
+ CompileTimeErrorCode(
+ 'RECURSIVE_CONSTRUCTOR_REDIRECT',
+ "Constructors can't redirect to themselves either directly or indirectly.",
+ correction:
+ "Try changing one of the constructors in the loop to not redirect.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ static const CompileTimeErrorCode RECURSIVE_FACTORY_REDIRECT =
+ CompileTimeErrorCode(
+ 'RECURSIVE_CONSTRUCTOR_REDIRECT',
+ "Constructors can't redirect to themselves either directly or indirectly.",
+ correction:
+ "Try changing one of the constructors in the loop to not redirect.",
+ hasPublishedDocs: true,
+ uniqueName: 'RECURSIVE_FACTORY_REDIRECT',
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the class that implements itself recursively
+ * 1: a string representation of the implements loop
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when there's a circularity in the
+ // type hierarchy. This happens when a type, either directly or indirectly,
+ // is declared to be a subtype of itself.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the class `A` is
+ // declared to be a subtype of `B`, and `B` is a subtype of `A`:
+ //
+ // ```dart
+ // class [!A!] extends B {}
+ // class B implements A {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Change the type hierarchy so that there's no circularity.
+ static const CompileTimeErrorCode RECURSIVE_INTERFACE_INHERITANCE =
+ CompileTimeErrorCode(
+ 'RECURSIVE_INTERFACE_INHERITANCE',
+ "'{0}' can't be a superinterface of itself: {1}.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * 7.10 Superinterfaces: It is a compile-time error if the interface of a
+ * class <i>C</i> is a superinterface of itself.
+ *
+ * 8.1 Superinterfaces: It is a compile-time error if an interface is a
+ * superinterface of itself.
+ *
+ * 7.9 Superclasses: It is a compile-time error if a class <i>C</i> is a
+ * superclass of itself.
+ *
+ * Parameters:
+ * 0: the name of the class that implements itself recursively
+ */
+ static const CompileTimeErrorCode RECURSIVE_INTERFACE_INHERITANCE_EXTENDS =
+ CompileTimeErrorCode(
+ 'RECURSIVE_INTERFACE_INHERITANCE',
+ "'{0}' can't extend itself.",
+ hasPublishedDocs: true,
+ uniqueName: 'RECURSIVE_INTERFACE_INHERITANCE_EXTENDS',
+ );
+
+ /**
+ * 7.10 Superinterfaces: It is a compile-time error if the interface of a
+ * class <i>C</i> is a superinterface of itself.
+ *
+ * 8.1 Superinterfaces: It is a compile-time error if an interface is a
+ * superinterface of itself.
+ *
+ * 7.9 Superclasses: It is a compile-time error if a class <i>C</i> is a
+ * superclass of itself.
+ *
+ * Parameters:
+ * 0: the name of the class that implements itself recursively
+ */
+ static const CompileTimeErrorCode RECURSIVE_INTERFACE_INHERITANCE_IMPLEMENTS =
+ CompileTimeErrorCode(
+ 'RECURSIVE_INTERFACE_INHERITANCE',
+ "'{0}' can't implement itself.",
+ hasPublishedDocs: true,
+ uniqueName: 'RECURSIVE_INTERFACE_INHERITANCE_IMPLEMENTS',
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the mixin that constraints itself recursively
+ */
+ static const CompileTimeErrorCode RECURSIVE_INTERFACE_INHERITANCE_ON =
+ CompileTimeErrorCode(
+ 'RECURSIVE_INTERFACE_INHERITANCE',
+ "'{0}' can't use itself as a superclass constraint.",
+ hasPublishedDocs: true,
+ uniqueName: 'RECURSIVE_INTERFACE_INHERITANCE_ON',
+ );
+
+ /**
+ * 7.10 Superinterfaces: It is a compile-time error if the interface of a
+ * class <i>C</i> is a superinterface of itself.
+ *
+ * 8.1 Superinterfaces: It is a compile-time error if an interface is a
+ * superinterface of itself.
+ *
+ * 7.9 Superclasses: It is a compile-time error if a class <i>C</i> is a
+ * superclass of itself.
+ *
+ * Parameters:
+ * 0: the name of the class that implements itself recursively
+ */
+ static const CompileTimeErrorCode RECURSIVE_INTERFACE_INHERITANCE_WITH =
+ CompileTimeErrorCode(
+ 'RECURSIVE_INTERFACE_INHERITANCE',
+ "'{0}' can't use itself as a mixin.",
+ hasPublishedDocs: true,
+ uniqueName: 'RECURSIVE_INTERFACE_INHERITANCE_WITH',
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a generative constructor
+ // redirects to a constructor that isn't defined.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the constructor `C.a`
+ // redirects to the constructor `C.b`, but `C.b` isn't defined:
+ //
+ // ```dart
+ // class C {
+ // C.a() : [!this.b()!];
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the missing constructor must be called, then define it:
+ //
+ // ```dart
+ // class C {
+ // C.a() : this.b();
+ // C.b();
+ // }
+ // ```
+ //
+ // If the missing constructor doesn't need to be called, then remove the
+ // redirect:
+ //
+ // ```dart
+ // class C {
+ // C.a();
+ // }
+ // ```
+ static const CompileTimeErrorCode REDIRECT_GENERATIVE_TO_MISSING_CONSTRUCTOR =
+ CompileTimeErrorCode(
+ 'REDIRECT_GENERATIVE_TO_MISSING_CONSTRUCTOR',
+ "The constructor '{0}' couldn't be found in '{1}'.",
+ correction:
+ "Try redirecting to a different constructor, or defining the constructor named '{0}'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a generative constructor
+ // redirects to a factory constructor.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the generative
+ // constructor `C.a` redirects to the factory constructor `C.b`:
+ //
+ // ```dart
+ // class C {
+ // C.a() : [!this.b()!];
+ // factory C.b() => C.a();
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the generative constructor doesn't need to redirect to another
+ // constructor, then remove the redirect.
+ //
+ // ```dart
+ // class C {
+ // C.a();
+ // factory C.b() => C.a();
+ // }
+ // ```
+ //
+ // If the generative constructor must redirect to another constructor, then
+ // make the other constructor be a generative (non-factory) constructor:
+ //
+ // ```dart
+ // class C {
+ // C.a() : this.b();
+ // C.b();
+ // }
+ // ```
+ static const CompileTimeErrorCode
+ REDIRECT_GENERATIVE_TO_NON_GENERATIVE_CONSTRUCTOR = CompileTimeErrorCode(
+ 'REDIRECT_GENERATIVE_TO_NON_GENERATIVE_CONSTRUCTOR',
+ "Generative constructors can't redirect to a factory constructor.",
+ correction: "Try redirecting to a different constructor.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * A factory constructor can't redirect to a non-generative constructor of an
+ * abstract class.
+ */
+ static const CompileTimeErrorCode REDIRECT_TO_ABSTRACT_CLASS_CONSTRUCTOR =
+ CompileTimeErrorCode(
+ 'REDIRECT_TO_ABSTRACT_CLASS_CONSTRUCTOR',
+ "The redirecting constructor '{0}' can't redirect to a constructor of the abstract class '{1}'.",
+ correction: "Try redirecting to a constructor of a different class.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the redirected constructor
+ * 1: the name of the redirecting constructor
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a factory constructor attempts
+ // to redirect to another constructor, but the two have incompatible
+ // parameters. The parameters are compatible if all of the parameters of the
+ // redirecting constructor can be passed to the other constructor and if the
+ // other constructor doesn't require any parameters that aren't declared by
+ // the redirecting constructor.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because the constructor for `A`
+ // doesn't declare a parameter that the constructor for `B` requires:
+ //
+ // ```dart
+ // abstract class A {
+ // factory A() = [!B!];
+ // }
+ //
+ // class B implements A {
+ // B(int x);
+ // B.zero();
+ // }
+ // ```
+ //
+ // The following code produces this diagnostic because the constructor for `A`
+ // declares a named parameter (`y`) that the constructor for `B` doesn't
+ // allow:
+ //
+ // ```dart
+ // abstract class A {
+ // factory A(int x, {int y}) = [!B!];
+ // }
+ //
+ // class B implements A {
+ // B(int x);
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If there's a different constructor that is compatible with the redirecting
+ // constructor, then redirect to that constructor:
+ //
+ // ```dart
+ // abstract class A {
+ // factory A() = B.zero;
+ // }
+ //
+ // class B implements A {
+ // B(int x);
+ // B.zero();
+ // }
+ // ```
+ //
+ // Otherwise, update the redirecting constructor to be compatible:
+ //
+ // ```dart
+ // abstract class A {
+ // factory A(int x) = B;
+ // }
+ //
+ // class B implements A {
+ // B(int x);
+ // }
+ // ```
+ static const CompileTimeErrorCode REDIRECT_TO_INVALID_FUNCTION_TYPE =
+ CompileTimeErrorCode(
+ 'REDIRECT_TO_INVALID_FUNCTION_TYPE',
+ "The redirected constructor '{0}' has incompatible parameters with '{1}'.",
+ correction: "Try redirecting to a different constructor.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the redirected constructor's return type
+ * 1: the name of the redirecting constructor's return type
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a factory constructor redirects
+ // to a constructor whose return type isn't a subtype of the type that the
+ // factory constructor is declared to produce.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `A` isn't a subclass
+ // of `C`, which means that the value returned by the constructor `A()`
+ // couldn't be returned from the constructor `C()`:
+ //
+ // ```dart
+ // class A {}
+ //
+ // class B implements C {}
+ //
+ // class C {
+ // factory C() = [!A!];
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the factory constructor is redirecting to a constructor in the wrong
+ // class, then update the factory constructor to redirect to the correct
+ // constructor:
+ //
+ // ```dart
+ // class A {}
+ //
+ // class B implements C {}
+ //
+ // class C {
+ // factory C() = B;
+ // }
+ // ```
+ //
+ // If the class defining the constructor being redirected to is the class that
+ // should be returned, then make it a subtype of the factory's return type:
+ //
+ // ```dart
+ // class A implements C {}
+ //
+ // class B implements C {}
+ //
+ // class C {
+ // factory C() = A;
+ // }
+ // ```
+ static const CompileTimeErrorCode REDIRECT_TO_INVALID_RETURN_TYPE =
+ CompileTimeErrorCode(
+ 'REDIRECT_TO_INVALID_RETURN_TYPE',
+ "The return type '{0}' of the redirected constructor isn't a subtype of '{1}'.",
+ correction: "Try redirecting to a different constructor.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * 7.6.2 Factories: It is a compile-time error if <i>k</i> is prefixed with
+ * the const modifier but <i>k'</i> is not a constant constructor.
+ */
+ static const CompileTimeErrorCode REDIRECT_TO_MISSING_CONSTRUCTOR =
+ CompileTimeErrorCode(
+ 'REDIRECT_TO_MISSING_CONSTRUCTOR',
+ "The constructor '{0}' couldn't be found in '{1}'.",
+ correction:
+ "Try redirecting to a different constructor, or define the constructor named '{0}'.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the non-type referenced in the redirect
+ */
+ // #### Description
+ //
+ // One way to implement a factory constructor is to redirect to another
+ // constructor by referencing the name of the constructor. The analyzer
+ // produces this diagnostic when the redirect is to something other than a
+ // constructor.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `f` is a function:
+ //
+ // ```dart
+ // C f() => throw 0;
+ //
+ // class C {
+ // factory C() = [!f!];
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the constructor isn't defined, then either define it or replace it with
+ // a constructor that is defined.
+ //
+ // If the constructor is defined but the class that defines it isn't visible,
+ // then you probably need to add an import.
+ //
+ // If you're trying to return the value returned by a function, then rewrite
+ // the constructor to return the value from the constructor's body:
+ //
+ // ```dart
+ // C f() => throw 0;
+ //
+ // class C {
+ // factory C() => f();
+ // }
+ // ```
+ static const CompileTimeErrorCode REDIRECT_TO_NON_CLASS =
+ CompileTimeErrorCode(
+ 'REDIRECT_TO_NON_CLASS',
+ "The name '{0}' isn't a type and can't be used in a redirected constructor.",
+ correction: "Try redirecting to a different constructor.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a constructor marked as `const`
+ // redirects to a constructor that isn't marked as `const`.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the constructor `C.a`
+ // is marked as `const` but redirects to the constructor `C.b`, which isn't:
+ //
+ // ```dart
+ // class C {
+ // const C.a() : this.[!b!]();
+ // C.b();
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the non-constant constructor can be marked as `const`, then mark it as
+ // `const`:
+ //
+ // ```dart
+ // class C {
+ // const C.a() : this.b();
+ // const C.b();
+ // }
+ // ```
+ //
+ // If the non-constant constructor can't be marked as `const`, then either
+ // remove the redirect or remove `const` from the redirecting constructor:
+ //
+ // ```dart
+ // class C {
+ // C.a() : this.b();
+ // C.b();
+ // }
+ // ```
+ static const CompileTimeErrorCode REDIRECT_TO_NON_CONST_CONSTRUCTOR =
+ CompileTimeErrorCode(
+ 'REDIRECT_TO_NON_CONST_CONSTRUCTOR',
+ "A constant redirecting constructor can't redirect to a non-constant constructor.",
+ correction: "Try redirecting to a different constructor.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a redirecting factory
+ // constructor redirects to a type alias, and the type alias expands to one of
+ // the type parameters of the type alias. This isn’t allowed because the value
+ // of the type parameter is a type rather than a class.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the redirect to `B<A>`
+ // is to a type alias whose value is `T`, even though it looks like the value
+ // should be `A`:
+ //
+ // ```dart
+ // class A implements C {}
+ //
+ // typedef B<T> = T;
+ //
+ // abstract class C {
+ // factory C() = [!B!]<A>;
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Use either a class name or a type alias that is defined to be a class
+ // rather than a type alias defined to be a type parameter:
+ //
+ // ```dart
+ // class A implements C {}
+ //
+ // abstract class C {
+ // factory C() = A;
+ // }
+ // ```
+ static const CompileTimeErrorCode
+ REDIRECT_TO_TYPE_ALIAS_EXPANDS_TO_TYPE_PARAMETER = CompileTimeErrorCode(
+ 'REDIRECT_TO_TYPE_ALIAS_EXPANDS_TO_TYPE_PARAMETER',
+ "A redirecting constructor can't redirect to a type alias that expands to a type parameter.",
+ correction: "Try replacing it with a class.",
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a variable is referenced before
+ // it’s declared. In Dart, variables are visible everywhere in the block in
+ // which they are declared, but can only be referenced after they are
+ // declared.
+ //
+ // The analyzer also produces a context message that indicates where the
+ // declaration is located.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `i` is used before it
+ // is declared:
+ //
+ // ```dart
+ // %language=2.9
+ // void f() {
+ // print([!i!]);
+ // int i = 5;
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you intended to reference the local variable, move the declaration
+ // before the first reference:
+ //
+ // ```dart
+ // %language=2.9
+ // void f() {
+ // int i = 5;
+ // print(i);
+ // }
+ // ```
+ //
+ // If you intended to reference a name from an outer scope, such as a
+ // parameter, instance field or top-level variable, then rename the local
+ // declaration so that it doesn't hide the outer variable.
+ //
+ // ```dart
+ // %language=2.9
+ // void f(int i) {
+ // print(i);
+ // int x = 5;
+ // print(x);
+ // }
+ // ```
+ static const CompileTimeErrorCode REFERENCED_BEFORE_DECLARATION =
+ CompileTimeErrorCode(
+ 'REFERENCED_BEFORE_DECLARATION',
+ "Local variable '{0}' can't be referenced before it is declared.",
+ correction:
+ "Try moving the declaration to before the first use, or renaming the local variable so that it doesn't hide a name from an enclosing scope.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a `rethrow` statement is outside
+ // a `catch` clause. The `rethrow` statement is used to throw a caught
+ // exception again, but there's no caught exception outside of a `catch`
+ // clause.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the`rethrow` statement
+ // is outside of a `catch` clause:
+ //
+ // ```dart
+ // void f() {
+ // [!rethrow!];
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you're trying to rethrow an exception, then wrap the `rethrow` statement
+ // in a `catch` clause:
+ //
+ // ```dart
+ // void f() {
+ // try {
+ // // ...
+ // } catch (exception) {
+ // rethrow;
+ // }
+ // }
+ // ```
+ //
+ // If you're trying to throw a new exception, then replace the `rethrow`
+ // statement with a `throw` expression:
+ //
+ // ```dart
+ // void f() {
+ // throw UnsupportedError('Not yet implemented');
+ // }
+ // ```
+ static const CompileTimeErrorCode RETHROW_OUTSIDE_CATCH =
+ CompileTimeErrorCode(
+ 'RETHROW_OUTSIDE_CATCH',
+ "A rethrow must be inside of a catch clause.",
+ correction:
+ "Try moving the expression into a catch clause, or using a 'throw' expression.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a generative constructor
+ // contains a `return` statement that specifies a value to be returned.
+ // Generative constructors always return the object that was created, and
+ // therefore can't return a different object.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the `return` statement
+ // has an expression:
+ //
+ // ```dart
+ // class C {
+ // C() {
+ // return [!this!];
+ // }
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the constructor should create a new instance, then remove either the
+ // `return` statement or the expression:
+ //
+ // ```dart
+ // class C {
+ // C();
+ // }
+ // ```
+ //
+ // If the constructor shouldn't create a new instance, then convert it to be a
+ // factory constructor:
+ //
+ // ```dart
+ // class C {
+ // factory C() {
+ // return _instance;
+ // }
+ //
+ // static C _instance = C._();
+ //
+ // C._();
+ // }
+ // ```
+ static const CompileTimeErrorCode RETURN_IN_GENERATIVE_CONSTRUCTOR =
+ CompileTimeErrorCode(
+ 'RETURN_IN_GENERATIVE_CONSTRUCTOR',
+ "Constructors can't return values.",
+ correction:
+ "Try removing the return statement or using a factory constructor.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a generator function (one whose
+ // body is marked with either `async*` or `sync*`) uses either a `return`
+ // statement to return a value or implicitly returns a value because of using
+ // `=>`. In any of these cases, they should use `yield` instead of `return`.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the method `f` is a
+ // generator and is using `return` to return a value:
+ //
+ // ```dart
+ // Iterable<int> f() sync* {
+ // [!return 3!];
+ // }
+ // ```
+ //
+ // The following code produces this diagnostic because the function `f` is a
+ // generator and is implicitly returning a value:
+ //
+ // ```dart
+ // Stream<int> f() async* [!=>!] 3;
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the function is using `=>` for the body of the function, then convert it
+ // to a block function body, and use `yield` to return a value:
+ //
+ // ```dart
+ // Stream<int> f() async* {
+ // yield 3;
+ // }
+ // ```
+ //
+ // If the method is intended to be a generator, then use `yield` to return a
+ // value:
+ //
+ // ```dart
+ // Iterable<int> f() sync* {
+ // yield 3;
+ // }
+ // ```
+ //
+ // If the method isn't intended to be a generator, then remove the modifier
+ // from the body (or use `async` if you're returning a future):
+ //
+ // ```dart
+ // int f() {
+ // return 3;
+ // }
+ // ```
+ static const CompileTimeErrorCode RETURN_IN_GENERATOR = CompileTimeErrorCode(
+ 'RETURN_IN_GENERATOR',
+ "Can't return a value from a generator function that uses the 'async*' or 'sync*' modifier.",
+ correction:
+ "Try replacing 'return' with 'yield', using a block function body, or changing the method body modifier.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the return type as declared in the return statement
+ * 1: the expected return type as defined by the method
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the static type of a returned
+ // expression isn't assignable to the return type that the closure is required
+ // to have.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `f` is defined to be a
+ // function that returns a `String`, but the closure assigned to it returns an
+ // `int`:
+ //
+ // ```dart
+ // String Function(String) f = (s) => [!3!];
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the return type is correct, then replace the returned value with a value
+ // of the correct type, possibly by converting the existing value:
+ //
+ // ```dart
+ // String Function(String) f = (s) => 3.toString();
+ // ```
+ static const CompileTimeErrorCode RETURN_OF_INVALID_TYPE_FROM_CLOSURE =
+ CompileTimeErrorCode(
+ 'RETURN_OF_INVALID_TYPE_FROM_CLOSURE',
+ "The return type '{0}' isn't a '{1}', as required by the closure's context.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the return type as declared in the return statement
+ * 1: the expected return type as defined by the enclosing class
+ * 2: the name of the constructor
+ */
+ static const CompileTimeErrorCode RETURN_OF_INVALID_TYPE_FROM_CONSTRUCTOR =
+ CompileTimeErrorCode(
+ 'RETURN_OF_INVALID_TYPE',
+ "A value of type '{0}' can't be returned from the constructor '{2}' because it has a return type of '{1}'.",
+ hasPublishedDocs: true,
+ uniqueName: 'RETURN_OF_INVALID_TYPE_FROM_CONSTRUCTOR',
+ );
+
+ /**
+ * Parameters:
+ * 0: the return type as declared in the return statement
+ * 1: the expected return type as defined by the method
+ * 2: the name of the method
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a method or function returns a
+ // value whose type isn't assignable to the declared return type.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `f` has a return type
+ // of `String` but is returning an `int`:
+ //
+ // ```dart
+ // String f() => [!3!];
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the return type is correct, then replace the value being returned with a
+ // value of the correct type, possibly by converting the existing value:
+ //
+ // ```dart
+ // String f() => 3.toString();
+ // ```
+ //
+ // If the value is correct, then change the return type to match:
+ //
+ // ```dart
+ // int f() => 3;
+ // ```
+ static const CompileTimeErrorCode RETURN_OF_INVALID_TYPE_FROM_FUNCTION =
+ CompileTimeErrorCode(
+ 'RETURN_OF_INVALID_TYPE',
+ "A value of type '{0}' can't be returned from the function '{2}' because it has a return type of '{1}'.",
+ hasPublishedDocs: true,
+ uniqueName: 'RETURN_OF_INVALID_TYPE_FROM_FUNCTION',
+ );
+
+ /**
+ * Parameters:
+ * 0: the return type as declared in the return statement
+ * 1: the expected return type as defined by the method
+ * 2: the name of the method
+ */
+ static const CompileTimeErrorCode RETURN_OF_INVALID_TYPE_FROM_METHOD =
+ CompileTimeErrorCode(
+ 'RETURN_OF_INVALID_TYPE',
+ "A value of type '{0}' can't be returned from the method '{2}' because it has a return type of '{1}'.",
+ hasPublishedDocs: true,
+ uniqueName: 'RETURN_OF_INVALID_TYPE_FROM_METHOD',
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when it finds a `return` statement
+ // without an expression in a function that declares a return type.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because the function `f` is
+ // expected to return an `int`, but no value is being returned:
+ //
+ // ```dart
+ // int f() {
+ // [!return!];
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Add an expression that computes the value to be returned:
+ //
+ // ```dart
+ // int f() {
+ // return 0;
+ // }
+ // ```
+ static const CompileTimeErrorCode RETURN_WITHOUT_VALUE = CompileTimeErrorCode(
+ '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 literal.",
+ correction:
+ "Try removing the keyword 'const' from the set literal or removing the keyword 'deferred' from the import.",
+ hasPublishedDocs: true,
+ uniqueName: 'SET_ELEMENT_FROM_DEFERRED_LIBRARY',
+ );
+
+ /**
+ * Parameters:
+ * 0: the actual type of the set element
+ * 1: the expected type of the set element
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an element in a set literal has
+ // a type that isn't assignable to the element type of the set.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the type of the string
+ // literal `'0'` is `String`, which isn't assignable to `int`, the element
+ // type of the set:
+ //
+ // ```dart
+ // var s = <int>{[!'0'!]};
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the element type of the set literal is wrong, then change the element
+ // type of the set:
+ //
+ // ```dart
+ // var s = <String>{'0'};
+ // ```
+ //
+ // If the type of the element is wrong, then change the element:
+ //
+ // ```dart
+ // var s = <int>{'0'.length};
+ // ```
+ static const CompileTimeErrorCode SET_ELEMENT_TYPE_NOT_ASSIGNABLE =
+ CompileTimeErrorCode(
+ 'SET_ELEMENT_TYPE_NOT_ASSIGNABLE',
+ "The element type '{0}' can't be assigned to the set type '{1}'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a prefix in a deferred import is
+ // also used as a prefix in other imports (whether deferred or not). The
+ // prefix in a deferred import can't be shared with other imports because the
+ // prefix is used to load the imported library.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the prefix `x` is used
+ // as the prefix for a deferred import and is also used for one other import:
+ //
+ // ```dart
+ // import 'dart:math' [!deferred!] as x;
+ // import 'dart:convert' as x;
+ //
+ // var y = x.json.encode(x.min(0, 1));
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you can use a different name for the deferred import, then do so:
+ //
+ // ```dart
+ // import 'dart:math' deferred as math;
+ // import 'dart:convert' as x;
+ //
+ // var y = x.json.encode(math.min(0, 1));
+ // ```
+ //
+ // If you can use a different name for the other imports, then do so:
+ //
+ // ```dart
+ // import 'dart:math' deferred as x;
+ // import 'dart:convert' as convert;
+ //
+ // var y = convert.json.encode(x.min(0, 1));
+ // ```
+ static const CompileTimeErrorCode SHARED_DEFERRED_PREFIX =
+ CompileTimeErrorCode(
+ 'SHARED_DEFERRED_PREFIX',
+ "The prefix of a deferred import can't be used in other import directives.",
+ correction: "Try renaming one of the prefixes.",
+ hasPublishedDocs: true,
+ );
+
+ static const CompileTimeErrorCode SPREAD_EXPRESSION_FROM_DEFERRED_LIBRARY =
+ CompileTimeErrorCode(
+ 'SPREAD_EXPRESSION_FROM_DEFERRED_LIBRARY',
+ "Constant values from a deferred library can't be spread into a const literal.",
+ correction: "Try making the deferred import non-deferred.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the instance member
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a class name is used to access
+ // an instance field. Instance fields don't exist on a class; they exist only
+ // on an instance of the class.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `x` is an instance
+ // field:
+ //
+ // ```dart
+ // %language=2.9
+ // class C {
+ // static int a;
+ //
+ // int b;
+ // }
+ //
+ // int f() => C.[!b!];
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you intend to access a static field, then change the name of the field
+ // to an existing static field:
+ //
+ // ```dart
+ // %language=2.9
+ // class C {
+ // static int a;
+ //
+ // int b;
+ // }
+ //
+ // int f() => C.a;
+ // ```
+ //
+ // If you intend to access the instance field, then use an instance of the
+ // class to access the field:
+ //
+ // ```dart
+ // %language=2.9
+ // class C {
+ // static int a;
+ //
+ // int b;
+ // }
+ //
+ // int f(C c) => c.b;
+ // ```
+ static const CompileTimeErrorCode STATIC_ACCESS_TO_INSTANCE_MEMBER =
+ CompileTimeErrorCode(
+ 'STATIC_ACCESS_TO_INSTANCE_MEMBER',
+ "Instance member '{0}' can't be accessed using static access.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * 7.6.1 Generative Constructors: Let <i>k</i> be a generative constructor. It
+ * is a compile-time error if a generative constructor of class Object
+ * includes a superinitializer.
+ */
+ static const CompileTimeErrorCode SUPER_INITIALIZER_IN_OBJECT =
+ CompileTimeErrorCode(
+ 'SUPER_INITIALIZER_IN_OBJECT',
+ "The class 'Object' can't invoke a constructor from a superclass.",
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a member declared inside an
+ // extension uses the `super` keyword . Extensions aren't classes and don't
+ // have superclasses, so the `super` keyword serves no purpose.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `super` can't be used
+ // in an extension:
+ //
+ // ```dart
+ // extension E on Object {
+ // String get displayString => [!super!].toString();
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Remove the `super` keyword :
+ //
+ // ```dart
+ // extension E on Object {
+ // String get displayString => toString();
+ // }
+ // ```
+ static const CompileTimeErrorCode SUPER_IN_EXTENSION = CompileTimeErrorCode(
+ 'SUPER_IN_EXTENSION',
+ "The 'super' keyword can't be used in an extension because an extension doesn't have a superclass.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the keyword `super` is used
+ // outside of a instance method.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `super` is used in a
+ // top-level function:
+ //
+ // ```dart
+ // void f() {
+ // [!super!].f();
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Rewrite the code to not use `super`.
+ static const CompileTimeErrorCode SUPER_IN_INVALID_CONTEXT =
+ CompileTimeErrorCode(
+ 'SUPER_IN_INVALID_CONTEXT',
+ "Invalid context for 'super' invocation.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a constructor that redirects to
+ // another constructor also attempts to invoke a constructor from the
+ // superclass. The superclass constructor will be invoked when the constructor
+ // that the redirecting constructor is redirected to is invoked.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the constructor `C.a`
+ // both redirects to `C.b` and invokes a constructor from the superclass:
+ //
+ // ```dart
+ // class C {
+ // C.a() : this.b(), [!super()!];
+ // C.b();
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Remove the invocation of the `super` constructor:
+ //
+ // ```dart
+ // class C {
+ // C.a() : this.b();
+ // C.b();
+ // }
+ // ```
+ static const CompileTimeErrorCode SUPER_IN_REDIRECTING_CONSTRUCTOR =
+ CompileTimeErrorCode(
+ 'SUPER_IN_REDIRECTING_CONSTRUCTOR',
+ "The redirecting constructor can't have a 'super' initializer.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * It is an error if any case of a switch statement except the last case (the
+ * default case if present) may complete normally. The previous syntactic
+ * restriction requiring the last statement of each case to be one of an
+ * enumerated list of statements (break, continue, return, throw, or rethrow)
+ * is removed.
+ */
+ static const CompileTimeErrorCode SWITCH_CASE_COMPLETES_NORMALLY =
+ CompileTimeErrorCode(
+ 'SWITCH_CASE_COMPLETES_NORMALLY',
+ "The 'case' should not complete normally.",
+ correction: "Try adding 'break', or 'return', etc.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the static type of the switch expression
+ * 1: the static type of the case expressions
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the type of the expression in a
+ // `switch` statement isn't assignable to the type of the expressions in the
+ // `case` clauses.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the type of `s`
+ // (`String`) isn't assignable to the type of `0` (`int`):
+ //
+ // ```dart
+ // %language=2.9
+ // void f(String s) {
+ // switch ([!s!]) {
+ // case 0:
+ // break;
+ // }
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the type of the `case` expressions is correct, then change the
+ // expression in the `switch` statement to have the correct type:
+ //
+ // ```dart
+ // %language=2.9
+ // void f(String s) {
+ // switch (int.parse(s)) {
+ // case 0:
+ // break;
+ // }
+ // }
+ // ```
+ //
+ // If the type of the `switch` expression is correct, then change the `case`
+ // expressions to have the correct type:
+ //
+ // ```dart
+ // %language=2.9
+ // void f(String s) {
+ // switch (s) {
+ // case '0':
+ // break;
+ // }
+ // }
+ // ```
+ static const CompileTimeErrorCode SWITCH_EXPRESSION_NOT_ASSIGNABLE =
+ CompileTimeErrorCode(
+ 'SWITCH_EXPRESSION_NOT_ASSIGNABLE',
+ "Type '{0}' of the switch expression isn't assignable to the type '{1}' of case expressions.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a generative constructor from an
+ // abstract class is being torn off. This isn't allowed because it isn't valid
+ // to create an instance of an abstract class, which means that there isn't
+ // any valid use for the torn off constructor.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the constructor `C.new`
+ // is being torn off and the class `C` is an abstract class:
+ //
+ // ```dart
+ // abstract class C {
+ // C();
+ // }
+ //
+ // void f() {
+ // [!C.new!];
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Tear off the constructor of a concrete class.
+ static const CompileTimeErrorCode
+ TEAROFF_OF_GENERATIVE_CONSTRUCTOR_OF_ABSTRACT_CLASS =
+ CompileTimeErrorCode(
+ 'TEAROFF_OF_GENERATIVE_CONSTRUCTOR_OF_ABSTRACT_CLASS',
+ "A generative constructor of an abstract class can't be torn off.",
+ correction:
+ "Try tearing off a constructor of a concrete class, or a non-generative constructor.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the type that can't be thrown
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the type of the expression in a
+ // throw expression isn't assignable to `Object`. It isn't valid to throw
+ // `null`, so it isn't valid to use an expression that might evaluate to
+ // `null`.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because `s` might be `null`:
+ //
+ // ```dart
+ // void f(String? s) {
+ // throw [!s!];
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Add an explicit null check to the expression:
+ //
+ // ```dart
+ // void f(String? s) {
+ // throw s!;
+ // }
+ // ```
+ static const CompileTimeErrorCode THROW_OF_INVALID_TYPE =
+ CompileTimeErrorCode(
+ 'THROW_OF_INVALID_TYPE',
+ "The type '{0}' of the thrown expression must be assignable to 'Object'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the element whose type could not be inferred.
+ * 1: The [TopLevelInferenceError]'s arguments that led to the cycle.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a top-level variable has no type
+ // annotation and the variable's initializer refers to the variable, either
+ // directly or indirectly.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the variables `x` and
+ // `y` are defined in terms of each other, and neither has an explicit type,
+ // so the type of the other can't be inferred:
+ //
+ // ```dart
+ // var x = y;
+ // var y = [!x!];
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the two variables don't need to refer to each other, then break the
+ // cycle:
+ //
+ // ```dart
+ // var x = 0;
+ // var y = x;
+ // ```
+ //
+ // If the two variables need to refer to each other, then give at least one of
+ // them an explicit type:
+ //
+ // ```dart
+ // int x = y;
+ // var y = x;
+ // ```
+ //
+ // Note, however, that while this code doesn't produce any diagnostics, it
+ // will produce a stack overflow at runtime unless at least one of the
+ // variables is assigned a value that doesn't depend on the other variables
+ // before any of the variables in the cycle are referenced.
+ static const CompileTimeErrorCode TOP_LEVEL_CYCLE = CompileTimeErrorCode(
+ 'TOP_LEVEL_CYCLE',
+ "The type of '{0}' can't be inferred because it depends on itself through the cycle: {1}.",
+ correction:
+ "Try adding an explicit type to one or more of the variables in the cycle in order to break the cycle.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a typedef refers to itself,
+ // either directly or indirectly.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because `F` depends on itself
+ // indirectly through `G`:
+ //
+ // ```dart
+ // typedef [!F!] = void Function(G);
+ // typedef G = void Function(F);
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Change one or more of the typedefs in the cycle so that none of them refer
+ // to themselves:
+ //
+ // ```dart
+ // typedef F = void Function(G);
+ // typedef G = void Function(int);
+ // ```
+ static const CompileTimeErrorCode TYPE_ALIAS_CANNOT_REFERENCE_ITSELF =
+ CompileTimeErrorCode(
+ 'TYPE_ALIAS_CANNOT_REFERENCE_ITSELF',
+ "Typedefs can't reference themselves directly or recursively via another typedef.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * 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 type test.",
+ correction:
+ "Try using a different type, or changing the import to not be deferred.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the type used in the instance creation that should be
+ * limited by the bound as specified in the class declaration
+ * 1: the name of the type parameter
+ * 2: the substituted bound of the type parameter
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a type argument isn't the same
+ // as or a subclass of the bounds of the corresponding type parameter.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `String` isn't a
+ // subclass of `num`:
+ //
+ // ```dart
+ // class A<E extends num> {}
+ //
+ // var a = A<[!String!]>();
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Change the type argument to be a subclass of the bounds:
+ //
+ // ```dart
+ // class A<E extends num> {}
+ //
+ // var a = A<int>();
+ // ```
+ static const CompileTimeErrorCode TYPE_ARGUMENT_NOT_MATCHING_BOUNDS =
+ CompileTimeErrorCode(
+ 'TYPE_ARGUMENT_NOT_MATCHING_BOUNDS',
+ "'{0}' doesn't conform to the bound '{2}' of the type parameter '{1}'.",
+ correction: "Try using a type that is or is a subclass of '{2}'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a static member references a
+ // type parameter that is declared for the class. Type parameters only have
+ // meaning for instances of the class.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the static method
+ // `hasType` has a reference to the type parameter `T`:
+ //
+ // ```dart
+ // class C<T> {
+ // static bool hasType(Object o) => o is [!T!];
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the member can be an instance member, then remove the keyword `static`:
+ //
+ // ```dart
+ // class C<T> {
+ // bool hasType(Object o) => o is T;
+ // }
+ // ```
+ //
+ // If the member must be a static member, then make the member be generic:
+ //
+ // ```dart
+ // class C<T> {
+ // static bool hasType<S>(Object o) => o is S;
+ // }
+ // ```
+ //
+ // Note, however, that there isn’t a relationship between `T` and `S`, so this
+ // second option changes the semantics from what was likely to be intended.
+ static const CompileTimeErrorCode TYPE_PARAMETER_REFERENCED_BY_STATIC =
+ CompileTimeErrorCode(
+ 'TYPE_PARAMETER_REFERENCED_BY_STATIC',
+ "Static members can't reference type parameters of the class.",
+ correction:
+ "Try removing the reference to the type parameter, or making the member an instance member.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the type parameter
+ * 1: the name of the bounding type
+ *
+ * See [CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS].
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the bound of a type parameter
+ // (the type following the `extends` keyword) is either directly or indirectly
+ // the type parameter itself. Stating that the type parameter must be the same
+ // as itself or a subtype of itself or a subtype of itself isn't helpful
+ // because it will always be the same as itself.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the bound of `T` is
+ // `T`:
+ //
+ // ```dart
+ // class C<[!T!] extends T> {}
+ // ```
+ //
+ // The following code produces this diagnostic because the bound of `T1` is
+ // `T2`, and the bound of `T2` is `T1`, effectively making the bound of `T1`
+ // be `T1`:
+ //
+ // ```dart
+ // class C<[!T1!] extends T2, T2 extends T1> {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the type parameter needs to be a subclass of some type, then replace the
+ // bound with the required type:
+ //
+ // ```dart
+ // class C<T extends num> {}
+ // ```
+ //
+ // If the type parameter can be any type, then remove the `extends` clause:
+ //
+ // ```dart
+ // class C<T> {}
+ // ```
+ static const CompileTimeErrorCode TYPE_PARAMETER_SUPERTYPE_OF_ITS_BOUND =
+ CompileTimeErrorCode(
+ 'TYPE_PARAMETER_SUPERTYPE_OF_ITS_BOUND',
+ "'{0}' can't be a supertype of its upper bound.",
+ correction: "Try using a type that is the same as or a subclass of '{1}'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the right-hand side of an `is`
+ // or `is!` test isn't a type.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the right-hand side is
+ // a parameter, not a type:
+ //
+ // ```dart
+ // typedef B = int Function(int);
+ //
+ // void f(Object a, B b) {
+ // if (a is [!b!]) {
+ // return;
+ // }
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you intended to use a type test, then replace the right-hand side with a
+ // type:
+ //
+ // ```dart
+ // typedef B = int Function(int);
+ //
+ // void f(Object a, B b) {
+ // if (a is B) {
+ // return;
+ // }
+ // }
+ // ```
+ //
+ // If you intended to use a different kind of test, then change the test:
+ //
+ // ```dart
+ // typedef B = int Function(int);
+ //
+ // void f(Object a, B b) {
+ // if (a == b) {
+ // return;
+ // }
+ // }
+ // ```
+ static const CompileTimeErrorCode TYPE_TEST_WITH_NON_TYPE =
+ CompileTimeErrorCode(
+ 'TYPE_TEST_WITH_NON_TYPE',
+ "The name '{0}' isn't a type and can't be used in an 'is' expression.",
+ correction: "Try correcting the name to match an existing type.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the name following the `is` in a
+ // type test expression isn't defined.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because the name `Srting` isn't
+ // defined:
+ //
+ // ```dart
+ // void f(Object o) {
+ // if (o is [!Srting!]) {
+ // // ...
+ // }
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Replace the name with the name of a type:
+ //
+ // ```dart
+ // void f(Object o) {
+ // if (o is String) {
+ // // ...
+ // }
+ // }
+ // ```
+ static const CompileTimeErrorCode TYPE_TEST_WITH_UNDEFINED_NAME =
+ CompileTimeErrorCode(
+ 'TYPE_TEST_WITH_UNDEFINED_NAME',
+ "The name '{0}' isn't defined, so it can't be used in an 'is' expression.",
+ correction:
+ "Try changing the name to the name of an existing type, or creating a type with the name '{0}'.",
+ hasPublishedDocs: true,
+ );
+
+ static const CompileTimeErrorCode UNCHECKED_INVOCATION_OF_NULLABLE_VALUE =
+ CompileTimeErrorCode(
+ 'UNCHECKED_USE_OF_NULLABLE_VALUE',
+ "The function can't be unconditionally invoked because it can be 'null'.",
+ correction: "Try adding a null check ('!').",
+ hasPublishedDocs: true,
+ uniqueName: 'UNCHECKED_INVOCATION_OF_NULLABLE_VALUE',
+ );
+
+ static const CompileTimeErrorCode
+ UNCHECKED_METHOD_INVOCATION_OF_NULLABLE_VALUE = CompileTimeErrorCode(
+ 'UNCHECKED_USE_OF_NULLABLE_VALUE',
+ "The method '{0}' can't be unconditionally invoked because the receiver can be 'null'.",
+ correction:
+ "Try making the call conditional (using '?.') or adding a null check to the target ('!').",
+ hasPublishedDocs: true,
+ uniqueName: 'UNCHECKED_METHOD_INVOCATION_OF_NULLABLE_VALUE',
+ );
+
+ static const CompileTimeErrorCode
+ UNCHECKED_OPERATOR_INVOCATION_OF_NULLABLE_VALUE = CompileTimeErrorCode(
+ 'UNCHECKED_USE_OF_NULLABLE_VALUE',
+ "The operator '{0}' can't be unconditionally invoked because the receiver can be 'null'.",
+ correction: "Try adding a null check to the target ('!').",
+ hasPublishedDocs: true,
+ uniqueName: 'UNCHECKED_OPERATOR_INVOCATION_OF_NULLABLE_VALUE',
+ );
+
+ static const CompileTimeErrorCode
+ UNCHECKED_PROPERTY_ACCESS_OF_NULLABLE_VALUE = CompileTimeErrorCode(
+ 'UNCHECKED_USE_OF_NULLABLE_VALUE',
+ "The property '{0}' can't be unconditionally accessed because the receiver can be 'null'.",
+ correction:
+ "Try making the access conditional (using '?.') or adding a null check to the target ('!').",
+ hasPublishedDocs: true,
+ uniqueName: 'UNCHECKED_PROPERTY_ACCESS_OF_NULLABLE_VALUE',
+ );
+
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an expression whose type is
+ // [potentially non-nullable][] is dereferenced without first verifying that
+ // the value isn't `null`.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because `s` can be `null` at
+ // the point where it's referenced:
+ //
+ // ```dart
+ // void f(String? s) {
+ // if (s.[!length!] > 3) {
+ // // ...
+ // }
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the value really can be `null`, then add a test to ensure that members
+ // are only accessed when the value isn't `null`:
+ //
+ // ```dart
+ // void f(String? s) {
+ // if (s != null && s.length > 3) {
+ // // ...
+ // }
+ // }
+ // ```
+ //
+ // If the expression is a variable and the value should never be `null`, then
+ // change the type of the variable to be non-nullable:
+ //
+ // ```dart
+ // void f(String s) {
+ // if (s.length > 3) {
+ // // ...
+ // }
+ // }
+ // ```
+ //
+ // If you believe that the value of the expression should never be `null`, but
+ // you can't change the type of the variable, and you're willing to risk
+ // having an exception thrown at runtime if you're wrong, then you can assert
+ // that the value isn't null:
+ //
+ // ```dart
+ // void f(String? s) {
+ // if (s!.length > 3) {
+ // // ...
+ // }
+ // }
+ // ```
+ static const CompileTimeErrorCode
+ UNCHECKED_USE_OF_NULLABLE_VALUE_AS_CONDITION = CompileTimeErrorCode(
+ 'UNCHECKED_USE_OF_NULLABLE_VALUE',
+ "A nullable expression can't be used as a condition.",
+ correction:
+ "Try checking that the value isn't 'null' before using it as a condition.",
+ hasPublishedDocs: true,
+ uniqueName: 'UNCHECKED_USE_OF_NULLABLE_VALUE_AS_CONDITION',
+ );
+
+ static const CompileTimeErrorCode
+ UNCHECKED_USE_OF_NULLABLE_VALUE_AS_ITERATOR = CompileTimeErrorCode(
+ 'UNCHECKED_USE_OF_NULLABLE_VALUE',
+ "A nullable expression can't be used as an iterator in a for-in loop.",
+ correction:
+ "Try checking that the value isn't 'null' before using it as an iterator.",
+ hasPublishedDocs: true,
+ uniqueName: 'UNCHECKED_USE_OF_NULLABLE_VALUE_AS_ITERATOR',
+ );
+
+ static const CompileTimeErrorCode UNCHECKED_USE_OF_NULLABLE_VALUE_IN_SPREAD =
+ CompileTimeErrorCode(
+ 'UNCHECKED_USE_OF_NULLABLE_VALUE',
+ "A nullable expression can't be used in a spread.",
+ correction:
+ "Try checking that the value isn't 'null' before using it in a spread, or use a null-aware spread.",
+ hasPublishedDocs: true,
+ uniqueName: 'UNCHECKED_USE_OF_NULLABLE_VALUE_IN_SPREAD',
+ );
+
+ static const CompileTimeErrorCode
+ UNCHECKED_USE_OF_NULLABLE_VALUE_IN_YIELD_EACH = CompileTimeErrorCode(
+ 'UNCHECKED_USE_OF_NULLABLE_VALUE',
+ "A nullable expression can't be used in a yield-each statement.",
+ correction:
+ "Try checking that the value isn't 'null' before using it in a yield-each statement.",
+ hasPublishedDocs: true,
+ uniqueName: 'UNCHECKED_USE_OF_NULLABLE_VALUE_IN_YIELD_EACH',
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a name that isn't defined is
+ // used as an annotation.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because the name `undefined`
+ // isn't defined:
+ //
+ // ```dart
+ // [!@undefined!]
+ // void f() {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the name is correct, but it isn’t declared yet, then declare the name as
+ // a constant value:
+ //
+ // ```dart
+ // const undefined = 'undefined';
+ //
+ // @undefined
+ // void f() {}
+ // ```
+ //
+ // If the name is wrong, replace the name with the name of a valid constant:
+ //
+ // ```dart
+ // @deprecated
+ // void f() {}
+ // ```
+ //
+ // Otherwise, remove the annotation.
+ static const CompileTimeErrorCode UNDEFINED_ANNOTATION = CompileTimeErrorCode(
+ 'UNDEFINED_ANNOTATION',
+ "Undefined name '{0}' used as an annotation.",
+ correction: "Try defining the name or importing it from another library.",
+ hasPublishedDocs: true,
+ isUnresolvedIdentifier: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the undefined class
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when it encounters an identifier that
+ // appears to be the name of a class but either isn't defined or isn't visible
+ // in the scope in which it's being referenced.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `Piont` isn't defined:
+ //
+ // ```dart
+ // class Point {}
+ //
+ // void f([!Piont!] p) {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the identifier isn't defined, then either define it or replace it with
+ // the name of a class that is defined. The example above can be corrected by
+ // fixing the spelling of the class:
+ //
+ // ```dart
+ // class Point {}
+ //
+ // void f(Point p) {}
+ // ```
+ //
+ // If the class is defined but isn't visible, then you probably need to add an
+ // import.
+ static const CompileTimeErrorCode UNDEFINED_CLASS = CompileTimeErrorCode(
+ 'UNDEFINED_CLASS',
+ "Undefined class '{0}'.",
+ correction:
+ "Try changing the name to the name of an existing class, or creating a class with the name '{0}'.",
+ hasPublishedDocs: true,
+ isUnresolvedIdentifier: true,
+ );
+
+ /**
+ * Same as [CompileTimeErrorCode.UNDEFINED_CLASS], but to catch using
+ * "boolean" instead of "bool" in order to improve the correction message.
+ *
+ * Parameters:
+ * 0: the name of the undefined class
+ */
+ static const CompileTimeErrorCode UNDEFINED_CLASS_BOOLEAN =
+ CompileTimeErrorCode(
+ 'UNDEFINED_CLASS',
+ "Undefined class '{0}'.",
+ correction: "Try using the type 'bool'.",
+ hasPublishedDocs: true,
+ isUnresolvedIdentifier: true,
+ uniqueName: 'UNDEFINED_CLASS_BOOLEAN',
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the superclass that does not define the invoked constructor
+ * 1: the name of the constructor being invoked
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a superclass constructor is
+ // invoked in the initializer list of a constructor, but the superclass
+ // doesn't define the constructor being invoked.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `A` doesn't have an
+ // unnamed constructor:
+ //
+ // ```dart
+ // class A {
+ // A.n();
+ // }
+ // class B extends A {
+ // B() : [!super()!];
+ // }
+ // ```
+ //
+ // The following code produces this diagnostic because `A` doesn't have a
+ // constructor named `m`:
+ //
+ // ```dart
+ // class A {
+ // A.n();
+ // }
+ // class B extends A {
+ // B() : [!super.m()!];
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the superclass defines a constructor that should be invoked, then change
+ // the constructor being invoked:
+ //
+ // ```dart
+ // class A {
+ // A.n();
+ // }
+ // class B extends A {
+ // B() : super.n();
+ // }
+ // ```
+ //
+ // If the superclass doesn't define an appropriate constructor, then define
+ // the constructor being invoked:
+ //
+ // ```dart
+ // class A {
+ // A.m();
+ // A.n();
+ // }
+ // class B extends A {
+ // B() : super.m();
+ // }
+ // ```
+ static const CompileTimeErrorCode UNDEFINED_CONSTRUCTOR_IN_INITIALIZER =
+ CompileTimeErrorCode(
+ 'UNDEFINED_CONSTRUCTOR_IN_INITIALIZER',
+ "The class '{0}' doesn't have a constructor named '{1}'.",
+ correction:
+ "Try defining a constructor named '{1}' in '{0}', or invoking a different constructor.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the superclass that does not define the invoked constructor
+ */
+ static const CompileTimeErrorCode
+ UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT = CompileTimeErrorCode(
+ 'UNDEFINED_CONSTRUCTOR_IN_INITIALIZER',
+ "The class '{0}' doesn't have an unnamed constructor.",
+ correction:
+ "Try defining an unnamed constructor in '{0}', or invoking a different constructor.",
+ hasPublishedDocs: true,
+ uniqueName: 'UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT',
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the enumeration constant that is not defined
+ * 1: the name of the enumeration used to access the constant
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when it encounters an identifier that
+ // appears to be the name of an enum constant, and the name either isn't
+ // defined or isn't visible in the scope in which it's being referenced.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `E` doesn't define a
+ // constant named `c`:
+ //
+ // ```dart
+ // enum E {a, b}
+ //
+ // var e = E.[!c!];
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the constant should be defined, then add it to the declaration of the
+ // enum:
+ //
+ // ```dart
+ // enum E {a, b, c}
+ //
+ // var e = E.c;
+ // ```
+ //
+ // If the constant shouldn't be defined, then change the name to the name of
+ // an existing constant:
+ //
+ // ```dart
+ // enum E {a, b}
+ //
+ // var e = E.b;
+ // ```
+ static const CompileTimeErrorCode UNDEFINED_ENUM_CONSTANT =
+ CompileTimeErrorCode(
+ 'UNDEFINED_ENUM_CONSTANT',
+ "There's no constant named '{0}' in '{1}'.",
+ correction:
+ "Try correcting the name to the name of an existing constant, or defining a constant named '{0}'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the getter that is undefined
+ * 1: the name of the extension that was explicitly specified
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an extension override is used to
+ // invoke a getter, but the getter isn't defined by the specified extension.
+ // The analyzer also produces this diagnostic when a static getter is
+ // referenced but isn't defined by the specified extension.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because the extension `E`
+ // doesn't declare an instance getter named `b`:
+ //
+ // ```dart
+ // extension E on String {
+ // String get a => 'a';
+ // }
+ //
+ // extension F on String {
+ // String get b => 'b';
+ // }
+ //
+ // void f() {
+ // E('c').[!b!];
+ // }
+ // ```
+ //
+ // The following code produces this diagnostic because the extension `E`
+ // doesn't declare a static getter named `a`:
+ //
+ // ```dart
+ // extension E on String {}
+ //
+ // var x = E.[!a!];
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the name of the getter is incorrect, then change it to the name of an
+ // existing getter:
+ //
+ // ```dart
+ // extension E on String {
+ // String get a => 'a';
+ // }
+ //
+ // extension F on String {
+ // String get b => 'b';
+ // }
+ //
+ // void f() {
+ // E('c').a;
+ // }
+ // ```
+ //
+ // If the name of the getter is correct but the name of the extension is
+ // wrong, then change the name of the extension to the correct name:
+ //
+ // ```dart
+ // extension E on String {
+ // String get a => 'a';
+ // }
+ //
+ // extension F on String {
+ // String get b => 'b';
+ // }
+ //
+ // void f() {
+ // F('c').b;
+ // }
+ // ```
+ //
+ // If the name of the getter and extension are both correct, but the getter
+ // isn't defined, then define the getter:
+ //
+ // ```dart
+ // extension E on String {
+ // String get a => 'a';
+ // String get b => 'z';
+ // }
+ //
+ // extension F on String {
+ // String get b => 'b';
+ // }
+ //
+ // void f() {
+ // E('c').b;
+ // }
+ // ```
+ static const CompileTimeErrorCode UNDEFINED_EXTENSION_GETTER =
+ CompileTimeErrorCode(
+ 'UNDEFINED_EXTENSION_GETTER',
+ "The getter '{0}' isn't defined for the extension '{1}'.",
+ correction:
+ "Try correcting the name to the name of an existing getter, or defining a getter named '{0}'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the method that is undefined
+ * 1: the name of the extension that was explicitly specified
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an extension override is used to
+ // invoke a method, but the method isn't defined by the specified extension.
+ // The analyzer also produces this diagnostic when a static method is
+ // referenced but isn't defined by the specified extension.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because the extension `E`
+ // doesn't declare an instance method named `b`:
+ //
+ // ```dart
+ // extension E on String {
+ // String a() => 'a';
+ // }
+ //
+ // extension F on String {
+ // String b() => 'b';
+ // }
+ //
+ // void f() {
+ // E('c').[!b!]();
+ // }
+ // ```
+ //
+ // The following code produces this diagnostic because the extension `E`
+ // doesn't declare a static method named `a`:
+ //
+ // ```dart
+ // extension E on String {}
+ //
+ // var x = E.[!a!]();
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the name of the method is incorrect, then change it to the name of an
+ // existing method:
+ //
+ // ```dart
+ // extension E on String {
+ // String a() => 'a';
+ // }
+ //
+ // extension F on String {
+ // String b() => 'b';
+ // }
+ //
+ // void f() {
+ // E('c').a();
+ // }
+ // ```
+ //
+ // If the name of the method is correct, but the name of the extension is
+ // wrong, then change the name of the extension to the correct name:
+ //
+ // ```dart
+ // extension E on String {
+ // String a() => 'a';
+ // }
+ //
+ // extension F on String {
+ // String b() => 'b';
+ // }
+ //
+ // void f() {
+ // F('c').b();
+ // }
+ // ```
+ //
+ // If the name of the method and extension are both correct, but the method
+ // isn't defined, then define the method:
+ //
+ // ```dart
+ // extension E on String {
+ // String a() => 'a';
+ // String b() => 'z';
+ // }
+ //
+ // extension F on String {
+ // String b() => 'b';
+ // }
+ //
+ // void f() {
+ // E('c').b();
+ // }
+ // ```
+ static const CompileTimeErrorCode UNDEFINED_EXTENSION_METHOD =
+ CompileTimeErrorCode(
+ 'UNDEFINED_EXTENSION_METHOD',
+ "The method '{0}' isn't defined for the extension '{1}'.",
+ correction:
+ "Try correcting the name to the name of an existing method, or defining a method named '{0}'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the operator that is undefined
+ * 1: the name of the extension that was explicitly specified
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an operator is invoked on a
+ // specific extension when that extension doesn't implement the operator.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the extension `E`
+ // doesn't define the operator `*`:
+ //
+ // ```dart
+ // var x = E('') [!*!] 4;
+ //
+ // extension E on String {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the extension is expected to implement the operator, then add an
+ // implementation of the operator to the extension:
+ //
+ // ```dart
+ // var x = E('') * 4;
+ //
+ // extension E on String {
+ // int operator *(int multiplier) => length * multiplier;
+ // }
+ // ```
+ //
+ // If the operator is defined by a different extension, then change the name
+ // of the extension to the name of the one that defines the operator.
+ //
+ // If the operator is defined on the argument of the extension override, then
+ // remove the extension override:
+ //
+ // ```dart
+ // var x = '' * 4;
+ //
+ // extension E on String {}
+ // ```
+ static const CompileTimeErrorCode UNDEFINED_EXTENSION_OPERATOR =
+ CompileTimeErrorCode(
+ 'UNDEFINED_EXTENSION_OPERATOR',
+ "The operator '{0}' isn't defined for the extension '{1}'.",
+ correction: "Try defining the operator '{0}'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the setter that is undefined
+ * 1: the name of the extension that was explicitly specified
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an extension override is used to
+ // invoke a setter, but the setter isn't defined by the specified extension.
+ // The analyzer also produces this diagnostic when a static setter is
+ // referenced but isn't defined by the specified extension.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because the extension `E`
+ // doesn't declare an instance setter named `b`:
+ //
+ // ```dart
+ // extension E on String {
+ // set a(String v) {}
+ // }
+ //
+ // extension F on String {
+ // set b(String v) {}
+ // }
+ //
+ // void f() {
+ // E('c').[!b!] = 'd';
+ // }
+ // ```
+ //
+ // The following code produces this diagnostic because the extension `E`
+ // doesn't declare a static setter named `a`:
+ //
+ // ```dart
+ // extension E on String {}
+ //
+ // void f() {
+ // E.[!a!] = 3;
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the name of the setter is incorrect, then change it to the name of an
+ // existing setter:
+ //
+ // ```dart
+ // extension E on String {
+ // set a(String v) {}
+ // }
+ //
+ // extension F on String {
+ // set b(String v) {}
+ // }
+ //
+ // void f() {
+ // E('c').a = 'd';
+ // }
+ // ```
+ //
+ // If the name of the setter is correct, but the name of the extension is
+ // wrong, then change the name of the extension to the correct name:
+ //
+ // ```dart
+ // extension E on String {
+ // set a(String v) {}
+ // }
+ //
+ // extension F on String {
+ // set b(String v) {}
+ // }
+ //
+ // void f() {
+ // F('c').b = 'd';
+ // }
+ // ```
+ //
+ // If the name of the setter and extension are both correct, but the setter
+ // isn't defined, then define the setter:
+ //
+ // ```dart
+ // extension E on String {
+ // set a(String v) {}
+ // set b(String v) {}
+ // }
+ //
+ // extension F on String {
+ // set b(String v) {}
+ // }
+ //
+ // void f() {
+ // E('c').b = 'd';
+ // }
+ // ```
+ static const CompileTimeErrorCode UNDEFINED_EXTENSION_SETTER =
+ CompileTimeErrorCode(
+ 'UNDEFINED_EXTENSION_SETTER',
+ "The setter '{0}' isn't defined for the extension '{1}'.",
+ correction:
+ "Try correcting the name to the name of an existing setter, or defining a setter named '{0}'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the method that is undefined
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when it encounters an identifier that
+ // appears to be the name of a function but either isn't defined or isn't
+ // visible in the scope in which it's being referenced.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because the name `emty` isn't
+ // defined:
+ //
+ // ```dart
+ // List<int> empty() => [];
+ //
+ // void main() {
+ // print([!emty!]());
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the identifier isn't defined, then either define it or replace it with
+ // the name of a function that is defined. The example above can be corrected
+ // by fixing the spelling of the function:
+ //
+ // ```dart
+ // List<int> empty() => [];
+ //
+ // void main() {
+ // print(empty());
+ // }
+ // ```
+ //
+ // If the function is defined but isn't visible, then you probably need to add
+ // an import or re-arrange your code to make the function visible.
+ static const CompileTimeErrorCode UNDEFINED_FUNCTION = CompileTimeErrorCode(
+ 'UNDEFINED_FUNCTION',
+ "The function '{0}' isn't defined.",
+ correction:
+ "Try importing the library that defines '{0}', correcting the name to the name of an existing function, or defining a function named '{0}'.",
+ hasPublishedDocs: true,
+ isUnresolvedIdentifier: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the getter
+ * 1: the name of the enclosing type where the getter is being looked for
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when it encounters an identifier that
+ // appears to be the name of a getter but either isn't defined or isn't
+ // visible in the scope in which it's being referenced.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `String` has no member
+ // named `len`:
+ //
+ // ```dart
+ // int f(String s) => s.[!len!];
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the identifier isn't defined, then either define it or replace it with
+ // the name of a getter that is defined. The example above can be corrected by
+ // fixing the spelling of the getter:
+ //
+ // ```dart
+ // int f(String s) => s.length;
+ // ```
+ static const CompileTimeErrorCode UNDEFINED_GETTER = CompileTimeErrorCode(
+ 'UNDEFINED_GETTER',
+ "The getter '{0}' isn't defined for the type '{1}'.",
+ correction:
+ "Try importing the library that defines '{0}', correcting the name to the name of an existing getter, or defining a getter or field named '{0}'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the getter
+ * 1: the name of the function type alias
+ */
+ static const CompileTimeErrorCode UNDEFINED_GETTER_ON_FUNCTION_TYPE =
+ CompileTimeErrorCode(
+ 'UNDEFINED_GETTER',
+ "The getter '{0}' isn't defined for the '{1}' function type.",
+ correction:
+ "Try wrapping the function type alias in parentheses in order to access '{0}' as an extension getter on 'Type'.",
+ hasPublishedDocs: true,
+ uniqueName: 'UNDEFINED_GETTER_ON_FUNCTION_TYPE',
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the identifier
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when it encounters an identifier that
+ // either isn't defined or isn't visible in the scope in which it's being
+ // referenced.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because the name `rihgt` isn't
+ // defined:
+ //
+ // ```dart
+ // int min(int left, int right) => left <= [!rihgt!] ? left : right;
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the identifier isn't defined, then either define it or replace it with
+ // an identifier that is defined. The example above can be corrected by
+ // fixing the spelling of the variable:
+ //
+ // ```dart
+ // int min(int left, int right) => left <= right ? left : right;
+ // ```
+ //
+ // If the identifier is defined but isn't visible, then you probably need to
+ // add an import or re-arrange your code to make the identifier visible.
+ static const CompileTimeErrorCode UNDEFINED_IDENTIFIER = CompileTimeErrorCode(
+ 'UNDEFINED_IDENTIFIER',
+ "Undefined name '{0}'.",
+ correction:
+ "Try correcting the name to one that is defined, or defining the name.",
+ hasPublishedDocs: true,
+ isUnresolvedIdentifier: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the name `await` is used in a
+ // method or function body without being declared, and the body isn't marked
+ // with the `async` keyword. The name `await` only introduces an await
+ // expression in an asynchronous function.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the name `await` is
+ // used in the body of `f` even though the body of `f` isn't marked with the
+ // `async` keyword:
+ //
+ // ```dart
+ // void f(p) { [!await!] p; }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Add the keyword `async` to the function body:
+ //
+ // ```dart
+ // void f(p) async { await p; }
+ // ```
+ static const CompileTimeErrorCode UNDEFINED_IDENTIFIER_AWAIT =
+ CompileTimeErrorCode(
+ 'UNDEFINED_IDENTIFIER_AWAIT',
+ "Undefined name 'await' in function body not marked with 'async'.",
+ correction:
+ "Try correcting the name to one that is defined, defining the name, or adding 'async' to the enclosing function body.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the method that is undefined
+ * 1: the resolved type name that the method lookup is happening on
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when it encounters an identifier that
+ // appears to be the name of a method but either isn't defined or isn't
+ // visible in the scope in which it's being referenced.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because the identifier
+ // `removeMiddle` isn't defined:
+ //
+ // ```dart
+ // int f(List<int> l) => l.[!removeMiddle!]();
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the identifier isn't defined, then either define it or replace it with
+ // the name of a method that is defined. The example above can be corrected by
+ // fixing the spelling of the method:
+ //
+ // ```dart
+ // int f(List<int> l) => l.removeLast();
+ // ```
+ static const CompileTimeErrorCode UNDEFINED_METHOD = CompileTimeErrorCode(
+ 'UNDEFINED_METHOD',
+ "The method '{0}' isn't defined for the type '{1}'.",
+ correction:
+ "Try correcting the name to the name of an existing method, or defining a method named '{0}'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the method
+ * 1: the name of the function type alias
+ */
+ static const CompileTimeErrorCode UNDEFINED_METHOD_ON_FUNCTION_TYPE =
+ CompileTimeErrorCode(
+ 'UNDEFINED_METHOD',
+ "The method '{0}' isn't defined for the '{1}' function type.",
+ correction:
+ "Try wrapping the function type alias in parentheses in order to access '{0}' as an extension method on 'Type'.",
+ hasPublishedDocs: true,
+ uniqueName: 'UNDEFINED_METHOD_ON_FUNCTION_TYPE',
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the requested named parameter
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a method or function invocation
+ // has a named argument, but the method or function being invoked doesn't
+ // define a parameter with the same name.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `m` doesn't declare a
+ // named parameter named `a`:
+ //
+ // ```dart
+ // %language=2.9
+ // class C {
+ // m({int b}) {}
+ // }
+ //
+ // void f(C c) {
+ // c.m([!a!]: 1);
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the argument name is mistyped, then replace it with the correct name.
+ // The example above can be fixed by changing `a` to `b`:
+ //
+ // ```dart
+ // %language=2.9
+ // class C {
+ // m({int b}) {}
+ // }
+ //
+ // void f(C c) {
+ // c.m(b: 1);
+ // }
+ // ```
+ //
+ // If a subclass adds a parameter with the name in question, then cast the
+ // receiver to the subclass:
+ //
+ // ```dart
+ // %language=2.9
+ // class C {
+ // m({int b}) {}
+ // }
+ //
+ // class D extends C {
+ // m({int a, int b}) {}
+ // }
+ //
+ // void f(C c) {
+ // (c as D).m(a: 1);
+ // }
+ // ```
+ //
+ // If the parameter should be added to the function, then add it:
+ //
+ // ```dart
+ // %language=2.9
+ // class C {
+ // m({int a, int b}) {}
+ // }
+ //
+ // void f(C c) {
+ // c.m(a: 1);
+ // }
+ // ```
+ static const CompileTimeErrorCode UNDEFINED_NAMED_PARAMETER =
+ CompileTimeErrorCode(
+ 'UNDEFINED_NAMED_PARAMETER',
+ "The named parameter '{0}' isn't defined.",
+ correction:
+ "Try correcting the name to an existing named parameter's name, or defining a named parameter with the name '{0}'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the operator
+ * 1: the name of the enclosing type where the operator is being looked for
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a user-definable operator is
+ // invoked on an object for which the operator isn't defined.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because the class `C` doesn't
+ // define the operator `+`:
+ //
+ // ```dart
+ // class C {}
+ //
+ // C f(C c) => c [!+!] 2;
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the operator should be defined for the class, then define it:
+ //
+ // ```dart
+ // class C {
+ // C operator +(int i) => this;
+ // }
+ //
+ // C f(C c) => c + 2;
+ // ```
+ static const CompileTimeErrorCode UNDEFINED_OPERATOR = CompileTimeErrorCode(
+ 'UNDEFINED_OPERATOR',
+ "The operator '{0}' isn't defined for the type '{1}'.",
+ correction: "Try defining the operator '{0}'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a prefixed identifier is found
+ // where the prefix is valid, but the identifier isn't declared in any of the
+ // libraries imported using that prefix.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `dart:core` doesn't
+ // define anything named `a`:
+ //
+ // ```dart
+ // import 'dart:core' as p;
+ //
+ // void f() {
+ // p.[!a!];
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the library in which the name is declared isn't imported yet, add an
+ // import for the library.
+ //
+ // If the name is wrong, then change it to one of the names that's declared in
+ // the imported libraries.
+ static const CompileTimeErrorCode UNDEFINED_PREFIXED_NAME =
+ CompileTimeErrorCode(
+ 'UNDEFINED_PREFIXED_NAME',
+ "The name '{0}' is being referenced through the prefix '{1}', but it isn't defined in any of the libraries imported using that prefix.",
+ correction:
+ "Try correcting the prefix or importing the library that defines '{0}'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the setter
+ * 1: the name of the enclosing type where the setter is being looked for
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when it encounters an identifier that
+ // appears to be the name of a setter but either isn't defined or isn't
+ // visible in the scope in which the identifier is being referenced.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because there isn't a setter
+ // named `z`:
+ //
+ // ```dart
+ // class C {
+ // int x = 0;
+ // void m(int y) {
+ // this.[!z!] = y;
+ // }
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the identifier isn't defined, then either define it or replace it with
+ // the name of a setter that is defined. The example above can be corrected by
+ // fixing the spelling of the setter:
+ //
+ // ```dart
+ // class C {
+ // int x = 0;
+ // void m(int y) {
+ // this.x = y;
+ // }
+ // }
+ // ```
+ static const CompileTimeErrorCode UNDEFINED_SETTER = CompileTimeErrorCode(
+ 'UNDEFINED_SETTER',
+ "The setter '{0}' isn't defined for the type '{1}'.",
+ correction:
+ "Try importing the library that defines '{0}', correcting the name to the name of an existing setter, or defining a setter or field named '{0}'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the setter
+ * 1: the name of the function type alias
+ */
+ static const CompileTimeErrorCode UNDEFINED_SETTER_ON_FUNCTION_TYPE =
+ CompileTimeErrorCode(
+ 'UNDEFINED_SETTER',
+ "The setter '{0}' isn't defined for the '{1}' function type.",
+ correction:
+ "Try wrapping the function type alias in parentheses in order to access '{0}' as an extension getter on 'Type'.",
+ hasPublishedDocs: true,
+ uniqueName: 'UNDEFINED_SETTER_ON_FUNCTION_TYPE',
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the getter
+ * 1: the name of the enclosing type where the getter is being looked for
+ */
+ static const CompileTimeErrorCode UNDEFINED_SUPER_GETTER =
+ CompileTimeErrorCode(
+ 'UNDEFINED_SUPER_MEMBER',
+ "The getter '{0}' isn't defined in a superclass of '{1}'.",
+ correction:
+ "Try correcting the name to the name of an existing getter, or defining a getter or field named '{0}' in a superclass.",
+ hasPublishedDocs: true,
+ uniqueName: 'UNDEFINED_SUPER_GETTER',
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the method that is undefined
+ * 1: the resolved type name that the method lookup is happening on
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an inherited member (method,
+ // getter, setter, or operator) is referenced using `super`, but there’s no
+ // member with that name in the superclass chain.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `Object` doesn't define
+ // a method named `n`:
+ //
+ // ```dart
+ // class C {
+ // void m() {
+ // super.[!n!]();
+ // }
+ // }
+ // ```
+ //
+ // The following code produces this diagnostic because `Object` doesn't define
+ // a getter named `g`:
+ //
+ // ```dart
+ // class C {
+ // void m() {
+ // super.[!g!];
+ // }
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the inherited member you intend to invoke has a different name, then
+ // make the name of the invoked member match the inherited member.
+ //
+ // If the member you intend to invoke is defined in the same class, then
+ // remove the `super.`.
+ //
+ // If the member isn’t defined, then either add the member to one of the
+ // superclasses or remove the invocation.
+ static const CompileTimeErrorCode UNDEFINED_SUPER_METHOD =
+ CompileTimeErrorCode(
+ 'UNDEFINED_SUPER_MEMBER',
+ "The method '{0}' isn't defined in a superclass of '{1}'.",
+ correction:
+ "Try correcting the name to the name of an existing method, or defining a method named '{0}' in a superclass.",
+ hasPublishedDocs: true,
+ uniqueName: 'UNDEFINED_SUPER_METHOD',
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the operator
+ * 1: the name of the enclosing type where the operator is being looked for
+ */
+ static const CompileTimeErrorCode UNDEFINED_SUPER_OPERATOR =
+ CompileTimeErrorCode(
+ 'UNDEFINED_SUPER_MEMBER',
+ "The operator '{0}' isn't defined in a superclass of '{1}'.",
+ correction: "Try defining the operator '{0}' in a superclass.",
+ hasPublishedDocs: true,
+ uniqueName: 'UNDEFINED_SUPER_OPERATOR',
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the setter
+ * 1: the name of the enclosing type where the setter is being looked for
+ */
+ static const CompileTimeErrorCode UNDEFINED_SUPER_SETTER =
+ CompileTimeErrorCode(
+ 'UNDEFINED_SUPER_MEMBER',
+ "The setter '{0}' isn't defined in a superclass of '{1}'.",
+ correction:
+ "Try correcting the name to the name of an existing setter, or defining a setter or field named '{0}' in a superclass.",
+ hasPublishedDocs: true,
+ uniqueName: 'UNDEFINED_SUPER_SETTER',
+ );
+
+ /**
+ * This is a specialization of [INSTANCE_ACCESS_TO_STATIC_MEMBER] that is used
+ * when we are able to find the name defined in a supertype. It exists to
+ * provide a more informative error message.
+ *
+ * Parameters:
+ * 0: the name of the defining type
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when code in one class references a
+ // static member in a superclass without prefixing the member's name with the
+ // name of the superclass. Static members can only be referenced without a
+ // prefix in the class in which they're declared.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the static field `x` is
+ // referenced in the getter `g` without prefixing it with the name of the
+ // defining class:
+ //
+ // ```dart
+ // class A {
+ // static int x = 3;
+ // }
+ //
+ // class B extends A {
+ // int get g => [!x!];
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Prefix the name of the static member with the name of the declaring class:
+ //
+ // ```dart
+ // class A {
+ // static int x = 3;
+ // }
+ //
+ // class B extends A {
+ // int get g => A.x;
+ // }
+ // ```
+ static const CompileTimeErrorCode
+ UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER = CompileTimeErrorCode(
+ 'UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER',
+ "Static members from supertypes must be qualified by the name of the defining type.",
+ correction: "Try adding '{0}.' before the name.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the defining type
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an undefined name is found, and
+ // the name is the same as a static member of the extended type or one of its
+ // superclasses.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `m` is a static member
+ // of the extended type `C`:
+ //
+ // ```dart
+ // class C {
+ // static void m() {}
+ // }
+ //
+ // extension E on C {
+ // void f() {
+ // [!m!]();
+ // }
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you're trying to reference a static member that's declared outside the
+ // extension, then add the name of the class or extension before the reference
+ // to the member:
+ //
+ // ```dart
+ // class C {
+ // static void m() {}
+ // }
+ //
+ // extension E on C {
+ // void f() {
+ // C.m();
+ // }
+ // }
+ // ```
+ //
+ // If you're referencing a member that isn't declared yet, add a declaration:
+ //
+ // ```dart
+ // class C {
+ // static void m() {}
+ // }
+ //
+ // extension E on C {
+ // void f() {
+ // m();
+ // }
+ //
+ // void m() {}
+ // }
+ // ```
+ static const CompileTimeErrorCode
+ UNQUALIFIED_REFERENCE_TO_STATIC_MEMBER_OF_EXTENDED_TYPE =
+ CompileTimeErrorCode(
+ 'UNQUALIFIED_REFERENCE_TO_STATIC_MEMBER_OF_EXTENDED_TYPE',
+ "Static members from the extended type or one of its superclasses must be qualified by the name of the defining type.",
+ correction: "Try adding '{0}.' before the name.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the URI pointing to a non-existent file
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an import, export, or part
+ // directive is found where the URI refers to a file that doesn't exist.
+ //
+ // #### Examples
+ //
+ // If the file `lib.dart` doesn't exist, the following code produces this
+ // diagnostic:
+ //
+ // ```dart
+ // import [!'lib.dart'!];
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the URI was mistyped or invalid, then correct the URI.
+ //
+ // If the URI is correct, then create the file.
+ static const CompileTimeErrorCode URI_DOES_NOT_EXIST = CompileTimeErrorCode(
+ 'URI_DOES_NOT_EXIST',
+ "Target of URI doesn't exist: '{0}'.",
+ correction:
+ "Try creating the file referenced by the URI, or Try using a URI for a file that does exist.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the URI pointing to a non-existent file
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an import, export, or part
+ // directive is found where the URI refers to a file that doesn't exist and
+ // the name of the file ends with a pattern that's commonly produced by code
+ // generators, such as one of the following:
+ // - `.g.dart`
+ // - `.pb.dart`
+ // - `.pbenum.dart`
+ // - `.pbserver.dart`
+ // - `.pbjson.dart`
+ // - `.template.dart`
+ //
+ // #### Examples
+ //
+ // If the file `lib.g.dart` doesn't exist, the following code produces this
+ // diagnostic:
+ //
+ // ```dart
+ // import [!'lib.g.dart'!];
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the file is a generated file, then run the generator that generates the
+ // file.
+ //
+ // If the file isn't a generated file, then check the spelling of the URI or
+ // create the file.
+ static const CompileTimeErrorCode URI_HAS_NOT_BEEN_GENERATED =
+ CompileTimeErrorCode(
+ 'URI_HAS_NOT_BEEN_GENERATED',
+ "Target of URI hasn't been generated: '{0}'.",
+ correction:
+ "Try running the generator that will generate the file referenced by the URI.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the string literal in an
+ // `import`, `export`, or `part` directive contains an interpolation. The
+ // resolution of the URIs in directives must happen before the declarations
+ // are compiled, so expressions can’t be evaluated while determining the
+ // values of the URIs.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the string in the
+ // `import` directive contains an interpolation:
+ //
+ // ```dart
+ // import [!'dart:$m'!];
+ //
+ // const m = 'math';
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Remove the interpolation from the URI:
+ //
+ // ```dart
+ // import 'dart:math';
+ //
+ // var zero = min(0, 0);
+ // ```
+ static const CompileTimeErrorCode URI_WITH_INTERPOLATION =
+ CompileTimeErrorCode(
+ 'URI_WITH_INTERPOLATION',
+ "URIs can't use string interpolation.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when it finds an expression whose
+ // type is `void`, and the expression is used in a place where a value is
+ // expected, such as before a member access or on the right-hand side of an
+ // assignment.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `f` doesn't produce an
+ // object on which `toString` can be invoked:
+ //
+ // ```dart
+ // void f() {}
+ //
+ // void g() {
+ // [!f()!].toString();
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Either rewrite the code so that the expression has a value or rewrite the
+ // code so that it doesn't depend on the value.
+ static const CompileTimeErrorCode USE_OF_VOID_RESULT = CompileTimeErrorCode(
+ 'USE_OF_VOID_RESULT',
+ "This expression has a type of 'void' so its value can't be used.",
+ correction:
+ "Try checking to see if you're using the correct API; there might be a function or call that returns void you didn't expect. Also check type parameters and variables which might also be void.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the type of the object being assigned.
+ * 1: the type of the variable being assigned to
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the evaluation of a constant
+ // expression would result in a `CastException`.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because the value of `x` is an
+ // `int`, which can't be assigned to `y` because an `int` isn't a `String`:
+ //
+ // ```dart
+ // %language=2.9
+ // const Object x = 0;
+ // const String y = [!x!];
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the declaration of the constant is correct, then change the value being
+ // assigned to be of the correct type:
+ //
+ // ```dart
+ // %language=2.9
+ // const Object x = 0;
+ // const String y = '$x';
+ // ```
+ //
+ // If the assigned value is correct, then change the declaration to have the
+ // correct type:
+ //
+ // ```dart
+ // %language=2.9
+ // const Object x = 0;
+ // const int y = x;
+ // ```
+ static const CompileTimeErrorCode VARIABLE_TYPE_MISMATCH =
+ CompileTimeErrorCode(
+ 'VARIABLE_TYPE_MISMATCH',
+ "A value of type '{0}' can't be assigned to a const variable of type '{1}'.",
+ correction: "Try using a subtype, or removing the 'const' keyword",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Let `C` be a generic class that declares a formal type parameter `X`, and
+ * assume that `T` is a direct superinterface of `C`.
+ *
+ * It is a compile-time error if `X` is explicitly defined as a covariant or
+ * 'in' type parameter and `X` occurs in a non-covariant position in `T`.
+ * It is a compile-time error if `X` is explicitly defined as a contravariant
+ * or 'out' type parameter and `X` occurs in a non-contravariant position in
+ * `T`.
+ *
+ * Parameters:
+ * 0: the name of the type parameter
+ * 1: the variance modifier defined for {0}
+ * 2: the variance position of the type parameter {0} in the
+ * superinterface {3}
+ * 3: the name of the superinterface
+ */
+ static const CompileTimeErrorCode
+ WRONG_EXPLICIT_TYPE_PARAMETER_VARIANCE_IN_SUPERINTERFACE =
+ CompileTimeErrorCode(
+ 'WRONG_EXPLICIT_TYPE_PARAMETER_VARIANCE_IN_SUPERINTERFACE',
+ "'{0}' is an '{1}' type parameter and can't be used in an '{2}' position in '{3}'.",
+ correction:
+ "Try using 'in' type parameters in 'in' positions and 'out' type parameters in 'out' positions in the superinterface.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the declared operator
+ * 1: the number of parameters expected
+ * 2: the number of parameters found in the operator declaration
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a declaration of an operator has
+ // the wrong number of parameters.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because the operator `+` must
+ // have a single parameter corresponding to the right operand:
+ //
+ // ```dart
+ // class C {
+ // int operator [!+!](a, b) => 0;
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Add or remove parameters to match the required number:
+ //
+ // ```dart
+ // class C {
+ // int operator +(a) => 0;
+ // }
+ // ```
+ // TODO(brianwilkerson) It would be good to add a link to the spec or some
+ // other documentation that lists the number of parameters for each operator,
+ // but I don't know what to link to.
+ static const CompileTimeErrorCode WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR =
+ CompileTimeErrorCode(
+ 'WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR',
+ "Operator '{0}' should declare exactly {1} parameters, but {2} found.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * 7.1.1 Operators: It is a compile time error if the arity of the
+ * user-declared operator - is not 0 or 1.
+ *
+ * Parameters:
+ * 0: the number of parameters found in the operator declaration
+ */
+ static const CompileTimeErrorCode
+ WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR_MINUS = CompileTimeErrorCode(
+ 'WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR',
+ "Operator '-' should declare 0 or 1 parameter, but {0} found.",
+ hasPublishedDocs: true,
+ uniqueName: 'WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR_MINUS',
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a setter is found that doesn't
+ // declare exactly one required positional parameter.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because the setter `s` declares
+ // two required parameters:
+ //
+ // ```dart
+ // %language=2.9
+ // class C {
+ // set [!s!](int x, int y) {}
+ // }
+ // ```
+ //
+ // The following code produces this diagnostic because the setter `s` declares
+ // one optional parameter:
+ //
+ // ```dart
+ // %language=2.9
+ // class C {
+ // set [!s!]([int x]) {}
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Change the declaration so that there's exactly one required positional
+ // parameter:
+ //
+ // ```dart
+ // %language=2.9
+ // class C {
+ // set s(int x) {}
+ // }
+ // ```
+ static const CompileTimeErrorCode WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER =
+ CompileTimeErrorCode(
+ 'WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER',
+ "Setters must declare exactly one required positional parameter.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the type being referenced (<i>G</i>)
+ * 1: the number of type parameters that were declared
+ * 2: the number of type arguments provided
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a type that has type parameters
+ // is used and type arguments are provided, but the number of type arguments
+ // isn't the same as the number of type parameters.
+ //
+ // The analyzer also produces this diagnostic when a constructor is invoked
+ // and the number of type arguments doesn't match the number of type
+ // parameters declared for the class.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because `C` has one type
+ // parameter but two type arguments are provided when it is used as a type
+ // annotation:
+ //
+ // ```dart
+ // class C<E> {}
+ //
+ // void f([!C<int, int>!] x) {}
+ // ```
+ //
+ // The following code produces this diagnostic because `C` declares one type
+ // parameter, but two type arguments are provided when creating an instance:
+ //
+ // ```dart
+ // class C<E> {}
+ //
+ // var c = [!C<int, int>!]();
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Add or remove type arguments, as necessary, to match the number of type
+ // parameters defined for the type:
+ //
+ // ```dart
+ // class C<E> {}
+ //
+ // void f(C<int> x) {}
+ // ```
+ static const CompileTimeErrorCode WRONG_NUMBER_OF_TYPE_ARGUMENTS =
+ CompileTimeErrorCode(
+ 'WRONG_NUMBER_OF_TYPE_ARGUMENTS',
+ "The type '{0}' is declared with {1} type parameters, but {2} type arguments were given.",
+ correction:
+ "Try adjusting the number of type arguments to match the number of type parameters.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the number of type parameters that were declared
+ * 1: the number of type arguments provided
+ */
+ static const CompileTimeErrorCode
+ WRONG_NUMBER_OF_TYPE_ARGUMENTS_ANONYMOUS_FUNCTION = CompileTimeErrorCode(
+ 'WRONG_NUMBER_OF_TYPE_ARGUMENTS_FUNCTION',
+ "This function is declared with {0} type parameters, but {1} type arguments were given.",
+ correction:
+ "Try adjusting the number of type arguments to match the number of type parameters.",
+ uniqueName: 'WRONG_NUMBER_OF_TYPE_ARGUMENTS_ANONYMOUS_FUNCTION',
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the class being instantiated
+ * 1: the name of the constructor being invoked
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when type arguments are provided
+ // after the name of a named constructor. Constructors can't declare type
+ // parameters, so invocations can only provide the type arguments associated
+ // with the class, and those type arguments are required to follow the name of
+ // the class rather than the name of the constructor.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the type parameters
+ // (`<String>`) follow the name of the constructor rather than the name of the
+ // class:
+ //
+ // ```dart
+ // class C<T> {
+ // C.named();
+ // }
+ // C f() => C.named[!<String>!]();
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the type arguments are for the class' type parameters, then move the
+ // type arguments to follow the class name:
+ //
+ // ```dart
+ // class C<T> {
+ // C.named();
+ // }
+ // C f() => C<String>.named();
+ // ```
+ //
+ // If the type arguments aren't for the class' type parameters, then remove
+ // them:
+ //
+ // ```dart
+ // class C<T> {
+ // C.named();
+ // }
+ // C f() => C.named();
+ // ```
+ static const CompileTimeErrorCode WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR =
+ CompileTimeErrorCode(
+ 'WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR',
+ "The constructor '{0}.{1}' doesn't have type parameters.",
+ correction: "Try moving type arguments to after the type name.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the extension being referenced
+ * 1: the number of type parameters that were declared
+ * 2: the number of type arguments provided
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an extension that has type
+ // parameters is used and type arguments are provided, but the number of type
+ // arguments isn't the same as the number of type parameters.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the extension `E` is
+ // declared to have a single type parameter (`T`), but the extension override
+ // has two type arguments:
+ //
+ // ```dart
+ // extension E<T> on List<T> {
+ // int get len => length;
+ // }
+ //
+ // void f(List<int> p) {
+ // E[!<int, String>!](p).len;
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Change the type arguments so that there are the same number of type
+ // arguments as there are type parameters:
+ //
+ // ```dart
+ // extension E<T> on List<T> {
+ // int get len => length;
+ // }
+ //
+ // void f(List<int> p) {
+ // E<int>(p).len;
+ // }
+ // ```
+ static const CompileTimeErrorCode WRONG_NUMBER_OF_TYPE_ARGUMENTS_EXTENSION =
+ CompileTimeErrorCode(
+ 'WRONG_NUMBER_OF_TYPE_ARGUMENTS_EXTENSION',
+ "The extension '{0}' is declared with {1} type parameters, but {2} type arguments were given.",
+ correction: "Try adjusting the number of type arguments.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the function being referenced
+ * 1: the number of type parameters that were declared
+ * 2: the number of type arguments provided
+ */
+ static const CompileTimeErrorCode WRONG_NUMBER_OF_TYPE_ARGUMENTS_FUNCTION =
+ CompileTimeErrorCode(
+ 'WRONG_NUMBER_OF_TYPE_ARGUMENTS_FUNCTION',
+ "The function '{0}' is declared with {1} type parameters, but {2} type arguments were given.",
+ correction:
+ "Try adjusting the number of type arguments to match the number of type parameters.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the method being referenced (<i>G</i>)
+ * 1: the number of type parameters that were declared
+ * 2: the number of type arguments provided
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a method or function is invoked
+ // with a different number of type arguments than the number of type
+ // parameters specified in its declaration. There must either be no type
+ // arguments or the number of arguments must match the number of parameters.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the invocation of the
+ // method `m` has two type arguments, but the declaration of `m` only has one
+ // type parameter:
+ //
+ // ```dart
+ // class C {
+ // int m<A>(A a) => 0;
+ // }
+ //
+ // int f(C c) => c.m[!<int, int>!](2);
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the type arguments are necessary, then make them match the number of
+ // type parameters by either adding or removing type arguments:
+ //
+ // ```dart
+ // class C {
+ // int m<A>(A a) => 0;
+ // }
+ //
+ // int f(C c) => c.m<int>(2);
+ // ```
+ //
+ // If the type arguments aren't necessary, then remove them:
+ //
+ // ```dart
+ // class C {
+ // int m<A>(A a) => 0;
+ // }
+ //
+ // int f(C c) => c.m(2);
+ // ```
+ static const CompileTimeErrorCode WRONG_NUMBER_OF_TYPE_ARGUMENTS_METHOD =
+ CompileTimeErrorCode(
+ 'WRONG_NUMBER_OF_TYPE_ARGUMENTS_METHOD',
+ "The method '{0}' is declared with {1} type parameters, but {2} type arguments are given.",
+ correction: "Try adjusting the number of type arguments.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Let `C` be a generic class that declares a formal type parameter `X`, and
+ * assume that `T` is a direct superinterface of `C`. It is a compile-time
+ * error if `X` occurs contravariantly or invariantly in `T`.
+ */
+ static const CompileTimeErrorCode
+ WRONG_TYPE_PARAMETER_VARIANCE_IN_SUPERINTERFACE = CompileTimeErrorCode(
+ 'WRONG_TYPE_PARAMETER_VARIANCE_IN_SUPERINTERFACE',
+ "'{0}' can't be used contravariantly or invariantly in '{1}'.",
+ correction:
+ "Try not using class type parameters in types of formal parameters of function types, nor in explicitly contravariant or invariant superinterfaces.",
+ );
+
+ /**
+ * Let `C` be a generic class that declares a formal type parameter `X`.
+ *
+ * If `X` is explicitly contravariant then it is a compile-time error for
+ * `X` to occur in a non-contravariant position in a member signature in the
+ * body of `C`, except when `X` is in a contravariant position in the type
+ * annotation of a covariant formal parameter.
+ *
+ * If `X` is explicitly covariant then it is a compile-time error for
+ * `X` to occur in a non-covariant position in a member signature in the
+ * body of `C`, except when `X` is in a covariant position in the type
+ * annotation of a covariant formal parameter.
+ *
+ * Parameters:
+ * 0: the variance modifier defined for {0}
+ * 1: the name of the type parameter
+ * 2: the variance position that the type parameter {1} is in
+ */
+ static const CompileTimeErrorCode WRONG_TYPE_PARAMETER_VARIANCE_POSITION =
+ CompileTimeErrorCode(
+ 'WRONG_TYPE_PARAMETER_VARIANCE_POSITION',
+ "The '{0}' type parameter '{1}' can't be used in an '{2}' position.",
+ correction:
+ "Try removing the type parameter or change the explicit variance modifier declaration for the type parameter to another one of 'in', 'out', or 'inout'.",
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a `yield` or `yield*` statement
+ // appears in a function whose body isn't marked with one of the `async*` or
+ // `sync*` modifiers.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because `yield` is being used
+ // in a function whose body doesn't have a modifier:
+ //
+ // ```dart
+ // Iterable<int> get digits {
+ // yield* [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
+ // }
+ // ```
+ //
+ // The following code produces this diagnostic because `yield*` is being used
+ // in a function whose body has the `async` modifier rather than the `async*`
+ // modifier:
+ //
+ // ```dart
+ // Stream<int> get digits async {
+ // yield* [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Add a modifier, or change the existing modifier to be either `async*` or
+ // `sync*`:
+ //
+ // ```dart
+ // Iterable<int> get digits sync* {
+ // yield* [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
+ // }
+ // ```
+ static const CompileTimeErrorCode YIELD_EACH_IN_NON_GENERATOR =
+ CompileTimeErrorCode(
+ 'YIELD_IN_NON_GENERATOR',
+ "Yield-each statements must be in a generator function (one marked with either 'async*' or 'sync*').",
+ correction: "Try adding 'async*' or 'sync*' to the enclosing function.",
+ hasPublishedDocs: true,
+ uniqueName: 'YIELD_EACH_IN_NON_GENERATOR',
+ );
+
+ /**
+ * ?? Yield: It is a compile-time error if a yield statement appears in a
+ * function that is not a generator function.
+ *
+ * No parameters.
+ */
+ static const CompileTimeErrorCode YIELD_IN_NON_GENERATOR =
+ CompileTimeErrorCode(
+ 'YIELD_IN_NON_GENERATOR',
+ "Yield statements must be in a generator function (one marked with either 'async*' or 'sync*').",
+ correction: "Try adding 'async*' or 'sync*' to the enclosing function.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the type of the expression after `yield`
+ * 1: the return type of the function containing the `yield`
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the type of object produced by a
+ // `yield` expression doesn't match the type of objects that are to be
+ // returned from the `Iterable` or `Stream` types that are returned from a
+ // generator (a function or method marked with either `sync*` or `async*`).
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the getter `zero` is
+ // declared to return an `Iterable` that returns integers, but the `yield` is
+ // returning a string from the iterable:
+ //
+ // ```dart
+ // Iterable<int> get zero sync* {
+ // yield [!'0'!];
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the return type of the function is correct, then fix the expression
+ // following the keyword `yield` to return the correct type:
+ //
+ // ```dart
+ // Iterable<int> get zero sync* {
+ // yield 0;
+ // }
+ // ```
+ //
+ // If the expression following the `yield` is correct, then change the return
+ // type of the function to allow it:
+ //
+ // ```dart
+ // Iterable<String> get zero sync* {
+ // yield '0';
+ // }
+ // ```
+ static const CompileTimeErrorCode YIELD_OF_INVALID_TYPE =
+ CompileTimeErrorCode(
+ 'YIELD_OF_INVALID_TYPE',
+ "The type '{0}' implied by the 'yield' expression must be assignable to '{1}'.",
+ hasPublishedDocs: true,
+ );
+
+ /// Initialize a newly created error code to have the given [name].
+ const CompileTimeErrorCode(
+ String name,
+ String message, {
+ String? correction,
+ bool hasPublishedDocs = false,
+ bool isUnresolvedIdentifier = false,
+ String? uniqueName,
+ }) : super(
+ correction: correction,
+ hasPublishedDocs: hasPublishedDocs,
+ isUnresolvedIdentifier: isUnresolvedIdentifier,
+ message: message,
+ name: name,
+ uniqueName: 'CompileTimeErrorCode.${uniqueName ?? name}',
+ );
+
+ @override
+ ErrorSeverity get errorSeverity => ErrorType.COMPILE_TIME_ERROR.severity;
+
+ @override
+ ErrorType get type => ErrorType.COMPILE_TIME_ERROR;
+}
+
+class LanguageCode extends ErrorCode {
+ static const LanguageCode IMPLICIT_DYNAMIC_FIELD = LanguageCode(
+ 'IMPLICIT_DYNAMIC_FIELD',
+ "Missing field type for '{0}'.",
+ correction:
+ "Try adding an explicit type, or remove implicit-dynamic from your analysis options file.",
+ );
+
+ static const LanguageCode IMPLICIT_DYNAMIC_FUNCTION = LanguageCode(
+ 'IMPLICIT_DYNAMIC_FUNCTION',
+ "Missing type arguments for generic function '{0}<{1}>'.",
+ correction:
+ "Try adding an explicit type, or remove implicit-dynamic from your analysis options file.",
+ );
+
+ static const LanguageCode IMPLICIT_DYNAMIC_INVOKE = LanguageCode(
+ 'IMPLICIT_DYNAMIC_INVOKE',
+ "Missing type arguments for calling generic function type '{0}'.",
+ correction:
+ "Try adding an explicit type, or remove implicit-dynamic from your analysis options file.",
+ );
+
+ static const LanguageCode IMPLICIT_DYNAMIC_LIST_LITERAL = LanguageCode(
+ 'IMPLICIT_DYNAMIC_LIST_LITERAL',
+ "Missing type argument for list literal.",
+ correction:
+ "Try adding an explicit type, or remove implicit-dynamic from your analysis options file.",
+ );
+
+ static const LanguageCode IMPLICIT_DYNAMIC_MAP_LITERAL = LanguageCode(
+ 'IMPLICIT_DYNAMIC_MAP_LITERAL',
+ "Missing type arguments for map literal.",
+ correction:
+ "Try adding an explicit type, or remove implicit-dynamic from your analysis options file.",
+ );
+
+ static const LanguageCode IMPLICIT_DYNAMIC_METHOD = LanguageCode(
+ 'IMPLICIT_DYNAMIC_METHOD',
+ "Missing type arguments for generic method '{0}<{1}>'.",
+ correction:
+ "Try adding an explicit type, or remove implicit-dynamic from your analysis options file.",
+ );
+
+ static const LanguageCode IMPLICIT_DYNAMIC_PARAMETER = LanguageCode(
+ 'IMPLICIT_DYNAMIC_PARAMETER',
+ "Missing parameter type for '{0}'.",
+ correction:
+ "Try adding an explicit type, or remove implicit-dynamic from your analysis options file.",
+ );
+
+ static const LanguageCode IMPLICIT_DYNAMIC_RETURN = LanguageCode(
+ 'IMPLICIT_DYNAMIC_RETURN',
+ "Missing return type for '{0}'.",
+ correction:
+ "Try adding an explicit type, or remove implicit-dynamic from your analysis options file.",
+ );
+
+ static const LanguageCode IMPLICIT_DYNAMIC_TYPE = LanguageCode(
+ 'IMPLICIT_DYNAMIC_TYPE',
+ "Missing type arguments for generic type '{0}'.",
+ correction:
+ "Try adding an explicit type, or remove implicit-dynamic from your analysis options file.",
+ );
+
+ static const LanguageCode IMPLICIT_DYNAMIC_VARIABLE = LanguageCode(
+ 'IMPLICIT_DYNAMIC_VARIABLE',
+ "Missing variable type for '{0}'.",
+ correction:
+ "Try adding an explicit type, or remove implicit-dynamic from your analysis options file.",
+ );
+
+ /// Initialize a newly created error code to have the given [name].
+ const LanguageCode(
+ String name,
+ String message, {
+ String? correction,
+ bool hasPublishedDocs = false,
+ bool isUnresolvedIdentifier = false,
+ String? uniqueName,
+ }) : super(
+ correction: correction,
+ hasPublishedDocs: hasPublishedDocs,
+ isUnresolvedIdentifier: isUnresolvedIdentifier,
+ message: message,
+ name: name,
+ uniqueName: 'LanguageCode.${uniqueName ?? name}',
+ );
+
+ @override
+ ErrorSeverity get errorSeverity => ErrorType.COMPILE_TIME_ERROR.severity;
+
+ @override
+ ErrorType get type => ErrorType.COMPILE_TIME_ERROR;
+}
+
+class StaticWarningCode extends AnalyzerErrorCode {
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic in two cases.
+ //
+ // The first is when the left operand of an `??` operator can't be `null`.
+ // The right operand is only evaluated if the left operand has the value
+ // `null`, and because the left operand can't be `null`, the right operand is
+ // never evaluated.
+ //
+ // The second is when the left-hand side of an assignment using the `??=`
+ // operator can't be `null`. The right-hand side is only evaluated if the
+ // left-hand side has the value `null`, and because the left-hand side can't
+ // be `null`, the right-hand side is never evaluated.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because `x` can't be `null`:
+ //
+ // ```dart
+ // int f(int x) {
+ // return x ?? [!0!];
+ // }
+ // ```
+ //
+ // The following code produces this diagnostic because `f` can't be `null`:
+ //
+ // ```dart
+ // class C {
+ // int f = -1;
+ //
+ // void m(int x) {
+ // f ??= [!x!];
+ // }
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the diagnostic is reported for an `??` operator, then remove the `??`
+ // operator and the right operand:
+ //
+ // ```dart
+ // int f(int x) {
+ // return x;
+ // }
+ // ```
+ //
+ // If the diagnostic is reported for an assignment, and the assignment isn't
+ // needed, then remove the assignment:
+ //
+ // ```dart
+ // class C {
+ // int f = -1;
+ //
+ // void m(int x) {
+ // }
+ // }
+ // ```
+ //
+ // If the assignment is needed, but should be based on a different condition,
+ // then rewrite the code to use `=` and the different condition:
+ //
+ // ```dart
+ // class C {
+ // int f = -1;
+ //
+ // void m(int x) {
+ // if (f < 0) {
+ // f = x;
+ // }
+ // }
+ // }
+ // ```
+ static const StaticWarningCode DEAD_NULL_AWARE_EXPRESSION = StaticWarningCode(
+ 'DEAD_NULL_AWARE_EXPRESSION',
+ "The left operand can't be null, so the right operand is never executed.",
+ correction: "Try removing the operator and the right operand.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the null-aware operator that is invalid
+ * 1: the non-null-aware operator that can replace the invalid operator
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a null-aware operator (`?.`,
+ // `?..`, `?[`, `?..[`, or `...?`) is used on a receiver that's known to be
+ // non-nullable.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because `s` can't be `null`:
+ //
+ // ```dart
+ // int? getLength(String s) {
+ // return s[!?.!]length;
+ // }
+ // ```
+ //
+ // The following code produces this diagnostic because `a` can't be `null`:
+ //
+ // ```dart
+ // var a = [];
+ // var b = [[!...?!]a];
+ // ```
+ //
+ // The following code produces this diagnostic because `s?.length` can't
+ // return `null`:
+ //
+ // ```dart
+ // void f(String? s) {
+ // s?.length[!?.!]isEven;
+ // }
+ // ```
+ //
+ // The reason `s?.length` can't return `null` is because the null-aware
+ // operator following `s` short-circuits the evaluation of both `length` and
+ // `isEven` if `s` is `null`. In other words, if `s` is `null`, then neither
+ // `length` nor `isEven` will be invoked, and if `s` is non-`null`, then
+ // `length` can't return a `null` value. Either way, `isEven` can't be invoked
+ // on a `null` value, so the null-aware operator is not necessary. See
+ // [Understanding null safety](/null-safety/understanding-null-safety#smarter-null-aware-methods)
+ // for more details.
+ //
+ // The following code produces this diagnostic because `s` can't be `null`.
+ //
+ // ```dart
+ // void f(Object? o) {
+ // var s = o as String;
+ // s[!?.!]length;
+ // }
+ // ```
+ //
+ // The reason `s` can't be null, despite the fact that `o` can be `null`, is
+ // because of the cast to `String`, which is a non-nullable type. If `o` ever
+ // has the value `null`, the cast will fail and the invocation of `length`
+ // will not happen.
+ //
+ // #### Common fixes
+ //
+ // Replace the null-aware operator with a non-null-aware equivalent; for
+ // example, change `?.` to `.`:
+ //
+ // ```dart
+ // int getLength(String s) {
+ // return s.length;
+ // }
+ // ```
+ //
+ // (Note that the return type was also changed to be non-nullable, which might
+ // not be appropriate in some cases.)
+ static const StaticWarningCode INVALID_NULL_AWARE_OPERATOR =
+ StaticWarningCode(
+ 'INVALID_NULL_AWARE_OPERATOR',
+ "The receiver can't be null, so the null-aware operator '{0}' is unnecessary.",
+ correction: "Try replacing the operator '{0}' with '{1}'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the null-aware operator that is invalid
+ * 1: the non-null-aware operator that can replace the invalid operator
+ */
+ static const StaticWarningCode
+ INVALID_NULL_AWARE_OPERATOR_AFTER_SHORT_CIRCUIT = StaticWarningCode(
+ 'INVALID_NULL_AWARE_OPERATOR',
+ "The receiver can't be null because of short-circuiting, so the null-aware operator '{0}' can't be used.",
+ correction: "Try replacing the operator '{0}' with '{1}'.",
+ hasPublishedDocs: true,
+ uniqueName: 'INVALID_NULL_AWARE_OPERATOR_AFTER_SHORT_CIRCUIT',
+ );
+
+ /**
+ * 7.1 Instance Methods: It is a static warning if an instance method
+ * <i>m1</i> overrides an instance member <i>m2</i>, the signature of
+ * <i>m2</i> explicitly specifies a default value for a formal parameter
+ * <i>p</i> and the signature of <i>m1</i> specifies a different default value
+ * for <i>p</i>.
+ */
+ static const StaticWarningCode
+ INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_NAMED = StaticWarningCode(
+ 'INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_NAMED',
+ "Parameters can't override default values, this method overrides '{0}.{1}' where '{2}' has a different value.",
+ correction: "Try using the same default value in both methods.",
+ );
+
+ /**
+ * 7.1 Instance Methods: It is a static warning if an instance method
+ * <i>m1</i> overrides an instance member <i>m2</i>, the signature of
+ * <i>m2</i> explicitly specifies a default value for a formal parameter
+ * <i>p</i> and the signature of <i>m1</i> specifies a different default value
+ * for <i>p</i>.
+ */
+ static const StaticWarningCode
+ INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_POSITIONAL = StaticWarningCode(
+ 'INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_POSITIONAL',
+ "Parameters can't override default values, this method overrides '{0}.{1}' where this positional parameter has a different value.",
+ correction: "Try using the same default value in both methods.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the constant that is missing
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a `switch` statement for an enum
+ // doesn't include an option for one of the values in the enumeration.
+ //
+ // Note that `null` is always a possible value for an enum and therefore also
+ // must be handled.
+ //
+ // #### Examples
+ //
+ // The following code produces this diagnostic because the enum constant `e2`
+ // isn't handled:
+ //
+ // ```dart
+ // enum E { e1, e2 }
+ //
+ // void f(E e) {
+ // [!switch (e)!] {
+ // case E.e1:
+ // break;
+ // }
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If there's special handling for the missing values, then add a `case`
+ // clause for each of the missing values:
+ //
+ // ```dart
+ // enum E { e1, e2 }
+ //
+ // void f(E e) {
+ // switch (e) {
+ // case E.e1:
+ // break;
+ // case E.e2:
+ // break;
+ // }
+ // }
+ // ```
+ //
+ // If the missing values should be handled the same way, then add a `default`
+ // clause:
+ //
+ // ```dart
+ // enum E { e1, e2 }
+ //
+ // void f(E e) {
+ // switch (e) {
+ // case E.e1:
+ // break;
+ // default:
+ // break;
+ // }
+ // }
+ // ```
+ // TODO(brianwilkerson) This documentation will need to be updated when NNBD
+ // ships.
+ static const StaticWarningCode MISSING_ENUM_CONSTANT_IN_SWITCH =
+ StaticWarningCode(
+ 'MISSING_ENUM_CONSTANT_IN_SWITCH',
+ "Missing case clause for '{0}'.",
+ correction:
+ "Try adding a case clause for the missing constant, or adding a default clause.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the operand of the `!` operator
+ // can't be `null`.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because `x` can't be `null`:
+ //
+ // ```dart
+ // int f(int x) {
+ // return x[!!!];
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Remove the null check operator (`!`):
+ //
+ // ```dart
+ // int f(int x) {
+ // return x;
+ // }
+ // ```
+ static const StaticWarningCode UNNECESSARY_NON_NULL_ASSERTION =
+ StaticWarningCode(
+ 'UNNECESSARY_NON_NULL_ASSERTION',
+ "The '!' will have no effect because the receiver can't be null.",
+ correction: "Try removing the '!' operator.",
+ hasPublishedDocs: true,
+ );
+
+ /// Initialize a newly created error code to have the given [name].
+ const StaticWarningCode(
+ String name,
+ String message, {
+ String? correction,
+ bool hasPublishedDocs = false,
+ bool isUnresolvedIdentifier = false,
+ String? uniqueName,
+ }) : super(
+ correction: correction,
+ hasPublishedDocs: hasPublishedDocs,
+ isUnresolvedIdentifier: isUnresolvedIdentifier,
+ message: message,
+ name: name,
+ uniqueName: 'StaticWarningCode.${uniqueName ?? name}',
+ );
+
+ @override
+ ErrorSeverity get errorSeverity => ErrorSeverity.WARNING;
+
+ @override
+ ErrorType get type => ErrorType.STATIC_WARNING;
+}
diff --git a/pkg/analyzer/lib/src/manifest/manifest_warning_code.dart b/pkg/analyzer/lib/src/manifest/manifest_warning_code.dart
index cd3116d..0cd9a11 100644
--- a/pkg/analyzer/lib/src/manifest/manifest_warning_code.dart
+++ b/pkg/analyzer/lib/src/manifest/manifest_warning_code.dart
@@ -2,95 +2,4 @@
// 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.
-import 'package:analyzer/error/error.dart';
-
-/// The error codes used for warnings in analysis options files. The convention
-/// for this class is for the name of the error code to indicate the problem
-/// that caused the error to be generated and for the error message to explain
-/// what is wrong and, when appropriate, how the problem can be corrected.
-class ManifestWarningCode extends ErrorCode {
- /// A code indicating that a specified hardware feature is not supported on
- /// Chrome OS.
- static const ManifestWarningCode UNSUPPORTED_CHROME_OS_HARDWARE =
- ManifestWarningCode(
- 'UNSUPPORTED_CHROME_OS_HARDWARE',
- 'The feature {0} is not supported on Chrome OS, consider making it '
- 'optional.',
- correction:
- 'Try adding `android:required="false"` for this feature.');
-
- /// A code indicating that a specified feature is not supported on Chrome OS.
- static const ManifestWarningCode UNSUPPORTED_CHROME_OS_FEATURE =
- ManifestWarningCode(
- 'UNSUPPORTED_CHROME_OS_FEATURE',
- 'The feature {0} is not supported on Chrome OS, consider making it '
- 'optional.',
- correction: "Try changing to `android:required=\"false\"` for this "
- "feature.");
-
- /// A code indicating that the touchscreen feature is not specified in the
- /// manifest.
- static const ManifestWarningCode NO_TOUCHSCREEN_FEATURE = ManifestWarningCode(
- 'NO_TOUCHSCREEN_FEATURE',
- 'The default "android.hardware.touchscreen" needs to be optional for '
- 'Chrome OS. ',
- correction: "Consider adding "
- "<uses-feature android:name=\"android.hardware.touchscreen\" android:required=\"false\" />"
- " to the manifest.");
-
- /// A code indicating that a specified permission is not supported on Chrome
- /// OS.
- static const ManifestWarningCode PERMISSION_IMPLIES_UNSUPPORTED_HARDWARE =
- ManifestWarningCode(
- 'PERMISSION_IMPLIES_UNSUPPORTED_HARDWARE',
- 'Permission makes app incompatible for Chrome OS, consider adding '
- 'optional {0} feature tag, ',
- correction: " Try adding `<uses-feature "
- "android:name=\"{0}\" android:required=\"false\">`.");
-
- /// A code indicating that the camera permissions is not supported on Chrome
- /// OS.
- static const ManifestWarningCode CAMERA_PERMISSIONS_INCOMPATIBLE = ManifestWarningCode(
- 'CAMERA_PERMISSIONS_INCOMPATIBLE',
- "Camera permissions make app incompatible for Chrome OS, consider adding "
- "optional features \"android.hardware.camera\" and \"android.hardware.camera.autofocus\".",
- correction: "Try adding `<uses-feature "
- "android:name=\"android.hardware.camera\" android:required=\"false\">` "
- "`<uses-feature "
- "android:name=\"android.hardware.camera.autofocus\" android:required=\"false\">`.");
-
- /// A code indicating that the activity is set to be non resizable.
- static const ManifestWarningCode NON_RESIZABLE_ACTIVITY = ManifestWarningCode(
- 'NON_RESIZABLE_ACTIVITY',
- "The `<activity>` element should be allowed to be resized to allow "
- "users to take advantage of the multi-window environment on Chrome OS",
- correction: "Consider declaring the corresponding "
- "activity element with `resizableActivity=\"true\"` attribute.");
-
- /// A code indicating that the activity is locked to an orientation.
- static const ManifestWarningCode SETTING_ORIENTATION_ON_ACTIVITY =
- ManifestWarningCode(
- 'SETTING_ORIENTATION_ON_ACTIVITY',
- "The `<activity>` element should not be locked to any orientation so "
- "that users can take advantage of the multi-window environments "
- "and larger screens on Chrome OS",
- correction:
- "Consider declaring the corresponding activity element with"
- " `screenOrientation=\"unspecified\"` or `\"fullSensor\"` attribute.");
-
- /// Initialize a newly created warning code to have the given [name],
- /// [message] and [correction].
- const ManifestWarningCode(String name, String message, {String? correction})
- : super(
- correction: correction,
- message: message,
- name: name,
- uniqueName: 'ManifestWarningCode.$name',
- );
-
- @override
- ErrorSeverity get errorSeverity => ErrorSeverity.WARNING;
-
- @override
- ErrorType get type => ErrorType.STATIC_WARNING;
-}
+export 'package:analyzer/src/manifest/manifest_warning_code.g.dart';
diff --git a/pkg/analyzer/lib/src/manifest/manifest_warning_code.g.dart b/pkg/analyzer/lib/src/manifest/manifest_warning_code.g.dart
new file mode 100644
index 0000000..73c4915
--- /dev/null
+++ b/pkg/analyzer/lib/src/manifest/manifest_warning_code.g.dart
@@ -0,0 +1,117 @@
+// 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";
+
+// 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 ManifestWarningCode extends ErrorCode {
+ /**
+ * A code indicating that the camera permissions is not supported on Chrome
+ * OS.
+ */
+ static const ManifestWarningCode CAMERA_PERMISSIONS_INCOMPATIBLE =
+ ManifestWarningCode(
+ 'CAMERA_PERMISSIONS_INCOMPATIBLE',
+ "Camera permissions make app incompatible for Chrome OS, consider adding optional features \"android.hardware.camera\" and \"android.hardware.camera.autofocus\".",
+ correction:
+ "Try adding `<uses-feature android:name=\"android.hardware.camera\" android:required=\"false\">` `<uses-feature android:name=\"android.hardware.camera.autofocus\" android:required=\"false\">`.",
+ );
+
+ /**
+ * A code indicating that the activity is set to be non resizable.
+ */
+ static const ManifestWarningCode NON_RESIZABLE_ACTIVITY = ManifestWarningCode(
+ 'NON_RESIZABLE_ACTIVITY',
+ "The `<activity>` element should be allowed to be resized to allow users to take advantage of the multi-window environment on Chrome OS",
+ correction:
+ "Consider declaring the corresponding activity element with `resizableActivity=\"true\"` attribute.",
+ );
+
+ /**
+ * A code indicating that the touchscreen feature is not specified in the
+ * manifest.
+ */
+ static const ManifestWarningCode NO_TOUCHSCREEN_FEATURE = ManifestWarningCode(
+ 'NO_TOUCHSCREEN_FEATURE',
+ "The default \"android.hardware.touchscreen\" needs to be optional for Chrome OS. ",
+ correction:
+ "Consider adding <uses-feature android:name=\"android.hardware.touchscreen\" android:required=\"false\" /> to the manifest.",
+ );
+
+ /**
+ * A code indicating that a specified permission is not supported on Chrome
+ * OS.
+ */
+ static const ManifestWarningCode PERMISSION_IMPLIES_UNSUPPORTED_HARDWARE =
+ ManifestWarningCode(
+ 'PERMISSION_IMPLIES_UNSUPPORTED_HARDWARE',
+ "Permission makes app incompatible for Chrome OS, consider adding optional {0} feature tag, ",
+ correction:
+ " Try adding `<uses-feature android:name=\"{0}\" android:required=\"false\">`.",
+ );
+
+ /**
+ * A code indicating that the activity is locked to an orientation.
+ */
+ static const ManifestWarningCode SETTING_ORIENTATION_ON_ACTIVITY =
+ ManifestWarningCode(
+ 'SETTING_ORIENTATION_ON_ACTIVITY',
+ "The `<activity>` element should not be locked to any orientation so that users can take advantage of the multi-window environments and larger screens on Chrome OS",
+ correction:
+ "Consider declaring the corresponding activity element with `screenOrientation=\"unspecified\"` or `\"fullSensor\"` attribute.",
+ );
+
+ /**
+ * A code indicating that a specified feature is not supported on Chrome OS.
+ */
+ static const ManifestWarningCode UNSUPPORTED_CHROME_OS_FEATURE =
+ ManifestWarningCode(
+ 'UNSUPPORTED_CHROME_OS_FEATURE',
+ "The feature {0} is not supported on Chrome OS, consider making it optional.",
+ correction:
+ "Try changing to `android:required=\"false\"` for this feature.",
+ );
+
+ /**
+ * A code indicating that a specified hardware feature is not supported on
+ * Chrome OS.
+ */
+ static const ManifestWarningCode UNSUPPORTED_CHROME_OS_HARDWARE =
+ ManifestWarningCode(
+ 'UNSUPPORTED_CHROME_OS_HARDWARE',
+ "The feature {0} is not supported on Chrome OS, consider making it optional.",
+ correction: "Try adding `android:required=\"false\"` for this feature.",
+ );
+
+ /// Initialize a newly created error code to have the given [name].
+ const ManifestWarningCode(
+ String name,
+ String message, {
+ String? correction,
+ bool hasPublishedDocs = false,
+ bool isUnresolvedIdentifier = false,
+ String? uniqueName,
+ }) : super(
+ correction: correction,
+ hasPublishedDocs: hasPublishedDocs,
+ isUnresolvedIdentifier: isUnresolvedIdentifier,
+ message: message,
+ name: name,
+ uniqueName: 'ManifestWarningCode.${uniqueName ?? name}',
+ );
+
+ @override
+ ErrorSeverity get errorSeverity => ErrorSeverity.WARNING;
+
+ @override
+ ErrorType get type => ErrorType.STATIC_WARNING;
+}
diff --git a/pkg/analyzer/lib/src/pubspec/pubspec_warning_code.dart b/pkg/analyzer/lib/src/pubspec/pubspec_warning_code.dart
index 5f90845..746e79c 100644
--- a/pkg/analyzer/lib/src/pubspec/pubspec_warning_code.dart
+++ b/pkg/analyzer/lib/src/pubspec/pubspec_warning_code.dart
@@ -2,564 +2,4 @@
// 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.
-import 'package:analyzer/error/error.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
-
-/// The error codes used for warnings in pubspec files. The convention for this
-/// class is for the name of the error code to indicate the problem that caused
-/// the error to be generated and for the error message to explain what is wrong
-/// and, when appropriate, how the problem can be corrected.
-class PubspecWarningCode extends ErrorCode {
- /**
- * Parameters:
- * 0: the path to the asset as given in the file.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an asset list contains a value
- // referencing a file that doesn't exist.
- //
- // #### Example
- //
- // Assuming that the file `doesNotExist.gif` doesn't exist, the following code
- // produces this diagnostic because it's listed as an asset:
- //
- // ```yaml
- // %uri="pubspec.yaml"
- // name: example
- // flutter:
- // assets:
- // - doesNotExist.gif
- // ```
- //
- // #### Common fixes
- //
- // If the path is correct, then create a file at that path.
- //
- // If the path isn't correct, then change the path to match the path of the
- // file containing the asset.
- static const PubspecWarningCode ASSET_DOES_NOT_EXIST = PubspecWarningCode(
- 'ASSET_DOES_NOT_EXIST', "The asset file '{0}' doesn't exist.",
- correction: "Try creating the file or fixing the path to the file.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the path to the asset directory as given in the file.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an asset list contains a value
- // referencing a directory that doesn't exist.
- //
- // #### Example
- //
- // Assuming that the directory `assets` doesn't exist, the following code
- // produces this diagnostic because it's listed as a directory containing
- // assets:
- //
- // ```yaml
- // %uri="pubspec.yaml"
- // name: example
- // flutter:
- // assets:
- // - assets/
- // ```
- //
- // #### Common fixes
- //
- // If the path is correct, then create a directory at that path.
- //
- // If the path isn't correct, then change the path to match the path of the
- // directory containing the assets.
- static const PubspecWarningCode ASSET_DIRECTORY_DOES_NOT_EXIST =
- PubspecWarningCode('ASSET_DIRECTORY_DOES_NOT_EXIST',
- "The asset directory '{0}' doesn't exist.",
- correction: "Try creating the directory or fixing the path to the "
- "directory.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the value of the `asset` key
- // isn't a list.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the value of the assets
- // key is a string when a list is expected:
- //
- // ```yaml
- // %uri="pubspec.yaml"
- // name: example
- // flutter:
- // assets: assets/
- // ```
- //
- // #### Common fixes
- //
- // Change the value of the asset list so that it's a list:
- //
- // ```yaml
- // %uri="pubspec.yaml"
- // name: example
- // flutter:
- // assets:
- // - assets/
- // ```
- static const PubspecWarningCode ASSET_FIELD_NOT_LIST = PubspecWarningCode(
- 'ASSET_FIELD_NOT_LIST',
- "The value of the 'asset' field is expected to be a list of relative "
- "file paths.",
- correction:
- "Try converting the value to be a list of relative file paths.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when an asset list contains a value
- // that isn't a string.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the asset list contains
- // a map:
- //
- // ```yaml
- // %uri="pubspec.yaml"
- // name: example
- // flutter:
- // assets:
- // - image.gif: true
- // ```
- //
- // #### Common fixes
- //
- // Change the asset list so that it only contains valid POSIX-style file
- // paths:
- //
- // ```yaml
- // %uri="pubspec.yaml"
- // name: example
- // flutter:
- // assets:
- // - image.gif
- // ```
- static const PubspecWarningCode ASSET_NOT_STRING = PubspecWarningCode(
- 'ASSET_NOT_STRING', "Assets are required to be file paths (strings).",
- correction: "Try converting the value to be a string.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the value of either the
- // `dependencies` or `dev_dependencies` key isn't a map.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the value of the
- // top-level `dependencies` key is a list:
- //
- // ```yaml
- // %uri="pubspec.yaml"
- // name: example
- // dependencies:
- // - meta
- // ```
- //
- // #### Common fixes
- //
- // Use a map as the value of the `dependencies` key:
- //
- // ```yaml
- // %uri='pubspec.yaml'
- // name: example
- // dependencies:
- // meta: ^1.0.2
- // ```
- static const PubspecWarningCode DEPENDENCIES_FIELD_NOT_MAP =
- PubspecWarningCode('DEPENDENCIES_FIELD_NOT_MAP',
- "The value of the '{0}' field is expected to be a map.",
- correction: "Try converting the value to be a map.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a key is used in a
- // `pubspec.yaml` file that was deprecated. Unused keys take up space and
- // might imply semantics that are no longer valid.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the `author` key is no
- // longer being used:
- //
- // ```dart
- // %uri="pubspec.yaml"
- // name: example
- // author: 'Dash'
- // ```
- //
- // #### Common fixes
- //
- // Remove the deprecated key:
- //
- // ```dart
- // %uri="pubspec.yaml"
- // name: example
- // ```
- static const PubspecWarningCode DEPRECATED_FIELD = PubspecWarningCode(
- 'DEPRECATED_FIELD',
- "The '{0}' field is no longer used and can be removed.",
- correction: "Try removing the field.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the value of the `flutter` key
- // isn't a map.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the value of the
- // top-level `flutter` key is a string:
- //
- // ```yaml
- // %uri="pubspec.yaml"
- // name: example
- // flutter: true
- // ```
- //
- // #### Common fixes
- //
- // If you need to specify Flutter-specific options, then change the value to
- // be a map:
- //
- // ```yaml
- // %uri="pubspec.yaml"
- // name: example
- // flutter:
- // uses-material-design: true
- // ```
- //
- // If you don't need to specify Flutter-specific options, then remove the
- // `flutter` key:
- //
- // ```yaml
- // %uri="pubspec.yaml"
- // name: example
- // ```
- static const PubspecWarningCode FLUTTER_FIELD_NOT_MAP = PubspecWarningCode(
- 'FLUTTER_FIELD_NOT_MAP',
- "The value of the 'flutter' field is expected to be a map.",
- correction: "Try converting the value to be a map.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the kind of dependency.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a package under either
- // `dependencies` or `dev_dependencies` is not a pub, `git`, or `path` based
- // dependency.
- //
- // See [Package dependencies](https://dart.dev/tools/pub/dependencies) for
- // more information about the kind of dependencies that are supported.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the dependency on the
- // package `transmogrify` is not a pub, `git`, or `path` based dependency:
- //
- // ```yaml
- // %uri="pubspec.yaml"
- // name: example
- // dependencies:
- // transmogrify:
- // hosted:
- // name: transmogrify
- // url: http://your-package-server.com
- // version: ^1.4.0
- // ```
- //
- // #### Common fixes
- //
- // If you want to publish your package to `pub.dev`, then change the
- // dependencies to ones that are supported by `pub`.
- //
- // If you don't want to publish your package to `pub.dev`, then add a
- // `publish_to: none` entry to mark the package as one that isn't intended to
- // be published:
- //
- // ```yaml
- // %uri="pubspec.yaml"
- // name: example
- // publish_to: none
- // dependencies:
- // transmogrify:
- // hosted:
- // name: transmogrify
- // url: http://your-package-server.com
- // version: ^1.4.0
- // ```
- static const PubspecWarningCode INVALID_DEPENDENCY = PubspecWarningCode(
- 'INVALID_DEPENDENCY',
- "Publishable packages can't have '{0}' dependencies.",
- correction:
- "Try adding a 'publish_to: none' entry to mark the package as not "
- "for publishing or remove the {0} dependency.",
- hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when there's no top-level `name` key.
- // The `name` key provides the name of the package, which is required.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the package doesn't
- // have a name:
- //
- // ```yaml
- // %uri="pubspec.yaml"
- // dependencies:
- // meta: ^1.0.2
- // ```
- //
- // #### Common fixes
- //
- // Add the top-level key `name` with a value that's the name of the package:
- //
- // ```yaml
- // %uri="pubspec.yaml"
- // name: example
- // dependencies:
- // meta: ^1.0.2
- // ```
- static const PubspecWarningCode MISSING_NAME = PubspecWarningCode(
- 'MISSING_NAME', "The 'name' field is required but missing.",
- correction: "Try adding a field named 'name'.", hasPublishedDocs: true);
-
- /**
- * No parameters.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when the top-level `name` key has a
- // value that isn't a string.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the value following the
- // `name` key is a list:
- //
- // ```yaml
- // %uri="pubspec.yaml"
- // name:
- // - example
- // ```
- //
- // #### Common fixes
- //
- // Replace the value with a string:
- //
- // ```yaml
- // %uri="pubspec.yaml"
- // name: example
- // ```
- static const PubspecWarningCode NAME_NOT_STRING = PubspecWarningCode(
- 'NAME_NOT_STRING',
- "The value of the 'name' field is required to be a string.",
- correction: "Try converting the value to be a string.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the path to the dependency as given in the file.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a dependency has a `path` key
- // referencing a directory that doesn't exist.
- //
- // #### Example
- //
- // Assuming that the directory `doesNotExist` doesn't exist, the following
- // code produces this diagnostic because it's listed as the path of a package:
- //
- // ```yaml
- // %uri="pubspec.yaml"
- // name: example
- // dependencies:
- // local_package:
- // path: doesNotExist
- // ```
- //
- // #### Common fixes
- //
- // If the path is correct, then create a directory at that path.
- //
- // If the path isn't correct, then change the path to match the path to the
- // root of the package.
- static const PubspecWarningCode PATH_DOES_NOT_EXIST = PubspecWarningCode(
- 'PATH_DOES_NOT_EXIST', "The path '{0}' doesn't exist.",
- correction:
- "Try creating the referenced path or using a path that exists.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the path as given in the file.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a dependency has a `path` key
- // whose value is a string, but isn't a POSIX-style path.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the path following the
- // `path` key is a Windows path:
- //
- // ```yaml
- // %uri="pubspec.yaml"
- // name: example
- // dependencies:
- // local_package:
- // path: E:\local_package
- // ```
- //
- // #### Common fixes
- //
- // Convert the path to a POSIX path.
- static const PubspecWarningCode PATH_NOT_POSIX = PubspecWarningCode(
- 'PATH_NOT_POSIX', "The path '{0}' isn't a POSIX-style path.",
- correction: "Try converting the value to a POSIX-style path.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the path to the dependency as given in the file.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when a dependency has a `path` key
- // that references a directory that doesn't contain a `pubspec.yaml` file.
- //
- // #### Example
- //
- // Assuming that the directory `local_package` doesn't contain a file named
- // `pubspec.yaml`, the following code produces this diagnostic because it's
- // listed as the path of a package:
- //
- // ```yaml
- // %uri="pubspec.yaml"
- // name: example
- // dependencies:
- // local_package:
- // path: local_package
- // ```
- //
- // #### Common fixes
- //
- // If the path is intended to be the root of a package, then add a
- // `pubspec.yaml` file in the directory:
- //
- // ```yaml
- // %uri="pubspec.yaml"
- // name: local_package
- // ```
- //
- // If the path is wrong, then replace it with a the correct path.
- static const PubspecWarningCode PATH_PUBSPEC_DOES_NOT_EXIST = PubspecWarningCode(
- 'PATH_PUBSPEC_DOES_NOT_EXIST',
- "The directory '{0}' doesn't contain a pubspec.",
- correction:
- "Try creating a pubspec in the referenced directory or using a path that has a pubspec.",
- hasPublishedDocs: true);
-
- /**
- * Parameters:
- * 0: the name of the package in the dev_dependency list.
- */
- // #### Description
- //
- // The analyzer produces this diagnostic when there's an entry under
- // `dev_dependencies` for a package that is also listed under `dependencies`.
- // The packages under `dependencies` are available to all of the code in the
- // package, so there's no need to also list them under `dev_dependencies`.
- //
- // #### Example
- //
- // The following code produces this diagnostic because the package `meta` is
- // listed under both `dependencies` and `dev_dependencies`:
- //
- // ```yaml
- // %uri='pubspec.yaml'
- // name: example
- // dependencies:
- // meta: ^1.0.2
- // dev_dependencies:
- // meta: ^1.0.2
- // ```
- //
- // #### Common fixes
- //
- // Remove the entry under `dev_dependencies` (and the `dev_dependencies` key
- // if that's the only package listed there):
- //
- // ```yaml
- // %uri='pubspec.yaml'
- // name: example
- // dependencies:
- // meta: ^1.0.2
- // ```
- static const PubspecWarningCode UNNECESSARY_DEV_DEPENDENCY =
- PubspecWarningCode(
- 'UNNECESSARY_DEV_DEPENDENCY',
- "The dev dependency on {0} is unnecessary because there is also a "
- "normal dependency on that package.",
- correction: "Try removing the dev dependency.",
- hasPublishedDocs: true);
-
- /// Initialize a newly created warning code to have the given [name],
- /// [message] and [correction].
- const PubspecWarningCode(String name, String message,
- {String? correction, bool hasPublishedDocs = false})
- : super(
- correction: correction,
- message: message,
- name: name,
- uniqueName: 'PubspecWarningCode.$name',
- hasPublishedDocs: hasPublishedDocs,
- );
-
- @override
- ErrorSeverity get errorSeverity => ErrorSeverity.WARNING;
-
- @override
- ErrorType get type => ErrorType.STATIC_WARNING;
-}
+export 'package:analyzer/src/pubspec/pubspec_warning_code.g.dart';
diff --git a/pkg/analyzer/lib/src/pubspec/pubspec_warning_code.g.dart b/pkg/analyzer/lib/src/pubspec/pubspec_warning_code.g.dart
new file mode 100644
index 0000000..fe4471c
--- /dev/null
+++ b/pkg/analyzer/lib/src/pubspec/pubspec_warning_code.g.dart
@@ -0,0 +1,589 @@
+// 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";
+
+// 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 PubspecWarningCode extends ErrorCode {
+ /**
+ * Parameters:
+ * 0: the path to the asset directory as given in the file.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an asset list contains a value
+ // referencing a directory that doesn't exist.
+ //
+ // #### Example
+ //
+ // Assuming that the directory `assets` doesn't exist, the following code
+ // produces this diagnostic because it's listed as a directory containing
+ // assets:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // name: example
+ // flutter:
+ // assets:
+ // - assets/
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the path is correct, then create a directory at that path.
+ //
+ // If the path isn't correct, then change the path to match the path of the
+ // directory containing the assets.
+ static const PubspecWarningCode ASSET_DIRECTORY_DOES_NOT_EXIST =
+ PubspecWarningCode(
+ 'ASSET_DIRECTORY_DOES_NOT_EXIST',
+ "The asset directory '{0}' doesn't exist.",
+ correction:
+ "Try creating the directory or fixing the path to the directory.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the path to the asset as given in the file.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an asset list contains a value
+ // referencing a file that doesn't exist.
+ //
+ // #### Example
+ //
+ // Assuming that the file `doesNotExist.gif` doesn't exist, the following code
+ // produces this diagnostic because it's listed as an asset:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // name: example
+ // flutter:
+ // assets:
+ // - doesNotExist.gif
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the path is correct, then create a file at that path.
+ //
+ // If the path isn't correct, then change the path to match the path of the
+ // file containing the asset.
+ static const PubspecWarningCode ASSET_DOES_NOT_EXIST = PubspecWarningCode(
+ 'ASSET_DOES_NOT_EXIST',
+ "The asset file '{0}' doesn't exist.",
+ correction: "Try creating the file or fixing the path to the file.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the value of the `asset` key
+ // isn't a list.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the value of the assets
+ // key is a string when a list is expected:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // name: example
+ // flutter:
+ // assets: assets/
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Change the value of the asset list so that it's a list:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // name: example
+ // flutter:
+ // assets:
+ // - assets/
+ // ```
+ static const PubspecWarningCode ASSET_FIELD_NOT_LIST = PubspecWarningCode(
+ 'ASSET_FIELD_NOT_LIST',
+ "The value of the 'asset' field is expected to be a list of relative file paths.",
+ correction: "Try converting the value to be a list of relative file paths.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an asset list contains a value
+ // that isn't a string.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the asset list contains
+ // a map:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // name: example
+ // flutter:
+ // assets:
+ // - image.gif: true
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Change the asset list so that it only contains valid POSIX-style file
+ // paths:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // name: example
+ // flutter:
+ // assets:
+ // - image.gif
+ // ```
+ static const PubspecWarningCode ASSET_NOT_STRING = PubspecWarningCode(
+ 'ASSET_NOT_STRING',
+ "Assets are required to be file paths (strings).",
+ correction: "Try converting the value to be a string.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the value of either the
+ // `dependencies` or `dev_dependencies` key isn't a map.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the value of the
+ // top-level `dependencies` key is a list:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // name: example
+ // dependencies:
+ // - meta
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Use a map as the value of the `dependencies` key:
+ //
+ // ```yaml
+ // %uri='pubspec.yaml'
+ // name: example
+ // dependencies:
+ // meta: ^1.0.2
+ // ```
+ static const PubspecWarningCode DEPENDENCIES_FIELD_NOT_MAP =
+ PubspecWarningCode(
+ 'DEPENDENCIES_FIELD_NOT_MAP',
+ "The value of the '{0}' field is expected to be a map.",
+ correction: "Try converting the value to be a map.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a key is used in a
+ // `pubspec.yaml` file that was deprecated. Unused keys take up space and
+ // might imply semantics that are no longer valid.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the `author` key is no
+ // longer being used:
+ //
+ // ```dart
+ // %uri="pubspec.yaml"
+ // name: example
+ // author: 'Dash'
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Remove the deprecated key:
+ //
+ // ```dart
+ // %uri="pubspec.yaml"
+ // name: example
+ // ```
+ static const PubspecWarningCode DEPRECATED_FIELD = PubspecWarningCode(
+ 'DEPRECATED_FIELD',
+ "The '{0}' field is no longer used and can be removed.",
+ correction: "Try removing the field.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the value of the `flutter` key
+ // isn't a map.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the value of the
+ // top-level `flutter` key is a string:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // name: example
+ // flutter: true
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you need to specify Flutter-specific options, then change the value to
+ // be a map:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // name: example
+ // flutter:
+ // uses-material-design: true
+ // ```
+ //
+ // If you don't need to specify Flutter-specific options, then remove the
+ // `flutter` key:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // name: example
+ // ```
+ static const PubspecWarningCode FLUTTER_FIELD_NOT_MAP = PubspecWarningCode(
+ 'FLUTTER_FIELD_NOT_MAP',
+ "The value of the 'flutter' field is expected to be a map.",
+ correction: "Try converting the value to be a map.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the kind of dependency.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a package under either
+ // `dependencies` or `dev_dependencies` is not a pub, `git`, or `path` based
+ // dependency.
+ //
+ // See [Package dependencies](https://dart.dev/tools/pub/dependencies) for
+ // more information about the kind of dependencies that are supported.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the dependency on the
+ // package `transmogrify` is not a pub, `git`, or `path` based dependency:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // name: example
+ // dependencies:
+ // transmogrify:
+ // hosted:
+ // name: transmogrify
+ // url: http://your-package-server.com
+ // version: ^1.4.0
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you want to publish your package to `pub.dev`, then change the
+ // dependencies to ones that are supported by `pub`.
+ //
+ // If you don't want to publish your package to `pub.dev`, then add a
+ // `publish_to: none` entry to mark the package as one that isn't intended to
+ // be published:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // name: example
+ // publish_to: none
+ // dependencies:
+ // transmogrify:
+ // hosted:
+ // name: transmogrify
+ // url: http://your-package-server.com
+ // version: ^1.4.0
+ // ```
+ static const PubspecWarningCode INVALID_DEPENDENCY = PubspecWarningCode(
+ 'INVALID_DEPENDENCY',
+ "Publishable packages can't have '{0}' dependencies.",
+ correction:
+ "Try adding a 'publish_to: none' entry to mark the package as not for publishing or remove the {0} dependency.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when there's no top-level `name` key.
+ // The `name` key provides the name of the package, which is required.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the package doesn't
+ // have a name:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // dependencies:
+ // meta: ^1.0.2
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Add the top-level key `name` with a value that's the name of the package:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // name: example
+ // dependencies:
+ // meta: ^1.0.2
+ // ```
+ static const PubspecWarningCode MISSING_NAME = PubspecWarningCode(
+ 'MISSING_NAME',
+ "The 'name' field is required but missing.",
+ correction: "Try adding a field named 'name'.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the top-level `name` key has a
+ // value that isn't a string.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the value following the
+ // `name` key is a list:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // name:
+ // - example
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Replace the value with a string:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // name: example
+ // ```
+ static const PubspecWarningCode NAME_NOT_STRING = PubspecWarningCode(
+ 'NAME_NOT_STRING',
+ "The value of the 'name' field is required to be a string.",
+ correction: "Try converting the value to be a string.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the path to the dependency as given in the file.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a dependency has a `path` key
+ // referencing a directory that doesn't exist.
+ //
+ // #### Example
+ //
+ // Assuming that the directory `doesNotExist` doesn't exist, the following
+ // code produces this diagnostic because it's listed as the path of a package:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // name: example
+ // dependencies:
+ // local_package:
+ // path: doesNotExist
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the path is correct, then create a directory at that path.
+ //
+ // If the path isn't correct, then change the path to match the path to the
+ // root of the package.
+ static const PubspecWarningCode PATH_DOES_NOT_EXIST = PubspecWarningCode(
+ 'PATH_DOES_NOT_EXIST',
+ "The path '{0}' doesn't exist.",
+ correction: "Try creating the referenced path or using a path that exists.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the path as given in the file.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a dependency has a `path` key
+ // whose value is a string, but isn't a POSIX-style path.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the path following the
+ // `path` key is a Windows path:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // name: example
+ // dependencies:
+ // local_package:
+ // path: E:\local_package
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Convert the path to a POSIX path.
+ static const PubspecWarningCode PATH_NOT_POSIX = PubspecWarningCode(
+ 'PATH_NOT_POSIX',
+ "The path '{0}' isn't a POSIX-style path.",
+ correction: "Try converting the value to a POSIX-style path.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the path to the dependency as given in the file.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a dependency has a `path` key
+ // that references a directory that doesn't contain a `pubspec.yaml` file.
+ //
+ // #### Example
+ //
+ // Assuming that the directory `local_package` doesn't contain a file named
+ // `pubspec.yaml`, the following code produces this diagnostic because it's
+ // listed as the path of a package:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // name: example
+ // dependencies:
+ // local_package:
+ // path: local_package
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the path is intended to be the root of a package, then add a
+ // `pubspec.yaml` file in the directory:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // name: local_package
+ // ```
+ //
+ // If the path is wrong, then replace it with a the correct path.
+ static const PubspecWarningCode PATH_PUBSPEC_DOES_NOT_EXIST =
+ PubspecWarningCode(
+ 'PATH_PUBSPEC_DOES_NOT_EXIST',
+ "The directory '{0}' doesn't contain a pubspec.",
+ correction:
+ "Try creating a pubspec in the referenced directory or using a path that has a pubspec.",
+ hasPublishedDocs: true,
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the package in the dev_dependency list.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when there's an entry under
+ // `dev_dependencies` for a package that is also listed under `dependencies`.
+ // The packages under `dependencies` are available to all of the code in the
+ // package, so there's no need to also list them under `dev_dependencies`.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the package `meta` is
+ // listed under both `dependencies` and `dev_dependencies`:
+ //
+ // ```yaml
+ // %uri='pubspec.yaml'
+ // name: example
+ // dependencies:
+ // meta: ^1.0.2
+ // dev_dependencies:
+ // meta: ^1.0.2
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Remove the entry under `dev_dependencies` (and the `dev_dependencies` key
+ // if that's the only package listed there):
+ //
+ // ```yaml
+ // %uri='pubspec.yaml'
+ // name: example
+ // dependencies:
+ // meta: ^1.0.2
+ // ```
+ static const PubspecWarningCode UNNECESSARY_DEV_DEPENDENCY =
+ PubspecWarningCode(
+ 'UNNECESSARY_DEV_DEPENDENCY',
+ "The dev dependency on {0} is unnecessary because there is also a normal dependency on that package.",
+ correction: "Try removing the dev dependency.",
+ hasPublishedDocs: true,
+ );
+
+ /// Initialize a newly created error code to have the given [name].
+ const PubspecWarningCode(
+ String name,
+ String message, {
+ String? correction,
+ bool hasPublishedDocs = false,
+ bool isUnresolvedIdentifier = false,
+ String? uniqueName,
+ }) : super(
+ correction: correction,
+ hasPublishedDocs: hasPublishedDocs,
+ isUnresolvedIdentifier: isUnresolvedIdentifier,
+ message: message,
+ name: name,
+ uniqueName: 'PubspecWarningCode.${uniqueName ?? name}',
+ );
+
+ @override
+ ErrorSeverity get errorSeverity => ErrorSeverity.WARNING;
+
+ @override
+ ErrorType get type => ErrorType.STATIC_WARNING;
+}
diff --git a/pkg/analyzer/messages.yaml b/pkg/analyzer/messages.yaml
index 74e44a3..f5cd801 100644
--- a/pkg/analyzer/messages.yaml
+++ b/pkg/analyzer/messages.yaml
@@ -1,6 +1,42 @@
+# 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 organized as a two level map, where the outer key corresponds to
+# the name of an analyzer error class (e.g. CompileTimeErrorCode), and the inner
+# key corresponds to the name of a static variable in that class, describing a
+# single diagnostic message. Ideally, each entry contains three parts:
+#
+# 1. A message template (problemMessage).
+#
+# 2. A suggestion for how to correct the problem (correctionMessage).
+#
+# 3. User-facing documentation for the problem (documentation).
+#
+# A message shouldn't indicate which kind of diagnostic it is, for example,
+# warning or error. This is implied by the analyzer error class. For example,
+# all entries in `StaticWarningCode` are warnings.
+#
+# See the file [lib/src/fasta/diagnostics.md] for more details on how to write
+# good diagnostic messages.
+#
+# A message used for internal errors should have key that starts with
+# "InternalProblem". This way, UX review can prioritize it accordingly.
+#
+# Eventually, we'd like to have all diagnostics in one shared location. However,
+# for now, we have analyzer error codes and CFE error codes in separate files.
+# See `pkg/front_end/messages.yaml` for the CFE error codes.
+#
+# ## Parameter Substitution in problemMessage and correctionMessage
+#
+# The fields `problemMessage` and `correctionMessage` are subject to parameter
+# substitution. When the compiler reports a problem, it may also specify a list
+# of values to be substituted into the message. Parameters are declared using
+# placeholders of the form `{INTEGER}`, e.g. `{0}` is the zeroth parameter.
+
AnalysisOptionsErrorCode:
INCLUDED_FILE_PARSE_ERROR:
- template: "{3} in {0}({1}..{2})"
+ problemMessage: "{3} in {0}({1}..{2})"
comment: |-
An error code indicating that there is a syntactic error in the included
file.
@@ -11,7 +47,7 @@
2: the ending offset of the text in the file that contains the error
3: the error message
PARSE_ERROR:
- template: "{0}"
+ problemMessage: "{0}"
comment: |-
An error code indicating that there is a syntactic error in the file.
@@ -19,27 +55,27 @@
0: the error message from the parse error
AnalysisOptionsHintCode:
PREVIEW_DART_2_SETTING_DEPRECATED:
- template: "The 'enablePreviewDart2' setting is deprecated."
- tip: It is no longer necessary to explicitly enable Dart 2.
+ problemMessage: "The 'enablePreviewDart2' setting is deprecated."
+ correctionMessage: It is no longer necessary to explicitly enable Dart 2.
comment: |-
An error code indicating that the enablePreviewDart2 setting is
deprecated.
STRONG_MODE_SETTING_DEPRECATED:
- template: "The 'strong-mode: true' setting is deprecated."
- tip: It is no longer necessary to explicitly enable strong mode.
+ problemMessage: "The 'strong-mode: true' setting is deprecated."
+ correctionMessage: It is no longer necessary to explicitly enable strong mode.
comment: "An error code indicating that strong-mode: true is deprecated."
SUPER_MIXINS_SETTING_DEPRECATED:
- template: "The 'enableSuperMixins' setting is deprecated."
- tip: "Support has been added to the language for 'mixin' based mixins."
+ problemMessage: "The 'enableSuperMixins' setting is deprecated."
+ correctionMessage: "Support has been added to the language for 'mixin' based mixins."
comment: |-
An error code indicating that the enablePreviewDart2 setting is
deprecated.
AnalysisOptionsWarningCode:
ANALYSIS_OPTION_DEPRECATED:
- template: "The option '{0}' is no longer supported."
+ problemMessage: "The option '{0}' is no longer supported."
comment: An error code indicating that the given option is deprecated.
INCLUDED_FILE_WARNING:
- template: "Warning in the included options file {0}({1}..{2}): {3}"
+ problemMessage: "Warning in the included options file {0}({1}..{2}): {3}"
comment: |-
An error code indicating a specified include file has a warning.
@@ -49,7 +85,7 @@
2: the ending offset of the text in the file that contains the warning
3: the warning message
INCLUDE_FILE_NOT_FOUND:
- template: "The include file '{0}' in '{1}' can't be found when analyzing '{2}'."
+ problemMessage: "The include file '{0}' in '{1}' can't be found when analyzing '{2}'."
comment: |-
An error code indicating a specified include file could not be found.
@@ -58,23 +94,23 @@
1: the path of the file containing the include directive
2: the path of the context being analyzed
INVALID_OPTION:
- template: "Invalid option specified for '{0}': {1}"
+ problemMessage: "Invalid option specified for '{0}': {1}"
comment: |-
An error code indicating that a plugin is being configured with an invalid
value for an option and a detail message is provided.
INVALID_SECTION_FORMAT:
- template: "Invalid format for the '{0}' section."
+ problemMessage: "Invalid format for the '{0}' section."
comment: |-
An error code indicating an invalid format for an options file section.
Parameters:
0: the section name
SPEC_MODE_REMOVED:
- template: "The option 'strong-mode: false' is no longer supported."
- tip: "It's recommended to remove the 'strong-mode:' setting (and make your code Dart 2 compliant)."
+ problemMessage: "The option 'strong-mode: false' is no longer supported."
+ correctionMessage: "It's recommended to remove the 'strong-mode:' setting (and make your code Dart 2 compliant)."
comment: "An error code indicating that strong-mode: false is has been removed."
UNRECOGNIZED_ERROR_CODE:
- template: "'{0}' isn't a recognized error code."
+ problemMessage: "'{0}' isn't a recognized error code."
comment: |-
An error code indicating that an unrecognized error code is being used to
specify an error filter.
@@ -82,7 +118,7 @@
Parameters:
0: the unrecognized error code
UNSUPPORTED_OPTION_WITHOUT_VALUES:
- template: "The option '{1}' isn't supported by '{0}'."
+ problemMessage: "The option '{1}' isn't supported by '{0}'."
comment: |-
An error code indicating that a plugin is being configured with an
unsupported option and legal options are provided.
@@ -91,7 +127,7 @@
0: the plugin name
1: the unsupported option key
UNSUPPORTED_OPTION_WITH_LEGAL_VALUE:
- template: "The option '{1}' isn't supported by '{0}'. Try using the only supported option: '{2}'."
+ problemMessage: "The option '{1}' isn't supported by '{0}'. Try using the only supported option: '{2}'."
comment: |-
An error code indicating that a plugin is being configured with an
unsupported option where there is just one legal value.
@@ -101,8 +137,8 @@
1: the unsupported option key
2: the legal value
UNSUPPORTED_OPTION_WITH_LEGAL_VALUES:
- template: "The option '{1}' isn't supported by '{0}'."
- tip: "Try using one of the supported options: {2}."
+ problemMessage: "The option '{1}' isn't supported by '{0}'."
+ correctionMessage: "Try using one of the supported options: {2}."
comment: |-
An error code indicating that a plugin is being configured with an
unsupported option and legal options are provided.
@@ -112,8 +148,8 @@
1: the unsupported option key
2: legal values
UNSUPPORTED_VALUE:
- template: "The value '{1}' isn't supported by '{0}'."
- tip: "Try using one of the supported options: {2}."
+ problemMessage: "The value '{1}' isn't supported by '{0}'."
+ correctionMessage: "Try using one of the supported options: {2}."
comment: |-
An error code indicating that an option entry is being configured with an
unsupported value.
@@ -125,8 +161,8 @@
CompileTimeErrorCode:
ABSTRACT_FIELD_CONSTRUCTOR_INITIALIZER:
sharedName: ABSTRACT_FIELD_INITIALIZER
- template: "Abstract fields can't have initializers."
- tip: "Try removing the field initializer or the 'abstract' keyword from the field declaration."
+ problemMessage: "Abstract fields can't have initializers."
+ correctionMessage: "Try removing the field initializer or the 'abstract' keyword from the field declaration."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -175,12 +211,12 @@
}
```
ABSTRACT_FIELD_INITIALIZER:
- template: "Abstract fields can't have initializers."
- tip: "Try removing the initializer or the 'abstract' keyword."
+ problemMessage: "Abstract fields can't have initializers."
+ correctionMessage: "Try removing the initializer or the 'abstract' keyword."
hasPublishedDocs: true
comment: No parameters.
ABSTRACT_SUPER_MEMBER_REFERENCE:
- template: "The {0} '{1}' is always abstract in the supertype."
+ problemMessage: "The {0} '{1}' is always abstract in the supertype."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -214,8 +250,8 @@
TODO(brianwilkerson) This either needs to be generalized (use 'member'
rather than '{0}') or split into multiple codes.
AMBIGUOUS_EXPORT:
- template: "The name '{0}' is defined in the libraries '{1}' and '{2}'."
- tip: Try removing the export of one of the libraries, or explicitly hiding the name in one of the export directives.
+ problemMessage: "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
comment: |-
Parameters:
@@ -269,8 +305,8 @@
export 'b.dart' hide C;
```
AMBIGUOUS_EXTENSION_MEMBER_ACCESS:
- template: "A member named '{0}' is defined in extensions {1}, and none are more specific."
- tip: Try using an extension override to specify the extension you want to be chosen.
+ problemMessage: "A member named '{0}' is defined in extensions {1}, and none are more specific."
+ correctionMessage: Try using an extension override to specify the extension you want to be chosen.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -333,8 +369,8 @@
}
```
AMBIGUOUS_IMPORT:
- template: "The name '{0}' is defined in the libraries {1}."
- tip: "Try using 'as prefix' for one of the import directives, or hiding the name from all but one of the imports."
+ problemMessage: "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
comment: |-
Parameters:
@@ -406,8 +442,8 @@
void f(a.C c1, b.C c2) {}
```
AMBIGUOUS_SET_OR_MAP_LITERAL_BOTH:
- template: "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."
- tip: Try removing or changing some of the elements so that all of the elements are consistent.
+ problemMessage: "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
comment: No parameters.
documentation: |-
@@ -460,8 +496,8 @@
{...a, for (String s in b) s: s, ...c};
```
AMBIGUOUS_SET_OR_MAP_LITERAL_EITHER:
- template: "This literal must be either a map or a set, but the elements don't have enough information for type inference to work."
- tip: Try adding type arguments to the literal (one for sets, two for maps).
+ problemMessage: "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
comment: No parameters.
documentation: |-
@@ -534,7 +570,7 @@
}
```
ARGUMENT_TYPE_NOT_ASSIGNABLE:
- template: "The argument type '{0}' can't be assigned to the parameter type '{1}'."
+ problemMessage: "The argument type '{0}' can't be assigned to the parameter type '{1}'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -595,7 +631,7 @@
String g(num y) => f(y as String);
```
ASSERT_IN_REDIRECTING_CONSTRUCTOR:
- template: "A redirecting constructor can't have an 'assert' initializer."
+ problemMessage: "A redirecting constructor can't have an 'assert' initializer."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -642,8 +678,8 @@
}
```
ASSIGNMENT_TO_CONST:
- template: "Constant variables can't be assigned a value."
- tip: "Try removing the assignment, or remove the modifier 'const' from the variable."
+ problemMessage: "Constant variables can't be assigned a value."
+ correctionMessage: "Try removing the assignment, or remove the modifier 'const' from the variable."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -693,8 +729,8 @@
}
```
ASSIGNMENT_TO_FINAL:
- template: "'{0}' can't be used as a setter because it's final."
- tip: "Try finding a different setter, or making '{0}' non-final."
+ problemMessage: "'{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
comment: |-
Parameters:
@@ -735,8 +771,8 @@
}
```
ASSIGNMENT_TO_FINAL_LOCAL:
- template: "The final variable '{0}' can only be set once."
- tip: "Try making '{0}' non-final."
+ problemMessage: "The final variable '{0}' can only be set once."
+ correctionMessage: "Try making '{0}' non-final."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -771,8 +807,8 @@
}
```
ASSIGNMENT_TO_FINAL_NO_SETTER:
- template: "There isn’t a setter named '{0}' in class '{1}'."
- tip: Try correcting the name to reference an existing setter, or declare the setter.
+ problemMessage: "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
comment: No parameters.
documentation: |-
@@ -828,7 +864,7 @@
}
```
ASSIGNMENT_TO_FUNCTION:
- template: "Functions can't be assigned a value."
+ problemMessage: "Functions can't be assigned a value."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -875,7 +911,7 @@
}
```
ASSIGNMENT_TO_METHOD:
- template: "Methods can't be assigned a value."
+ problemMessage: "Methods can't be assigned a value."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -903,7 +939,7 @@
Rewrite the code so that there isn't an assignment to a method.
ASSIGNMENT_TO_TYPE:
- template: "Types can't be assigned a value."
+ problemMessage: "Types can't be assigned a value."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -939,8 +975,8 @@
}
```
ASYNC_FOR_IN_WRONG_CONTEXT:
- template: The async for-in loop can only be used in an async function.
- tip: "Try marking the function body with either 'async' or 'async*', or removing the 'await' before the for-in loop."
+ problemMessage: 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
comment: No parameters.
documentation: |-
@@ -998,8 +1034,8 @@
}
```
AWAIT_IN_LATE_LOCAL_VARIABLE_INITIALIZER:
- template: "The 'await' expression can't be used in a 'late' local variable's initializer."
- tip: "Try removing the 'late' modifier, or rewriting the initializer without using the 'await' expression."
+ problemMessage: "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
comment: No parameters.
documentation: |-
@@ -1040,15 +1076,15 @@
}
```
AWAIT_IN_WRONG_CONTEXT:
- template: The await expression can only be used in an async function.
- tip: "Try marking the function body with either 'async' or 'async*'."
+ problemMessage: The await expression can only be used in an async function.
+ correctionMessage: "Try marking the function body with either 'async' or 'async*'."
comment: |-
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.)
BODY_MIGHT_COMPLETE_NORMALLY:
- template: "The body might complete normally, causing 'null' to be returned, but the return type is a potentially non-nullable type."
- tip: Try adding either a return or a throw statement at the end.
+ problemMessage: "The body might complete normally, causing 'null' to be returned, but the return type is a potentially non-nullable type."
+ correctionMessage: Try adding either a return or a throw statement at the end.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -1122,7 +1158,7 @@
}
```
BREAK_LABEL_ON_SWITCH_MEMBER:
- template: "A break label resolves to the 'case' or 'default' statement."
+ problemMessage: "A break label resolves to the 'case' or 'default' statement."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -1177,8 +1213,8 @@
}
```
BUILT_IN_IDENTIFIER_AS_TYPE:
- template: "The built-in identifier '{0}' can't be used as a type."
- tip: Try correcting the name to match an existing type.
+ problemMessage: "The built-in identifier '{0}' can't be used as a type."
+ correctionMessage: Try correcting the name to match an existing type.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -1207,8 +1243,8 @@
```
BUILT_IN_IDENTIFIER_AS_EXTENSION_NAME:
sharedName: BUILT_IN_IDENTIFIER_IN_DECLARATION
- template: "The built-in identifier '{0}' can't be used as an extension name."
- tip: Try choosing a different name for the extension.
+ problemMessage: "The built-in identifier '{0}' can't be used as an extension name."
+ correctionMessage: Try choosing a different name for the extension.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -1235,39 +1271,39 @@
Choose a different name for the declaration.
BUILT_IN_IDENTIFIER_AS_PREFIX_NAME:
sharedName: BUILT_IN_IDENTIFIER_IN_DECLARATION
- template: "The built-in identifier '{0}' can't be used as a prefix name."
- tip: Try choosing a different name for the prefix.
+ problemMessage: "The built-in identifier '{0}' can't be used as a prefix name."
+ correctionMessage: Try choosing a different name for the prefix.
hasPublishedDocs: true
comment: |-
Parameters:
0: the built-in identifier that is being used
BUILT_IN_IDENTIFIER_AS_TYPE_NAME:
sharedName: BUILT_IN_IDENTIFIER_IN_DECLARATION
- template: "The built-in identifier '{0}' can't be used as a type name."
- tip: Try choosing a different name for the type.
+ problemMessage: "The built-in identifier '{0}' can't be used as a type name."
+ correctionMessage: Try choosing a different name for the type.
hasPublishedDocs: true
comment: |-
Parameters:
0: the built-in identifier that is being used
BUILT_IN_IDENTIFIER_AS_TYPE_PARAMETER_NAME:
sharedName: BUILT_IN_IDENTIFIER_IN_DECLARATION
- template: "The built-in identifier '{0}' can't be used as a type parameter name."
- tip: Try choosing a different name for the type parameter.
+ problemMessage: "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
comment: |-
Parameters:
0: the built-in identifier that is being used
BUILT_IN_IDENTIFIER_AS_TYPEDEF_NAME:
sharedName: BUILT_IN_IDENTIFIER_IN_DECLARATION
- template: "The built-in identifier '{0}' can't be used as a typedef name."
- tip: Try choosing a different name for the typedef.
+ problemMessage: "The built-in identifier '{0}' can't be used as a typedef name."
+ correctionMessage: Try choosing a different name for the typedef.
hasPublishedDocs: true
comment: |-
Parameters:
0: the built-in identifier that is being used
CASE_BLOCK_NOT_TERMINATED:
- template: "The last statement of the 'case' should be 'break', 'continue', 'rethrow', 'return', or 'throw'."
- tip: Try adding one of the required statements.
+ problemMessage: "The last statement of the 'case' should be 'break', 'continue', 'rethrow', 'return', or 'throw'."
+ correctionMessage: Try adding one of the required statements.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -1311,7 +1347,7 @@
}
```
CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS:
- template: "The switch case expression type '{0}' can't override the '==' operator."
+ problemMessage: "The switch case expression type '{0}' can't override the '==' operator."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -1412,7 +1448,7 @@
}
```
CASE_EXPRESSION_TYPE_IS_NOT_SWITCH_EXPRESSION_SUBTYPE:
- template: "The switch case expression type '{0}' must be a subtype of the switch expression type '{1}'."
+ problemMessage: "The switch case expression type '{0}' must be a subtype of the switch expression type '{1}'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -1465,8 +1501,8 @@
}
```
CAST_TO_NON_TYPE:
- template: "The name '{0}' isn't a type, so it can't be used in an 'as' expression."
- tip: "Try changing the name to the name of an existing type, or creating a type with the name '{0}'."
+ problemMessage: "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
comment: No parameters.
documentation: |-
@@ -1495,35 +1531,35 @@
```
CLASS_INSTANTIATION_ACCESS_TO_INSTANCE_MEMBER:
sharedName: CLASS_INSTANTIATION_ACCESS_TO_MEMBER
- template: "The instance member '{0}' can't be accessed on a class instantiation."
- tip: Try changing the member name to the name of a constructor.
+ problemMessage: "The instance member '{0}' can't be accessed on a class instantiation."
+ correctionMessage: Try changing the member name to the name of a constructor.
comment: |-
Parameters:
0: the name of the member
CLASS_INSTANTIATION_ACCESS_TO_UNKNOWN_MEMBER:
sharedName: CLASS_INSTANTIATION_ACCESS_TO_MEMBER
- template: "The class '{0} doesn't have a constructor named '{1}."
- tip: "Try invoking a different constructor, or defining a constructor named '{1}'."
+ problemMessage: "The class '{0} doesn't have a constructor named '{1}."
+ correctionMessage: "Try invoking a different constructor, or defining a constructor named '{1}'."
comment: |-
Parameters:
0: the name of the member
CLASS_INSTANTIATION_ACCESS_TO_STATIC_MEMBER:
sharedName: CLASS_INSTANTIATION_ACCESS_TO_MEMBER
- template: "The static member '{0}' can't be accessed on a class instantiation."
- tip: Try removing the type arguments from the class name, or changing the member name to the name of a constructor.
+ problemMessage: "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.
comment: |-
Parameters:
0: the name of the member
NON_CONSTANT_MAP_KEY_FROM_DEFERRED_LIBRARY:
sharedName: COLLECTION_ELEMENT_FROM_DEFERRED_LIBRARY
- template: "Constant values from a deferred library can't be used as keys in a 'const' map literal."
- tip: "Try removing the keyword 'const' from the map literal or removing the keyword 'deferred' from the import."
+ problemMessage: "Constant values from a deferred library can't be used as keys in a 'const' map literal."
+ correctionMessage: "Try removing the keyword 'const' from the map literal or removing the keyword 'deferred' from the import."
hasPublishedDocs: true
comment: No parameters.
NON_CONSTANT_LIST_ELEMENT_FROM_DEFERRED_LIBRARY:
sharedName: COLLECTION_ELEMENT_FROM_DEFERRED_LIBRARY
- template: "Constant values from a deferred library can't be used as values in a 'const' list literal."
- tip: "Try removing the keyword 'const' from the list literal or removing the keyword 'deferred' from the import."
+ problemMessage: "Constant values from a deferred library can't be used as values in a 'const' list literal."
+ correctionMessage: "Try removing the keyword 'const' from the list literal or removing the keyword 'deferred' from the import."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -1585,19 +1621,19 @@
```
SET_ELEMENT_FROM_DEFERRED_LIBRARY:
sharedName: COLLECTION_ELEMENT_FROM_DEFERRED_LIBRARY
- template: "Constant values from a deferred library can't be used as values in a 'const' set literal."
- tip: "Try removing the keyword 'const' from the set literal or removing the keyword 'deferred' from the import."
+ problemMessage: "Constant values from a deferred library can't be used as values in a 'const' set literal."
+ correctionMessage: "Try removing the keyword 'const' from the set literal or removing the keyword 'deferred' from the import."
hasPublishedDocs: true
comment: No parameters.
NON_CONSTANT_MAP_VALUE_FROM_DEFERRED_LIBRARY:
sharedName: COLLECTION_ELEMENT_FROM_DEFERRED_LIBRARY
- template: "Constant values from a deferred library can't be used as values in a 'const' map literal."
- tip: "Try removing the keyword 'const' from the map literal or removing the keyword 'deferred' from the import."
+ problemMessage: "Constant values from a deferred library can't be used as values in a 'const' map literal."
+ correctionMessage: "Try removing the keyword 'const' from the map literal or removing the keyword 'deferred' from the import."
hasPublishedDocs: true
comment: No parameters.
CONCRETE_CLASS_WITH_ABSTRACT_MEMBER:
- template: "'{0}' must have a method body because '{1}' isn't abstract."
- tip: "Try making '{1}' abstract, or adding a body to '{0}'."
+ problemMessage: "'{0}' must have a method body because '{1}' isn't abstract."
+ correctionMessage: "Try making '{1}' abstract, or adding a body to '{0}'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -1642,8 +1678,8 @@
```
CONFLICTING_CONSTRUCTOR_AND_STATIC_FIELD:
sharedName: CONFLICTING_CONSTRUCTOR_AND_STATIC_MEMBER
- template: "'{0}' can't be used to name both a constructor and a static field in this class."
- tip: Try renaming either the constructor or the field.
+ problemMessage: "'{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
comment: |-
Parameters:
@@ -1683,31 +1719,31 @@
Rename either the member or the constructor.
CONFLICTING_CONSTRUCTOR_AND_STATIC_GETTER:
sharedName: CONFLICTING_CONSTRUCTOR_AND_STATIC_MEMBER
- template: "'{0}' can't be used to name both a constructor and a static getter in this class."
- tip: Try renaming either the constructor or the getter.
+ problemMessage: "'{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
comment: |-
Parameters:
0: the name of the constructor and getter
CONFLICTING_CONSTRUCTOR_AND_STATIC_METHOD:
sharedName: CONFLICTING_CONSTRUCTOR_AND_STATIC_MEMBER
- template: "'{0}' can't be used to name both a constructor and a static method in this class."
- tip: Try renaming either the constructor or the method.
+ problemMessage: "'{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
comment: |-
Parameters:
0: the name of the constructor
CONFLICTING_CONSTRUCTOR_AND_STATIC_SETTER:
sharedName: CONFLICTING_CONSTRUCTOR_AND_STATIC_MEMBER
- template: "'{0}' can't be used to name both a constructor and a static setter in this class."
- tip: Try renaming either the constructor or the setter.
+ problemMessage: "'{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
comment: |-
Parameters:
0: the name of the constructor and setter
CONFLICTING_FIELD_AND_METHOD:
- template: "Class '{0}' can't define field '{1}' and have method '{2}.{1}' with the same name."
- tip: "Try converting the getter to a method, or renaming the field to a name that doesn't conflict."
+ problemMessage: "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."
comment: |-
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
@@ -1718,7 +1754,7 @@
1: the name of the conflicting field
2: the name of the class defining the method with which the field conflicts
CONFLICTING_GENERIC_INTERFACES:
- template: "The class '{0}' can't implement both '{1}' and '{2}' because the type arguments are different."
+ problemMessage: "The class '{0}' can't implement both '{1}' and '{2}' because the type arguments are different."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -1758,8 +1794,8 @@
class C extends A<String> implements B {}
```
CONFLICTING_METHOD_AND_FIELD:
- template: "Class '{0}' can't define method '{1}' and have field '{2}.{1}' with the same name."
- tip: "Try converting the method to a getter, or renaming the method to a name that doesn't conflict."
+ problemMessage: "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."
comment: |-
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
@@ -1770,8 +1806,8 @@
1: the name of the conflicting method
2: the name of the class defining the field with which the method conflicts
CONFLICTING_STATIC_AND_INSTANCE:
- template: "Class '{0}' can't define static member '{1}' and have instance member '{2}.{1}' with the same name."
- tip: "Try renaming the member to a name that doesn't conflict."
+ problemMessage: "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."
comment: |-
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
@@ -1783,8 +1819,8 @@
2: the name of the class defining the field with which the method conflicts
CONFLICTING_TYPE_VARIABLE_AND_CLASS:
sharedName: CONFLICTING_TYPE_VARIABLE_AND_CONTAINER
- template: "'{0}' can't be used to name both a type variable and the class in which the type variable is defined."
- tip: Try renaming either the type variable or the class.
+ problemMessage: "'{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
comment: |-
Parameters:
@@ -1814,24 +1850,24 @@
```
CONFLICTING_TYPE_VARIABLE_AND_EXTENSION:
sharedName: CONFLICTING_TYPE_VARIABLE_AND_CONTAINER
- template: "'{0}' can't be used to name both a type variable and the extension in which the type variable is defined."
- tip: Try renaming either the type variable or the extension.
+ problemMessage: "'{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
comment: |-
Parameters:
0: the name of the type variable
CONFLICTING_TYPE_VARIABLE_AND_MIXIN:
sharedName: CONFLICTING_TYPE_VARIABLE_AND_CONTAINER
- template: "'{0}' can't be used to name both a type variable and the mixin in which the type variable is defined."
- tip: Try renaming either the type variable or the mixin.
+ problemMessage: "'{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
comment: |-
Parameters:
0: the name of the type variable
CONFLICTING_TYPE_VARIABLE_AND_MEMBER_CLASS:
sharedName: CONFLICTING_TYPE_VARIABLE_AND_MEMBER
- template: "'{0}' can't be used to name both a type variable and a member in this class."
- tip: Try renaming either the type variable or the member.
+ problemMessage: "'{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
comment: |-
Parameters:
@@ -1865,29 +1901,29 @@
```
CONFLICTING_TYPE_VARIABLE_AND_MEMBER_MIXIN:
sharedName: CONFLICTING_TYPE_VARIABLE_AND_MEMBER
- template: "'{0}' can't be used to name both a type variable and a member in this mixin."
- tip: Try renaming either the type variable or the member.
+ problemMessage: "'{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
comment: |-
Parameters:
0: the name of the type variable
CONFLICTING_TYPE_VARIABLE_AND_MEMBER_EXTENSION:
sharedName: CONFLICTING_TYPE_VARIABLE_AND_MEMBER
- template: "'{0}' can't be used to name both a type variable and a member in this extension."
- tip: Try renaming either the type variable or the member.
+ problemMessage: "'{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
comment: |-
Parameters:
0: the name of the type variable
CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH:
- template: "In a const constructor, a value of type '{0}' can't be assigned to the field '{1}', which has type '{2}'."
- tip: "Try using a subtype, or removing the keyword 'const'."
+ problemMessage: "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'."
comment: |-
16.12.2 Const: It is a compile-time error if evaluation of a constant
object results in an uncaught exception being thrown.
CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH:
- template: "A value of type '{0}' can't be assigned to a parameter of type '{1}' in a const constructor."
- tip: "Try using a subtype, or removing the keyword 'const'."
+ problemMessage: "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
comment: |-
Parameters:
@@ -1937,14 +1973,14 @@
}
```
CONST_CONSTRUCTOR_THROWS_EXCEPTION:
- template: "Const constructors can't throw exceptions."
- tip: "Try removing the throw statement, or removing the keyword 'const'."
+ problemMessage: "Const constructors can't throw exceptions."
+ correctionMessage: "Try removing the throw statement, or removing the keyword 'const'."
comment: |-
16.12.2 Const: It is a compile-time error if evaluation of a constant
object results in an uncaught exception being thrown.
CONST_CONSTRUCTOR_WITH_FIELD_INITIALIZED_BY_NON_CONST:
- template: "Can't define the 'const' constructor because the field '{0}' is initialized with a non-constant value."
- tip: "Try initializing the field to a constant value, or removing the keyword 'const' from the constructor."
+ problemMessage: "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
comment: |-
Parameters:
@@ -1989,8 +2025,8 @@
}
```
CONST_CONSTRUCTOR_WITH_MIXIN_WITH_FIELD:
- template: "This constructor can't be declared 'const' because a mixin adds the instance field: {0}."
- tip: "Try removing the 'const' keyword or removing the 'with' clause from the class declaration, or removing the field from the mixin class."
+ problemMessage: "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."
comment: |-
7.6.3 Constant Constructors: The superinitializer that appears, explicitly
or implicitly, in the initializer list of a constant constructor must
@@ -2006,8 +2042,8 @@
0: the name of the instance field.
CONST_CONSTRUCTOR_WITH_MIXIN_WITH_FIELDS:
sharedName: CONST_CONSTRUCTOR_WITH_MIXIN_WITH_FIELD
- template: "This constructor can't be declared 'const' because the mixins add the instance fields: {0}."
- tip: "Try removing the 'const' keyword or removing the 'with' clause from the class declaration, or removing the fields from the mixin classes."
+ problemMessage: "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."
comment: |-
7.6.3 Constant Constructors: The superinitializer that appears, explicitly
or implicitly, in the initializer list of a constant constructor must
@@ -2022,8 +2058,8 @@
Parameters:
0: the names of the instance fields.
CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER:
- template: "A constant constructor can't call a non-constant super constructor of '{0}'."
- tip: "Try calling a constant constructor in the superclass, or removing the keyword 'const' from the constructor."
+ problemMessage: "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
comment: |-
Parameters:
@@ -2097,8 +2133,8 @@
}
```
CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD:
- template: "Can't define a const constructor for a class with non-final fields."
- tip: "Try making all of the fields final, or removing the keyword 'const' from the constructor."
+ problemMessage: "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
comment: No parameters.
documentation: |-
@@ -2144,8 +2180,8 @@
}
```
CONST_DEFERRED_CLASS:
- template: "Deferred classes can't be created with 'const'."
- tip: "Try using 'new' to create the instance, or changing the import to not be deferred."
+ problemMessage: "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
comment: No parameters.
documentation: |-
@@ -2190,51 +2226,51 @@
const json2 = convert.JsonCodec();
```
CONST_EVAL_THROWS_EXCEPTION:
- template: Evaluation of this constant expression throws an exception.
+ problemMessage: Evaluation of this constant expression throws an exception.
comment: |-
16.12.2 Const: It is a compile-time error if evaluation of a constant
object results in an uncaught exception being thrown.
CONST_EVAL_THROWS_IDBZE:
- template: Evaluation of this constant expression throws an IntegerDivisionByZeroException.
+ problemMessage: Evaluation of this constant expression throws an IntegerDivisionByZeroException.
comment: |-
16.12.2 Const: It is a compile-time error if evaluation of a constant
object results in an uncaught exception being thrown.
CONST_EVAL_TYPE_BOOL:
- template: "In constant expressions, operands of this operator must be of type 'bool'."
+ problemMessage: "In constant expressions, operands of this operator must be of type 'bool'."
comment: |-
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.
CONST_EVAL_TYPE_BOOL_INT:
- template: "In constant expressions, operands of this operator must be of type 'bool' or 'int'."
+ problemMessage: "In constant expressions, operands of this operator must be of type 'bool' or 'int'."
comment: |-
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.
CONST_EVAL_TYPE_BOOL_NUM_STRING:
- template: "In constant expressions, operands of this operator must be of type 'bool', 'num', 'String' or 'null'."
+ problemMessage: "In constant expressions, operands of this operator must be of type 'bool', 'num', 'String' or 'null'."
comment: |-
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.
CONST_EVAL_TYPE_INT:
- template: "In constant expressions, operands of this operator must be of type 'int'."
+ problemMessage: "In constant expressions, operands of this operator must be of type 'int'."
comment: |-
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.
CONST_EVAL_TYPE_NUM:
- template: "In constant expressions, operands of this operator must be of type 'num'."
+ problemMessage: "In constant expressions, operands of this operator must be of type 'num'."
comment: |-
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.
CONST_EVAL_TYPE_TYPE:
- template: "In constant expressions, operands of this operator must be of type 'Type'."
+ problemMessage: "In constant expressions, operands of this operator must be of type 'Type'."
CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE:
- template: Const variables must be initialized with a constant value.
- tip: Try changing the initializer to be a constant expression.
+ problemMessage: Const variables must be initialized with a constant value.
+ correctionMessage: Try changing the initializer to be a constant expression.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -2272,8 +2308,8 @@
final y = x;
```
CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE_FROM_DEFERRED_LIBRARY:
- template: "Constant values from a deferred library can't be used to initialize a 'const' variable."
- tip: Try initializing the variable without referencing members of the deferred library, or changing the import to not be deferred.
+ problemMessage: "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
comment: No parameters.
documentation: |-
@@ -2317,8 +2353,8 @@
const pi = 3.14;
```
CONST_INSTANCE_FIELD:
- template: Only static fields can be declared as const.
- tip: "Try declaring the field as final, or adding the keyword 'static'."
+ problemMessage: Only static fields can be declared as const.
+ correctionMessage: "Try declaring the field as final, or adding the keyword 'static'."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -2357,8 +2393,8 @@
}
```
CONST_MAP_KEY_EXPRESSION_TYPE_IMPLEMENTS_EQUALS:
- template: "The type of a key in a constant map can't override the '==' operator, but the class '{0}' does."
- tip: "Try using a different value for the key, or removing the keyword 'const' from the map."
+ problemMessage: "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
comment: |-
Parameters:
@@ -2413,8 +2449,8 @@
final map = {C() : 0};
```
CONST_NOT_INITIALIZED:
- template: "The constant '{0}' must be initialized."
- tip: Try adding an initialization to the declaration.
+ problemMessage: "The constant '{0}' must be initialized."
+ correctionMessage: Try adding an initialization to the declaration.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -2441,8 +2477,8 @@
const c = 'c';
```
CONST_SET_ELEMENT_TYPE_IMPLEMENTS_EQUALS:
- template: "The type of an element in a constant set can't override the '==' operator, but the type '{0}' does."
- tip: "Try using a different value for the element, or removing the keyword 'const' from the set."
+ problemMessage: "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
comment: |-
Parameters:
@@ -2497,7 +2533,7 @@
final set = {C()};
```
CONST_SPREAD_EXPECTED_LIST_OR_SET:
- template: A list or a set is expected in this spread.
+ problemMessage: A list or a set is expected in this spread.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -2529,7 +2565,7 @@
const List<int> list2 = [...list1];
```
CONST_SPREAD_EXPECTED_MAP:
- template: A map is expected in this spread.
+ problemMessage: A map is expected in this spread.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -2559,8 +2595,8 @@
const Map<String, int> map2 = {...map1};
```
CONST_WITH_NON_CONST:
- template: "The constructor being called isn't a const constructor."
- tip: "Try removing 'const' from the constructor invocation."
+ problemMessage: "The constructor being called isn't a const constructor."
+ correctionMessage: "Try removing 'const' from the constructor invocation."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -2606,8 +2642,8 @@
A f() => A();
```
CONST_WITH_NON_CONSTANT_ARGUMENT:
- template: Arguments of a constant creation must be constant expressions.
- tip: "Try making the argument a valid constant, or use 'new' to call the constructor."
+ problemMessage: 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
comment: No parameters.
documentation: |-
@@ -2641,8 +2677,8 @@
C f(int i) => C(i);
```
CONST_WITH_TYPE_PARAMETERS:
- template: "A constant creation can't use a type parameter as a type argument."
- tip: Try replacing the type parameter with a different type.
+ problemMessage: "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
comment: No parameters.
documentation: |-
@@ -2691,19 +2727,19 @@
```
CONST_WITH_TYPE_PARAMETERS_CONSTRUCTOR_TEAROFF:
sharedName: CONST_WITH_TYPE_PARAMETERS
- template: "A constant constructor tearoff can't use a type parameter as a type argument."
- tip: Try replacing the type parameter with a different type.
+ problemMessage: "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
comment: No parameters.
CONST_WITH_TYPE_PARAMETERS_FUNCTION_TEAROFF:
sharedName: CONST_WITH_TYPE_PARAMETERS
- template: "A constant function tearoff can't use a type parameter as a type argument."
- tip: Try replacing the type parameter with a different type.
+ problemMessage: "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
comment: No parameters.
CONST_WITH_UNDEFINED_CONSTRUCTOR:
- template: "The class '{0}' doesn't have a constant constructor '{1}'."
- tip: Try calling a different constructor.
+ problemMessage: "The class '{0}' doesn't have a constant constructor '{1}'."
+ correctionMessage: Try calling a different constructor.
comment: |-
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>.
@@ -2712,8 +2748,8 @@
0: the name of the type
1: the name of the requested constant constructor
CONST_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT:
- template: "The class '{0}' doesn't have an unnamed constant constructor."
- tip: Try calling a different constructor.
+ problemMessage: "The class '{0}' doesn't have an unnamed constant constructor."
+ correctionMessage: Try calling a different constructor.
comment: |-
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>.
@@ -2721,17 +2757,17 @@
Parameters:
0: the name of the type
CONTINUE_LABEL_ON_SWITCH:
- template: A continue label resolves to switch, must be loop or switch member
+ problemMessage: A continue label resolves to switch, must be loop or switch member
COULD_NOT_INFER:
- template: "Couldn't infer type parameter '{0}'.{1}"
+ problemMessage: "Couldn't infer type parameter '{0}'.{1}"
comment: |-
Parameters:
0: the name of the type parameter
1: detail text explaining why the type could not be inferred
NEW_WITH_NON_TYPE:
sharedName: CREATION_WITH_NON_TYPE
- template: "The name '{0}' isn't a class."
- tip: Try correcting the name to match an existing class.
+ problemMessage: "The name '{0}' isn't a class."
+ correctionMessage: Try correcting the name to match an existing class.
isUnresolvedIdentifier: true
hasPublishedDocs: true
comment: |-
@@ -2781,16 +2817,16 @@
```
CONST_WITH_NON_TYPE:
sharedName: CREATION_WITH_NON_TYPE
- template: "The name '{0}' isn't a class."
- tip: Try correcting the name to match an existing class.
+ problemMessage: "The name '{0}' isn't a class."
+ correctionMessage: Try correcting the name to match an existing class.
isUnresolvedIdentifier: true
hasPublishedDocs: true
comment: |-
Parameters:
0: the name of the non-type element
DEFAULT_LIST_CONSTRUCTOR:
- template: "The default 'List' constructor isn't available when null safety is enabled."
- tip: "Try using a list literal, 'List.filled' or 'List.generate'."
+ problemMessage: "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
comment: No parameters.
documentation: |-
@@ -2831,8 +2867,8 @@
var l = List.generate(3, (i) => i);
```
DEFAULT_VALUE_IN_REDIRECTING_FACTORY_CONSTRUCTOR:
- template: "Default values aren't allowed in factory constructors that redirect to another constructor."
- tip: Try removing the default value.
+ problemMessage: "Default values aren't allowed in factory constructors that redirect to another constructor."
+ correctionMessage: Try removing the default value.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -2885,8 +2921,8 @@
}
```
DEFAULT_VALUE_ON_REQUIRED_PARAMETER:
- template: "Required named parameters can't have a default value."
- tip: "Try removing either the default value or the 'required' modifier."
+ problemMessage: "Required named parameters can't have a default value."
+ correctionMessage: "Try removing either the default value or the 'required' modifier."
comment: No parameters.
documentation: |-
#### Description
@@ -2919,8 +2955,8 @@
void log({String message = 'no message'}) {}
```
DEFERRED_IMPORT_OF_EXTENSION:
- template: Imports of deferred libraries must hide all extensions.
- tip: Try adding either a show combinator listing the names you need to reference or a hide combinator listing all of the extensions.
+ problemMessage: 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
comment: No parameters.
documentation: |-
@@ -2998,8 +3034,8 @@
}
```
DEFINITELY_UNASSIGNED_LATE_LOCAL_VARIABLE:
- template: "The late local variable '{0}' is definitely unassigned at this point."
- tip: Ensure that it is assigned on necessary execution paths.
+ problemMessage: "The late local variable '{0}' is definitely unassigned at this point."
+ correctionMessage: Ensure that it is assigned on necessary execution paths.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -3035,21 +3071,21 @@
}
```
DISALLOWED_TYPE_INSTANTIATION_EXPRESSION:
- template: Only a generic type, generic function, generic instance method, or generic constructor can be type instantiated.
- tip: Try instantiating the type(s) of a generic type, generic function, generic instance method, or generic constructor.
+ problemMessage: 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.
comment: No parameters.
DUPLICATE_CONSTRUCTOR_NAME:
sharedName: DUPLICATE_CONSTRUCTOR
- template: "The constructor with name '{0}' is already defined."
- tip: Try renaming one of the constructors.
+ problemMessage: "The constructor with name '{0}' is already defined."
+ correctionMessage: Try renaming one of the constructors.
hasPublishedDocs: true
comment: |-
Parameters:
0: the name of the duplicate entity
DUPLICATE_CONSTRUCTOR_DEFAULT:
sharedName: DUPLICATE_CONSTRUCTOR
- template: The unnamed constructor is already defined.
- tip: Try giving one of the constructors a name.
+ problemMessage: The unnamed constructor is already defined.
+ correctionMessage: Try giving one of the constructors a name.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -3125,8 +3161,8 @@
}
```
DUPLICATE_DEFINITION:
- template: "The name '{0}' is already defined."
- tip: Try renaming one of the declarations.
+ problemMessage: "The name '{0}' is already defined."
+ correctionMessage: Try renaming one of the declarations.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -3156,8 +3192,8 @@
int y = 1;
```
DUPLICATE_FIELD_FORMAL_PARAMETER:
- template: "The field '{0}' can't be initialized by multiple parameters in the same constructor."
- tip: Try removing one of the parameters, or using different fields.
+ problemMessage: "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
comment: |-
Parameters:
@@ -3194,8 +3230,8 @@
}
```
DUPLICATE_NAMED_ARGUMENT:
- template: "The argument for the named parameter '{0}' was already specified."
- tip: Try removing one of the named arguments, or correcting one of the names to reference a different named parameter.
+ problemMessage: "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
comment: |-
Parameters:
@@ -3250,8 +3286,8 @@
}
```
DUPLICATE_PART:
- template: "The library already contains a part with the URI '{0}'."
- tip: Try removing all except one of the duplicated part directives.
+ problemMessage: "The library already contains a part with the URI '{0}'."
+ correctionMessage: Try removing all except one of the duplicated part directives.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -3291,11 +3327,11 @@
part 'part.dart';
```
ENUM_CONSTANT_SAME_NAME_AS_ENCLOSING:
- template: "The name of the enum constant can't be the same as the enum's name."
- tip: Try renaming the constant.
+ problemMessage: "The name of the enum constant can't be the same as the enum's name."
+ correctionMessage: Try renaming the constant.
EQUAL_ELEMENTS_IN_CONST_SET:
- template: "Two elements in a constant set literal can't be equal."
- tip: Change or remove the duplicate element.
+ problemMessage: "Two elements in a constant set literal can't be equal."
+ correctionMessage: Change or remove the duplicate element.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -3326,8 +3362,8 @@
of which element to remove might affect the order in which elements are
returned by an iterator.
EQUAL_KEYS_IN_CONST_MAP:
- template: "Two keys in a constant map literal can't be equal."
- tip: Change or remove the duplicate key.
+ problemMessage: "Two keys in a constant map literal can't be equal."
+ correctionMessage: Change or remove the duplicate key.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -3367,8 +3403,8 @@
of which entry to remove might affect the order in which keys and values
are returned by an iterator.
EXPECTED_ONE_LIST_TYPE_ARGUMENTS:
- template: "List literals require one type argument or none, but {0} found."
- tip: Try adjusting the number of type arguments.
+ problemMessage: "List literals require one type argument or none, but {0} found."
+ correctionMessage: Try adjusting the number of type arguments.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -3396,8 +3432,8 @@
var l = <int>[];
```
EXPECTED_ONE_SET_TYPE_ARGUMENTS:
- template: "Set literals require one type argument or none, but {0} were found."
- tip: Try adjusting the number of type arguments.
+ problemMessage: "Set literals require one type argument or none, but {0} were found."
+ correctionMessage: Try adjusting the number of type arguments.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -3425,8 +3461,8 @@
var s = <int>{0, 1};
```
EXPECTED_TWO_MAP_TYPE_ARGUMENTS:
- template: "Map literals require two type arguments or none, but {0} found."
- tip: Try adjusting the number of type arguments.
+ problemMessage: "Map literals require two type arguments or none, but {0} found."
+ correctionMessage: Try adjusting the number of type arguments.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -3454,7 +3490,7 @@
var m = <int, String>{};
```
EXPORT_INTERNAL_LIBRARY:
- template: "The library '{0}' is internal and can't be exported."
+ problemMessage: "The library '{0}' is internal and can't be exported."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -3478,8 +3514,8 @@
Remove the export directive.
EXPORT_LEGACY_SYMBOL:
- template: "The symbol '{0}' is defined in a legacy library, and can't be re-exported from a library with null safety enabled."
- tip: Try removing the export or migrating the legacy library.
+ problemMessage: "The symbol '{0}' is defined in a legacy library, and can't be re-exported from a library with null safety enabled."
+ correctionMessage: Try removing the export or migrating the legacy library.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -3531,8 +3567,8 @@
combinator to the export directive in your library that hides all of the
names declared in the opted-out library.
EXPORT_OF_NON_LIBRARY:
- template: "The exported library '{0}' can't have a part-of directive."
- tip: Try exporting the library that the part is a part of.
+ problemMessage: "The exported library '{0}' can't have a part-of directive."
+ correctionMessage: Try exporting the library that the part is a part of.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -3566,8 +3602,8 @@
Either remove the export directive, or change the URI to be the URI of the
library containing the part.
EXPRESSION_IN_MAP:
- template: "Expressions can't be used in a map literal."
- tip: Try removing the expression or converting it to be a map entry.
+ problemMessage: "Expressions can't be used in a map literal."
+ correctionMessage: Try removing the expression or converting it to be a map entry.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -3594,8 +3630,8 @@
var map = <String, int>{'a': 0, 'b': 1, 'c': 2};
```
EXTENDS_NON_CLASS:
- template: Classes can only extend other classes.
- tip: Try specifying a different superclass, or removing the extends clause.
+ problemMessage: Classes can only extend other classes.
+ correctionMessage: Try specifying a different superclass, or removing the extends clause.
isUnresolvedIdentifier: true
hasPublishedDocs: true
comment: |-
@@ -3639,8 +3675,8 @@
class C {}
```
EXTENSION_AS_EXPRESSION:
- template: "Extension '{0}' can't be used as an expression."
- tip: Try replacing it with a valid expression.
+ problemMessage: "Extension '{0}' can't be used as an expression."
+ correctionMessage: Try replacing it with a valid expression.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -3680,8 +3716,8 @@
var x = E.m();
```
EXTENSION_CONFLICTING_STATIC_AND_INSTANCE:
- template: "Extension '{0}' can't define static member '{1}' and an instance member with the same name."
- tip: "Try renaming the member to a name that doesn't conflict."
+ problemMessage: "Extension '{0}' can't define static member '{1}' and an instance member with the same name."
+ correctionMessage: "Try renaming the member to a name that doesn't conflict."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -3719,8 +3755,8 @@
}
```
EXTENSION_DECLARES_MEMBER_OF_OBJECT:
- template: "Extensions can't declare members with the same name as a member declared by 'Object'."
- tip: Try specifying a different name for the member.
+ problemMessage: "Extensions can't declare members with the same name as a member declared by 'Object'."
+ correctionMessage: Try specifying a different name for the member.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -3753,8 +3789,8 @@
}
```
EXTENSION_OVERRIDE_ACCESS_TO_STATIC_MEMBER:
- template: "An extension override can't be used to access a static member from an extension."
- tip: Try using just the name of the extension.
+ problemMessage: "An extension override can't be used to access a static member from an extension."
+ correctionMessage: Try using just the name of the extension.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -3793,7 +3829,7 @@
}
```
EXTENSION_OVERRIDE_ARGUMENT_NOT_ASSIGNABLE:
- template: "The type of the argument to the extension override '{0}' isn't assignable to the extended type '{1}'."
+ problemMessage: "The type of the argument to the extension override '{0}' isn't assignable to the extended type '{1}'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -3838,8 +3874,8 @@
then either replace the name of the extension or unwrap the argument so
that the correct extension is found.
EXTENSION_OVERRIDE_WITHOUT_ACCESS:
- template: An extension override can only be used to access instance members.
- tip: Consider adding an access to an instance member.
+ problemMessage: An extension override can only be used to access instance members.
+ correctionMessage: Consider adding an access to an instance member.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -3892,8 +3928,8 @@
}
```
EXTENSION_OVERRIDE_WITH_CASCADE:
- template: "Extension overrides have no value so they can't be used as the receiver of a cascade expression."
- tip: "Try using '.' instead of '..'."
+ problemMessage: "Extension overrides have no value so they can't be used as the receiver of a cascade expression."
+ correctionMessage: "Try using '.' instead of '..'."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -3934,17 +3970,17 @@
If there are multiple cascaded accesses, you'll need to duplicate the
extension override for each one.
EXTERNAL_FIELD_CONSTRUCTOR_INITIALIZER:
- template: External fields cannot have initializers.
- tip: "Try removing the field initializer or the 'external' keyword from the field declaration."
+ problemMessage: External fields cannot have initializers.
+ correctionMessage: "Try removing the field initializer or the 'external' keyword from the field declaration."
EXTERNAL_FIELD_INITIALIZER:
- template: External fields cannot have initializers.
- tip: "Try removing the initializer or the 'external' keyword."
+ problemMessage: External fields cannot have initializers.
+ correctionMessage: "Try removing the initializer or the 'external' keyword."
EXTERNAL_VARIABLE_INITIALIZER:
- template: External variables cannot have initializers.
- tip: "Try removing the initializer or the 'external' keyword."
+ problemMessage: External variables cannot have initializers.
+ correctionMessage: "Try removing the initializer or the 'external' keyword."
EXTRA_POSITIONAL_ARGUMENTS:
- template: "Too many positional arguments: {0} expected, but {1} found."
- tip: Try removing the extra arguments.
+ problemMessage: "Too many positional arguments: {0} expected, but {1} found."
+ correctionMessage: Try removing the extra arguments.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -3979,8 +4015,8 @@
}
```
EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED:
- template: "Too many positional arguments: {0} expected, but {1} found."
- tip: Try removing the extra positional arguments, or specifying the name for named arguments.
+ problemMessage: "Too many positional arguments: {0} expected, but {1} found."
+ correctionMessage: Try removing the extra positional arguments, or specifying the name for named arguments.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -4031,8 +4067,8 @@
}
```
FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS:
- template: "The field '{0}' can't be initialized twice in the same constructor."
- tip: Try removing one of the initializations.
+ problemMessage: "The field '{0}' can't be initialized twice in the same constructor."
+ correctionMessage: Try removing one of the initializations.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -4069,8 +4105,8 @@
}
```
FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION:
- template: "Fields can't be initialized in the constructor if they are final and were already initialized at their declaration."
- tip: Try removing one of the initializations.
+ problemMessage: "Fields can't be initialized in the constructor if they are final and were already initialized at their declaration."
+ correctionMessage: Try removing one of the initializations.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -4116,8 +4152,8 @@
}
```
FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER:
- template: "Fields can't be initialized in both the parameter list and the initializers."
- tip: Try removing one of the initializations.
+ problemMessage: "Fields can't be initialized in both the parameter list and the initializers."
+ correctionMessage: Try removing one of the initializations.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -4174,8 +4210,8 @@
}
```
FIELD_INITIALIZER_FACTORY_CONSTRUCTOR:
- template: "Initializing formal parameters can't be used in factory constructors."
- tip: Try using a normal parameter.
+ problemMessage: "Initializing formal parameters can't be used in factory constructors."
+ correctionMessage: Try using a normal parameter.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -4210,7 +4246,7 @@
}
```
FIELD_INITIALIZER_NOT_ASSIGNABLE:
- template: "The initializer type '{0}' can't be assigned to the field type '{1}'."
+ problemMessage: "The initializer type '{0}' can't be assigned to the field type '{1}'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -4261,23 +4297,23 @@
```
CONST_FIELD_INITIALIZER_NOT_ASSIGNABLE:
sharedName: FIELD_INITIALIZER_NOT_ASSIGNABLE
- template: "The initializer type '{0}' can't be assigned to the field type '{1}' in a const constructor."
- tip: "Try using a subtype, or removing the 'const' keyword"
+ problemMessage: "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
comment: |-
Parameters:
0: the name of the type of the initializer expression
1: the name of the type of the field
FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR:
- template: Initializing formal parameters can only be used in constructors.
- tip: Try using a normal parameter.
+ problemMessage: Initializing formal parameters can only be used in constructors.
+ correctionMessage: Try using a normal parameter.
comment: |-
7.6.1 Generative Constructors: It is a compile-time error if an
initializing formal is used by a function other than a non-redirecting
generative constructor.
FIELD_INITIALIZER_REDIRECTING_CONSTRUCTOR:
- template: "The redirecting constructor can't have a field initializer."
- tip: Try initializing the field in the constructor being redirected to.
+ problemMessage: "The redirecting constructor can't have a field initializer."
+ correctionMessage: Try initializing the field in the constructor being redirected to.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -4346,8 +4382,8 @@
}
```
FIELD_INITIALIZING_FORMAL_NOT_ASSIGNABLE:
- template: "The parameter type '{0}' is incompatible with the field type '{1}'."
- tip: "Try changing or removing the parameter's type, or changing the field's type."
+ problemMessage: "The parameter type '{0}' is incompatible with the field type '{1}'."
+ correctionMessage: "Try changing or removing the parameter's type, or changing the field's type."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -4410,8 +4446,8 @@
}
```
FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR:
- template: "'{0}' is final and was given a value when it was declared, so it can't be set to a new value."
- tip: Try removing one of the initializations.
+ problemMessage: "'{0}' is final and was given a value when it was declared, so it can't be set to a new value."
+ correctionMessage: Try removing one of the initializations.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -4459,8 +4495,8 @@
}
```
FINAL_NOT_INITIALIZED:
- template: "The final variable '{0}' must be initialized."
- tip: Try initializing the variable.
+ problemMessage: "The final variable '{0}' must be initialized."
+ correctionMessage: Try initializing the variable.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -4510,8 +4546,8 @@
```
FINAL_NOT_INITIALIZED_CONSTRUCTOR_1:
sharedName: FINAL_NOT_INITIALIZED_CONSTRUCTOR
- template: "All final variables must be initialized, but '{0}' isn't."
- tip: Try adding an initializer for the field.
+ problemMessage: "All final variables must be initialized, but '{0}' isn't."
+ correctionMessage: Try adding an initializer for the field.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -4600,8 +4636,8 @@
```
FINAL_NOT_INITIALIZED_CONSTRUCTOR_2:
sharedName: FINAL_NOT_INITIALIZED_CONSTRUCTOR
- template: "All final variables must be initialized, but '{0}' and '{1}' aren't."
- tip: Try adding initializers for the fields.
+ problemMessage: "All final variables must be initialized, but '{0}' and '{1}' aren't."
+ correctionMessage: Try adding initializers for the fields.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -4609,8 +4645,8 @@
1: the name of the uninitialized final variable
FINAL_NOT_INITIALIZED_CONSTRUCTOR_3_PLUS:
sharedName: FINAL_NOT_INITIALIZED_CONSTRUCTOR
- template: "All final variables must be initialized, but '{0}', '{1}', and {2} others aren't."
- tip: Try adding initializers for the fields.
+ problemMessage: "All final variables must be initialized, but '{0}', '{1}', and {2} others aren't."
+ correctionMessage: Try adding initializers for the fields.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -4618,7 +4654,7 @@
1: the name of the uninitialized final variable
2: the number of additional not initialized variables that aren't listed
FOR_IN_OF_INVALID_ELEMENT_TYPE:
- template: "The type '{0}' used in the 'for' loop must implement '{1}' with a type argument that can be assigned to '{2}'."
+ problemMessage: "The type '{0}' used in the 'for' loop must implement '{1}' with a type argument that can be assigned to '{2}'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -4670,7 +4706,7 @@
}
```
FOR_IN_OF_INVALID_TYPE:
- template: "The type '{0}' used in the 'for' loop must implement {1}."
+ problemMessage: "The type '{0}' used in the 'for' loop must implement {1}."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -4707,8 +4743,8 @@
}
```
FOR_IN_WITH_CONST_VARIABLE:
- template: "A for-in loop variable can't be a 'const'."
- tip: "Try removing the 'const' modifier from the variable, or use a different variable."
+ problemMessage: "A for-in loop variable can't be a 'const'."
+ correctionMessage: "Try removing the 'const' modifier from the variable, or use a different variable."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -4747,20 +4783,20 @@
}
```
GENERIC_FUNCTION_TYPE_CANNOT_BE_BOUND:
- template: "Generic function types can't be used as type parameter bounds"
- tip: Try making the free variable in the function type part of the larger declaration signature
+ problemMessage: "Generic function types can't be used as type parameter bounds"
+ correctionMessage: Try making the free variable in the function type part of the larger declaration signature
comment: |-
It is a compile-time error if a generic function type is used as a bound
for a formal type parameter of a class or a function.
GENERIC_FUNCTION_TYPE_CANNOT_BE_TYPE_ARGUMENT:
- template: "A generic function type can't be a type argument."
- tip: "Try removing type parameters from the generic function type, or using 'dynamic' as the type argument here."
+ problemMessage: "A generic function type can't be a type argument."
+ correctionMessage: "Try removing type parameters from the generic function type, or using 'dynamic' as the type argument here."
comment: |-
It is a compile-time error if a generic function type is used as an actual
type argument.
GENERIC_METHOD_TYPE_INSTANTIATION_ON_DYNAMIC:
- template: "A method tear-off on a receiver whose type is 'dynamic' can't have type arguments."
- tip: Specify the type of the receiver, or remove the type arguments from the method tear-off.
+ problemMessage: "A method tear-off on a receiver whose type is 'dynamic' can't have type arguments."
+ correctionMessage: Specify the type of the receiver, or remove the type arguments from the method tear-off.
comment: No parameters.
documentation: |-
#### Description
@@ -4802,8 +4838,8 @@
}
```
GETTER_NOT_ASSIGNABLE_SETTER_TYPES:
- template: "The return type of getter '{0}' is '{1}' which isn't assignable to the type '{2}' of its setter '{3}'."
- tip: Try changing the types so that they are compatible.
+ problemMessage: "The return type of getter '{0}' is '{1}' which isn't assignable to the type '{2}' of its setter '{3}'."
+ correctionMessage: Try changing the types so that they are compatible.
comment: |-
Parameters:
0: the name of the getter
@@ -4811,8 +4847,8 @@
2: the type of the setter
3: the name of the setter
GETTER_NOT_SUBTYPE_SETTER_TYPES:
- template: "The return type of getter '{0}' is '{1}' which isn't a subtype of the type '{2}' of its setter '{3}'."
- tip: Try changing the types so that they are compatible.
+ problemMessage: "The return type of getter '{0}' is '{1}' which isn't a subtype of the type '{2}' of its setter '{3}'."
+ correctionMessage: Try changing the types so that they are compatible.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -4866,11 +4902,11 @@
}
```
IF_ELEMENT_CONDITION_FROM_DEFERRED_LIBRARY:
- template: "Constant values from a deferred library can't be used as values in an if condition inside a const collection literal."
- tip: Try making the deferred import non-deferred.
+ problemMessage: "Constant values from a deferred library can't be used as values in an if condition inside a const collection literal."
+ correctionMessage: Try making the deferred import non-deferred.
ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE:
- template: "Functions marked 'async*' must have a return type that is a supertype of 'Stream<T>' for some type 'T'."
- tip: "Try fixing the return type of the function, or removing the modifier 'async*' from the function body."
+ problemMessage: "Functions marked 'async*' must have a return type that is a supertype of 'Stream<T>' for some type 'T'."
+ correctionMessage: "Try fixing the return type of the function, or removing the modifier 'async*' from the function body."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -4905,8 +4941,8 @@
int f() => 0;
```
ILLEGAL_ASYNC_RETURN_TYPE:
- template: "Functions marked 'async' must have a return type assignable to 'Future'."
- tip: "Try fixing the return type of the function, or removing the modifier 'async' from the function body."
+ problemMessage: "Functions marked 'async' must have a return type assignable to 'Future'."
+ correctionMessage: "Try fixing the return type of the function, or removing the modifier 'async' from the function body."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -4945,8 +4981,8 @@
int f() => 0;
```
ILLEGAL_SYNC_GENERATOR_RETURN_TYPE:
- template: "Functions marked 'sync*' must have a return type that is a supertype of 'Iterable<T>' for some type 'T'."
- tip: "Try fixing the return type of the function, or removing the modifier 'sync*' from the function body."
+ problemMessage: "Functions marked 'sync*' must have a return type that is a supertype of 'Iterable<T>' for some type 'T'."
+ correctionMessage: "Try fixing the return type of the function, or removing the modifier 'sync*' from the function body."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -4982,8 +5018,8 @@
int f() => 0;
```
IMPLEMENTS_NON_CLASS:
- template: Classes and mixins can only implement other classes and mixins.
- tip: Try specifying a class or mixin, or remove the name from the list.
+ problemMessage: Classes and mixins can only implement other classes and mixins.
+ correctionMessage: Try specifying a class or mixin, or remove the name from the list.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -5019,8 +5055,8 @@
of an existing class or mixin, or remove the name from the `implements`
clause.
IMPLEMENTS_REPEATED:
- template: "'{0}' can only be implemented once."
- tip: Try removing all but one occurrence of the class name.
+ problemMessage: "'{0}' can only be implemented once."
+ correctionMessage: Try removing all but one occurrence of the class name.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -5050,8 +5086,8 @@
class B implements A {}
```
IMPLEMENTS_SUPER_CLASS:
- template: "'{0}' can't be used in both the 'extends' and 'implements' clauses."
- tip: Try removing one of the occurrences.
+ problemMessage: "'{0}' can't be used in both the 'extends' and 'implements' clauses."
+ correctionMessage: Try removing one of the occurrences.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -5094,8 +5130,8 @@
class B implements A {}
```
IMPLICIT_THIS_REFERENCE_IN_INITIALIZER:
- template: "The instance member '{0}' can't be accessed in an initializer."
- tip: Try replacing the reference to the instance member with a different expression
+ problemMessage: "The instance member '{0}' can't be accessed in an initializer."
+ correctionMessage: Try replacing the reference to the instance member with a different expression
hasPublishedDocs: true
comment: |-
Parameters:
@@ -5148,7 +5184,7 @@
}
```
IMPORT_INTERNAL_LIBRARY:
- template: "The library '{0}' is internal and can't be imported."
+ problemMessage: "The library '{0}' is internal and can't be imported."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -5172,8 +5208,8 @@
Remove the import directive.
IMPORT_OF_NON_LIBRARY:
- template: "The imported library '{0}' can't have a part-of directive."
- tip: Try importing the library that the part is a part of.
+ problemMessage: "The imported library '{0}' can't have a part-of directive."
+ correctionMessage: Try importing the library that the part is a part of.
comment: |-
14.1 Imports: It is a compile-time error if the specified URI of an
immediate import does not refer to a library declaration.
@@ -5181,7 +5217,7 @@
Parameters:
0: the uri pointing to a non-library declaration
INCONSISTENT_CASE_EXPRESSION_TYPES:
- template: "Case expressions must have the same types, '{0}' isn't a '{1}'."
+ problemMessage: "Case expressions must have the same types, '{0}' isn't a '{1}'."
comment: |-
13.9 Switch: It is a compile-time error if values of the expressions
<i>e<sub>k</sub></i> are not instances of the same class <i>C</i>, for all
@@ -5191,8 +5227,8 @@
0: the expression source code that is the unexpected type
1: the name of the expected type
INCONSISTENT_INHERITANCE:
- template: "Superinterfaces don't have a valid override for '{0}': {1}."
- tip: Try adding an explicit override that is consistent with all of the inherited members.
+ problemMessage: "Superinterfaces don't have a valid override for '{0}': {1}."
+ correctionMessage: Try adding an explicit override that is consistent with all of the inherited members.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -5245,8 +5281,8 @@
}
```
INCONSISTENT_INHERITANCE_GETTER_AND_METHOD:
- template: "'{0}' is inherited as a getter (from '{1}') and also a method (from '{2}')."
- tip: Try adjusting the supertypes of this class to remove the inconsistency.
+ problemMessage: "'{0}' is inherited as a getter (from '{1}') and also a method (from '{2}')."
+ correctionMessage: Try adjusting the supertypes of this class to remove the inconsistency.
comment: |-
11.1.1 Inheritance and Overriding. Let `I` be the implicit interface of a
class `C` declared in library `L`. `I` inherits all members of
@@ -5259,7 +5295,7 @@
1: the name of the superinterface that declares the name as a getter.
2: the name of the superinterface that declares the name as a method.
INCONSISTENT_LANGUAGE_VERSION_OVERRIDE:
- template: Parts must have exactly the same language version override as the library.
+ problemMessage: Parts must have exactly the same language version override as the library.
comment: |-
It is a compile-time error if a part file has a different language version
override than its library.
@@ -5268,8 +5304,8 @@
future-releases/language-versioning/feature-specification.md
#individual-library-language-version-override
INITIALIZER_FOR_NON_EXISTENT_FIELD:
- template: "'{0}' isn't a field in the enclosing class."
- tip: "Try correcting the name to match an existing field, or defining a field named '{0}'."
+ problemMessage: "'{0}' isn't a field in the enclosing class."
+ correctionMessage: "Try correcting the name to match an existing field, or defining a field named '{0}'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -5323,8 +5359,8 @@
}
```
INITIALIZER_FOR_STATIC_FIELD:
- template: "'{0}' is a static field in the enclosing class. Fields initialized in a constructor can't be static."
- tip: Try removing the initialization.
+ problemMessage: "'{0}' is a static field in the enclosing class. Fields initialized in a constructor can't be static."
+ correctionMessage: Try removing the initialization.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -5383,8 +5419,8 @@
}
```
INITIALIZING_FORMAL_FOR_NON_EXISTENT_FIELD:
- template: "'{0}' isn't a field in the enclosing class."
- tip: "Try correcting the name to match an existing field, or defining a field named '{0}'."
+ problemMessage: "'{0}' isn't a field in the enclosing class."
+ correctionMessage: "Try correcting the name to match an existing field, or defining a field named '{0}'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -5462,8 +5498,8 @@
}
```
INSTANCE_ACCESS_TO_STATIC_MEMBER:
- template: "Static {1} '{0}' can't be accessed through an instance."
- tip: "Try using the class '{2}' to access the {1}."
+ problemMessage: "Static {1} '{0}' can't be accessed through an instance."
+ correctionMessage: "Try using the class '{2}' to access the {1}."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -5505,8 +5541,8 @@
}
```
INSTANCE_MEMBER_ACCESS_FROM_FACTORY:
- template: "Instance members can't be accessed from a factory constructor."
- tip: Try removing the reference to the instance member.
+ problemMessage: "Instance members can't be accessed from a factory constructor."
+ correctionMessage: Try removing the reference to the instance member.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -5549,8 +5585,8 @@
}
```
INSTANCE_MEMBER_ACCESS_FROM_STATIC:
- template: "Instance members can't be accessed from a static method."
- tip: "Try removing the reference to the instance member, or removing the keyword 'static' from the method."
+ problemMessage: "Instance members can't be accessed from a static method."
+ correctionMessage: "Try removing the reference to the instance member, or removing the keyword 'static' from the method."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -5605,8 +5641,8 @@
}
```
INSTANTIATE_ABSTRACT_CLASS:
- template: "Abstract classes can't be instantiated."
- tip: Try creating an instance of a concrete subtype.
+ problemMessage: "Abstract classes can't be instantiated."
+ correctionMessage: Try creating an instance of a concrete subtype.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -5633,8 +5669,8 @@
If there's a concrete subclass of the abstract class that can be used, then
create an instance of the concrete subclass.
INSTANTIATE_ENUM:
- template: "Enums can't be instantiated."
- tip: Try using one of the defined constants.
+ problemMessage: "Enums can't be instantiated."
+ correctionMessage: Try using one of the defined constants.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -5668,8 +5704,8 @@
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.
INSTANTIATE_TYPE_ALIAS_EXPANDS_TO_TYPE_PARAMETER:
- template: "Type aliases that expand to a type parameter can't be instantiated."
- tip: Try replacing it with a class.
+ problemMessage: "Type aliases that expand to a type parameter can't be instantiated."
+ correctionMessage: Try replacing it with a class.
comment: No parameters.
documentation: |-
#### Description
@@ -5710,8 +5746,8 @@
}
```
INTEGER_LITERAL_IMPRECISE_AS_DOUBLE:
- template: "The integer literal is being used as a double, but can't be represented as a 64-bit double without overflow or loss of precision: '{0}'."
- tip: "Try using the class 'BigInt', or switch to the closest valid double: '{1}'."
+ problemMessage: "The integer literal is being used as a double, but can't be represented as a 64-bit double without overflow or loss of precision: '{0}'."
+ correctionMessage: "Try using the class 'BigInt', or switch to the closest valid double: '{1}'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -5749,8 +5785,8 @@
double x = 9223372036854775808;
```
INTEGER_LITERAL_OUT_OF_RANGE:
- template: "The integer literal {0} can't be represented in 64 bits."
- tip: "Try using the 'BigInt' class if you need an integer larger than 9,223,372,036,854,775,807 or less than -9,223,372,036,854,775,808."
+ problemMessage: "The integer literal {0} can't be represented in 64 bits."
+ correctionMessage: "Try using the 'BigInt' class if you need an integer larger than 9,223,372,036,854,775,807 or less than -9,223,372,036,854,775,808."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -5778,7 +5814,7 @@
var x = BigInt.parse('9223372036854775810');
```
INVALID_ANNOTATION:
- template: Annotation must be either a const variable reference or const constructor invocation.
+ problemMessage: Annotation must be either a const variable reference or const constructor invocation.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -5849,8 +5885,8 @@
}
```
INVALID_ANNOTATION_CONSTANT_VALUE_FROM_DEFERRED_LIBRARY:
- template: "Constant values from a deferred library can't be used in annotations."
- tip: "Try moving the constant from the deferred library, or removing 'deferred' from the import."
+ problemMessage: "Constant values from a deferred library can't be used in annotations."
+ correctionMessage: "Try moving the constant from the deferred library, or removing 'deferred' from the import."
comment: No parameters.
documentation: |-
#### Description
@@ -5900,8 +5936,8 @@
is appropriate, then use that constant in place of the constant from the
deferred library.
INVALID_ANNOTATION_FROM_DEFERRED_LIBRARY:
- template: "Constant values from a deferred library can't be used as annotations."
- tip: Try removing the annotation, or changing the import to not be deferred.
+ problemMessage: "Constant values from a deferred library can't be used as annotations."
+ correctionMessage: Try removing the annotation, or changing the import to not be deferred.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -5948,8 +5984,8 @@
void f() {}
```
INVALID_ASSIGNMENT:
- template: "A value of type '{0}' can't be assigned to a variable of type '{1}'."
- tip: "Try changing the type of the variable, or casting the right-hand type to '{1}'."
+ problemMessage: "A value of type '{0}' can't be assigned to a variable of type '{1}'."
+ correctionMessage: "Try changing the type of the variable, or casting the right-hand type to '{1}'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -5994,55 +6030,55 @@
int s = i;
```
INVALID_CAST_FUNCTION:
- template: "The function '{0}' has type '{1}' that isn't of expected type '{2}'. This means its parameter or return type doesn't match what is expected."
+ problemMessage: "The function '{0}' has type '{1}' that isn't of expected type '{2}'. This means its parameter or return type doesn't match what is expected."
comment: |-
Parameters:
0: the type of the function
1: the expected function type
INVALID_CAST_FUNCTION_EXPR:
- template: "The function expression type '{0}' isn't of type '{1}'. This means its parameter or return type doesn't match what is expected. Consider changing parameter type(s) or the returned type(s)."
+ problemMessage: "The function expression type '{0}' isn't of type '{1}'. This means its parameter or return type doesn't match what is expected. Consider changing parameter type(s) or the returned type(s)."
comment: |-
Parameters:
0: the type of the torn-off function expression
1: the expected function type
INVALID_CAST_LITERAL:
- template: "The literal '{0}' with type '{1}' isn't of expected type '{2}'."
+ problemMessage: "The literal '{0}' with type '{1}' isn't of expected type '{2}'."
comment: |-
Parameters:
0: the type of the literal
1: the expected type
INVALID_CAST_LITERAL_LIST:
- template: "The list literal type '{0}' isn't of expected type '{1}'. The list's type can be changed with an explicit generic type argument or by changing the element types."
+ problemMessage: "The list literal type '{0}' isn't of expected type '{1}'. The list's type can be changed with an explicit generic type argument or by changing the element types."
comment: |-
Parameters:
0: the type of the list literal
1: the expected type
INVALID_CAST_LITERAL_MAP:
- template: "The map literal type '{0}' isn't of expected type '{1}'. The maps's type can be changed with an explicit generic type arguments or by changing the key and value types."
+ problemMessage: "The map literal type '{0}' isn't of expected type '{1}'. The maps's type can be changed with an explicit generic type arguments or by changing the key and value types."
comment: |-
Parameters:
0: the type of the map literal
1: the expected type
INVALID_CAST_LITERAL_SET:
- template: "The set literal type '{0}' isn't of expected type '{1}'. The set's type can be changed with an explicit generic type argument or by changing the element types."
+ problemMessage: "The set literal type '{0}' isn't of expected type '{1}'. The set's type can be changed with an explicit generic type argument or by changing the element types."
comment: |-
Parameters:
0: the type of the set literal
1: the expected type
INVALID_CAST_METHOD:
- template: "The method tear-off '{0}' has type '{1}' that isn't of expected type '{2}'. This means its parameter or return type doesn't match what is expected."
+ problemMessage: "The method tear-off '{0}' has type '{1}' that isn't of expected type '{2}'. This means its parameter or return type doesn't match what is expected."
comment: |-
Parameters:
0: the type of the torn-off method
1: the expected function type
INVALID_CAST_NEW_EXPR:
- template: "The constructor returns type '{0}' that isn't of expected type '{1}'."
+ problemMessage: "The constructor returns type '{0}' that isn't of expected type '{1}'."
comment: |-
Parameters:
0: the type of the instantiated object
1: the expected type
INVALID_CONSTANT:
- template: Invalid constant value.
+ problemMessage: Invalid constant value.
comment: |-
TODO(brianwilkerson) Remove this when we have decided on how to report
errors in compile-time constants. Until then, this acts as a placeholder
@@ -6050,13 +6086,13 @@
See TODOs in ConstantVisitor
INVALID_CONSTRUCTOR_NAME:
- template: Invalid constructor name.
+ problemMessage: Invalid constructor name.
comment: |-
7.6 Constructors: It is a compile-time error if the name of a constructor
is not a constructor name.
INVALID_EXTENSION_ARGUMENT_COUNT:
- template: "Extension overrides must have exactly one argument: the value of 'this' in the extension method."
- tip: Try specifying exactly one argument.
+ problemMessage: "Extension overrides must have exactly one argument: the value of 'this' in the extension method."
+ correctionMessage: Try specifying exactly one argument.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -6108,7 +6144,7 @@
}
```
INVALID_FACTORY_NAME_NOT_A_CLASS:
- template: The name of a factory constructor must be the same as the name of the immediately enclosing class.
+ problemMessage: The name of a factory constructor must be the same as the name of the immediately enclosing class.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -6166,7 +6202,7 @@
}
```
INVALID_IMPLEMENTATION_OVERRIDE:
- template: "'{1}.{0}' ('{2}') isn't a valid concrete implementation of '{3}.{0}' ('{4}')."
+ problemMessage: "'{1}.{0}' ('{2}') isn't a valid concrete implementation of '{3}.{0}' ('{4}')."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -6260,8 +6296,8 @@
}
```
INVALID_INLINE_FUNCTION_TYPE:
- template: "Inline function types can't be used for parameters in a generic function type."
- tip: "Try using a generic function type (returnType 'Function(' parameters ')')."
+ problemMessage: "Inline function types can't be used for parameters in a generic function type."
+ correctionMessage: "Try using a generic function type (returnType 'Function(' parameters ')')."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -6289,8 +6325,8 @@
typedef F = int Function(int Function(String));
```
INVALID_MODIFIER_ON_CONSTRUCTOR:
- template: "The modifier '{0}' can't be applied to the body of a constructor."
- tip: Try removing the modifier.
+ problemMessage: "The modifier '{0}' can't be applied to the body of a constructor."
+ correctionMessage: Try removing the modifier.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -6335,8 +6371,8 @@
}
```
INVALID_MODIFIER_ON_SETTER:
- template: "Setters can't use 'async', 'async*', or 'sync*'."
- tip: Try removing the modifier.
+ problemMessage: "Setters can't use 'async', 'async*', or 'sync*'."
+ correctionMessage: Try removing the modifier.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -6378,7 +6414,7 @@
}
```
INVALID_OVERRIDE:
- template: "'{1}.{0}' ('{2}') isn't a valid override of '{3}.{0}' ('{4}')."
+ problemMessage: "'{1}.{0}' ('{2}') isn't a valid override of '{3}.{0}' ('{4}')."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -6445,7 +6481,7 @@
}
```
INVALID_REFERENCE_TO_THIS:
- template: "Invalid reference to 'this' expression."
+ problemMessage: "Invalid reference to 'this' expression."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -6478,7 +6514,7 @@
class C {}
```
INVALID_SUPER_INVOCATION:
- template: "The superclass call must be last in an initializer list: '{0}'."
+ problemMessage: "The superclass call must be last in an initializer list: '{0}'."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -6519,8 +6555,8 @@
```
INVALID_TYPE_ARGUMENT_IN_CONST_LIST:
sharedName: INVALID_TYPE_ARGUMENT_IN_CONST_LITERAL
- template: "Constant list literals can't include a type parameter as a type argument, such as '{0}'."
- tip: Try replacing the type parameter with a different type.
+ problemMessage: "Constant list literals can't include a type parameter as a type argument, such as '{0}'."
+ correctionMessage: Try replacing the type parameter with a different type.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -6573,22 +6609,22 @@
```
INVALID_TYPE_ARGUMENT_IN_CONST_MAP:
sharedName: INVALID_TYPE_ARGUMENT_IN_CONST_LITERAL
- template: "Constant map literals can't include a type parameter as a type argument, such as '{0}'."
- tip: Try replacing the type parameter with a different type.
+ problemMessage: "Constant map literals can't include a type parameter as a type argument, such as '{0}'."
+ correctionMessage: Try replacing the type parameter with a different type.
hasPublishedDocs: true
comment: |-
Parameters:
0: the name of the type parameter
INVALID_TYPE_ARGUMENT_IN_CONST_SET:
sharedName: INVALID_TYPE_ARGUMENT_IN_CONST_LITERAL
- template: "Constant set literals can't include a type parameter as a type argument, such as '{0}'."
- tip: Try replacing the type parameter with a different type.
+ problemMessage: "Constant set literals can't include a type parameter as a type argument, such as '{0}'."
+ correctionMessage: Try replacing the type parameter with a different type.
hasPublishedDocs: true
comment: |-
Parameters:
0: the name of the type parameter
INVALID_URI:
- template: "Invalid URI syntax: '{0}'."
+ problemMessage: "Invalid URI syntax: '{0}'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -6612,12 +6648,12 @@
Replace the invalid URI with a valid URI.
INVALID_USE_OF_COVARIANT:
- template: "The 'covariant' keyword can only be used for parameters in instance methods or before non-final instance fields."
- tip: "Try removing the 'covariant' keyword."
+ problemMessage: "The 'covariant' keyword can only be used for parameters in instance methods or before non-final instance fields."
+ correctionMessage: "Try removing the 'covariant' keyword."
comment: "The 'covariant' keyword was found in an inappropriate location."
INVALID_USE_OF_NULL_VALUE:
- template: "An expression whose value is always 'null' can't be dereferenced."
- tip: Try changing the type of the expression.
+ problemMessage: "An expression whose value is always 'null' can't be dereferenced."
+ correctionMessage: Try changing the type of the expression.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -6648,7 +6684,7 @@
}
```
INVOCATION_OF_EXTENSION_WITHOUT_CALL:
- template: "The extension '{0}' doesn't define a 'call' method so the override can't be used in an invocation."
+ problemMessage: "The extension '{0}' doesn't define a 'call' method so the override can't be used in an invocation."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -6692,8 +6728,8 @@
If the `call` method isn't defined, then rewrite the code so that it
doesn't invoke the `call` method.
INVOCATION_OF_NON_FUNCTION:
- template: "'{0}' isn't a function."
- tip: "Try correcting the name to match an existing function, or define a method or function named '{0}'."
+ problemMessage: "'{0}' isn't a function."
+ correctionMessage: "Try correcting the name to match an existing function, or define a method or function named '{0}'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -6722,7 +6758,7 @@
Replace the name with the name of a function.
INVOCATION_OF_NON_FUNCTION_EXPRESSION:
- template: "The expression doesn't evaluate to a function, so it can't be invoked."
+ problemMessage: "The expression doesn't evaluate to a function, so it can't be invoked."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -6769,7 +6805,7 @@
var y = f();
```
LABEL_IN_OUTER_SCOPE:
- template: "Can't reference label '{0}' declared in an outer method."
+ problemMessage: "Can't reference label '{0}' declared in an outer method."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -6834,8 +6870,8 @@
}
```
LABEL_UNDEFINED:
- template: "Can't reference an undefined label '{0}'."
- tip: Try defining the label, or correcting the name to match an existing label.
+ problemMessage: "Can't reference an undefined label '{0}'."
+ correctionMessage: Try defining the label, or correcting the name to match an existing label.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -6889,8 +6925,8 @@
}
```
LATE_FINAL_FIELD_WITH_CONST_CONSTRUCTOR:
- template: "Can't have a late final field in a class with a generative const constructor."
- tip: "Try removing the 'late' modifier, or don't declare 'const' constructors."
+ problemMessage: "Can't have a late final field in a class with a generative const constructor."
+ correctionMessage: "Try removing the 'late' modifier, or don't declare 'const' constructors."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -6936,8 +6972,8 @@
}
```
LATE_FINAL_LOCAL_ALREADY_ASSIGNED:
- template: The late final local variable is already assigned.
- tip: "Try removing the 'final' modifier, or don't reassign the value."
+ problemMessage: The late final local variable is already assigned.
+ correctionMessage: "Try removing the 'final' modifier, or don't reassign the value."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -6989,7 +7025,7 @@
}
```
LIST_ELEMENT_TYPE_NOT_ASSIGNABLE:
- template: "The element type '{0}' can't be assigned to the list type '{1}'."
+ problemMessage: "The element type '{0}' can't be assigned to the list type '{1}'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -7032,8 +7068,8 @@
List<num> x = [1, 2.5, 3];
```
MAIN_FIRST_POSITIONAL_PARAMETER_TYPE:
- template: "The type of the first positional parameter of the 'main' function must be a supertype of 'List<String>'."
- tip: Try changing the type of the parameter.
+ problemMessage: "The type of the first positional parameter of the 'main' function must be a supertype of 'List<String>'."
+ correctionMessage: Try changing the type of the parameter.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -7066,8 +7102,8 @@
void f(List<int> args) {}
```
MAIN_HAS_REQUIRED_NAMED_PARAMETERS:
- template: "The function 'main' can't have any required named parameters."
- tip: "Try using a different name for the function, or removing the 'required' modifier."
+ problemMessage: "The function 'main' can't have any required named parameters."
+ correctionMessage: "Try using a different name for the function, or removing the 'required' modifier."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -7099,8 +7135,8 @@
void f({required int x}) {}
```
MAIN_HAS_TOO_MANY_REQUIRED_POSITIONAL_PARAMETERS:
- template: "The function 'main' can't have more than two required positional parameters."
- tip: Try using a different name for the function, or removing extra parameters.
+ problemMessage: "The function 'main' can't have more than two required positional parameters."
+ correctionMessage: Try using a different name for the function, or removing extra parameters.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -7141,8 +7177,8 @@
void f(List<String> args, int x, int y) {}
```
MAIN_IS_NOT_FUNCTION:
- template: "The declaration named 'main' must be a function."
- tip: Try using a different name for this declaration.
+ problemMessage: "The declaration named 'main' must be a function."
+ correctionMessage: Try using a different name for this declaration.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -7168,8 +7204,8 @@
var mainIndex = 3;
```
MAP_ENTRY_NOT_IN_MAP:
- template: Map entries can only be used in a map literal.
- tip: Try converting the collection to a map or removing the map entry.
+ problemMessage: Map entries can only be used in a map literal.
+ correctionMessage: Try converting the collection to a map or removing the map entry.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -7208,7 +7244,7 @@
const collection = <String>{'a', 'b'};
```
MAP_KEY_TYPE_NOT_ASSIGNABLE:
- template: "The element type '{0}' can't be assigned to the map key type '{1}'."
+ problemMessage: "The element type '{0}' can't be assigned to the map key type '{1}'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -7244,7 +7280,7 @@
var m = <int, String>{2 : 'a'};
```
MAP_VALUE_TYPE_NOT_ASSIGNABLE:
- template: "The element type '{0}' can't be assigned to the map value type '{1}'."
+ problemMessage: "The element type '{0}' can't be assigned to the map value type '{1}'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -7281,20 +7317,20 @@
var m = <String, int>{'a' : 2};
```
MISSING_CONST_IN_LIST_LITERAL:
- template: "List literals must be prefixed with 'const' when used as a constant expression."
- tip: "Try adding the keyword 'const' before the literal."
+ problemMessage: "List literals must be prefixed with 'const' when used as a constant expression."
+ correctionMessage: "Try adding the keyword 'const' before the literal."
comment: "12.1 Constants: A constant expression is ... a constant list literal."
MISSING_CONST_IN_MAP_LITERAL:
- template: "Map literals must be prefixed with 'const' when used as a constant expression."
- tip: "Try adding the keyword 'const' before the literal."
+ problemMessage: "Map literals must be prefixed with 'const' when used as a constant expression."
+ correctionMessage: "Try adding the keyword 'const' before the literal."
comment: "12.1 Constants: A constant expression is ... a constant map literal."
MISSING_CONST_IN_SET_LITERAL:
- template: "Set literals must be prefixed with 'const' when used as a constant expression."
- tip: "Try adding the keyword 'const' before the literal."
+ problemMessage: "Set literals must be prefixed with 'const' when used as a constant expression."
+ correctionMessage: "Try adding the keyword 'const' before the literal."
comment: "12.1 Constants: A constant expression is ... a constant set literal."
MISSING_DART_LIBRARY:
- template: "Required library '{0}' is missing."
- tip: Re-install the Dart or Flutter SDK.
+ problemMessage: "Required library '{0}' is missing."
+ correctionMessage: Re-install the Dart or Flutter SDK.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -7308,8 +7344,8 @@
Reinstall the Dart or Flutter SDK.
MISSING_DEFAULT_VALUE_FOR_PARAMETER:
- template: "The parameter '{0}' can't have a value of 'null' because of its type, but the implicit default value is 'null'."
- tip: "Try adding either an explicit non-'null' default value or the 'required' modifier."
+ problemMessage: "The parameter '{0}' can't have a value of 'null' because of its type, but the implicit default value is 'null'."
+ correctionMessage: "Try adding either an explicit non-'null' default value or the 'required' modifier."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -7361,8 +7397,8 @@
void g({required int x}) {}
```
MISSING_REQUIRED_ARGUMENT:
- template: "The named parameter '{0}' is required, but there's no corresponding argument."
- tip: Try adding the required argument.
+ problemMessage: "The named parameter '{0}' is required, but there's no corresponding argument."
+ correctionMessage: Try adding the required argument.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -7396,8 +7432,8 @@
}
```
MIXINS_SUPER_CLASS:
- template: "'{0}' can't be used in both 'extends' and 'with' clauses."
- tip: Try removing one of the occurrences.
+ problemMessage: "'{0}' can't be used in both 'extends' and 'with' clauses."
+ correctionMessage: Try removing one of the occurrences.
comment: |-
Technically this is [IMPLEMENTS_SUPER_CLASS].
See https://github.com/dart-lang/sdk/issues/25765#issuecomment-307422593
@@ -7405,7 +7441,7 @@
Parameters:
0: the name of the class that appears in both "extends" and "with" clauses
MIXIN_APPLICATION_CONCRETE_SUPER_INVOKED_MEMBER_TYPE:
- template: "The super-invoked member '{0}' has the type '{1}', and the concrete member in the class has the type '{2}'."
+ problemMessage: "The super-invoked member '{0}' has the type '{1}', and the concrete member in the class has the type '{2}'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -7509,8 +7545,8 @@
abstract class C extends B with M {}
```
MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE:
- template: "'{0}' can't be mixed onto '{1}' because '{1}' doesn't implement '{2}'."
- tip: "Try extending the class '{0}'."
+ problemMessage: "'{0}' can't be mixed onto '{1}' because '{1}' doesn't implement '{2}'."
+ correctionMessage: "Try extending the class '{0}'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -7551,7 +7587,7 @@
class X = A with M;
```
MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_MEMBER:
- template: "The class doesn't have a concrete implementation of the super-invoked member '{0}'."
+ problemMessage: "The class doesn't have a concrete implementation of the super-invoked member '{0}'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -7625,7 +7661,7 @@
abstract class B extends A with M {}
```
MIXIN_CLASS_DECLARES_CONSTRUCTOR:
- template: "The class '{0}' can't be used as a mixin because it declares a constructor."
+ problemMessage: "The class '{0}' can't be used as a mixin because it declares a constructor."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -7681,18 +7717,18 @@
class B extends A {}
```
MIXIN_DECLARES_CONSTRUCTOR:
- template: "Mixins can't declare constructors."
+ problemMessage: "Mixins can't declare constructors."
comment: |-
The <i>mixinMember</i> production allows the same instance or static
members that a class would allow, but no constructors (for now).
MIXIN_INFERENCE_INCONSISTENT_MATCHING_CLASSES:
- template: "Type parameters couldn't be inferred for the mixin '{0}' because the base class implements the mixin's supertype constraint '{1}' in multiple conflicting ways"
+ problemMessage: "Type parameters couldn't be inferred for the mixin '{0}' because the base class implements the mixin's supertype constraint '{1}' in multiple conflicting ways"
MIXIN_INFERENCE_NO_MATCHING_CLASS:
- template: "Type parameters couldn't be inferred for the mixin '{0}' because the base class doesn't implement the mixin's supertype constraint '{1}'"
+ problemMessage: "Type parameters couldn't be inferred for the mixin '{0}' because the base class doesn't implement the mixin's supertype constraint '{1}'"
MIXIN_INFERENCE_NO_POSSIBLE_SUBSTITUTION:
- template: "Type parameters couldn't be inferred for the mixin '{0}' because no type parameter substitution could be found matching the mixin's supertype constraints"
+ problemMessage: "Type parameters couldn't be inferred for the mixin '{0}' because no type parameter substitution could be found matching the mixin's supertype constraints"
MIXIN_INHERITS_FROM_NOT_OBJECT:
- template: "The class '{0}' can't be used as a mixin because it extends a class other than 'Object'."
+ problemMessage: "The class '{0}' can't be used as a mixin because it extends a class other than 'Object'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -7753,7 +7789,7 @@
class C extends A with M {}
```
MIXIN_INSTANTIATE:
- template: "Mixins can't be instantiated."
+ problemMessage: "Mixins can't be instantiated."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -7777,7 +7813,7 @@
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:
- template: Classes can only mix in mixins and classes.
+ problemMessage: Classes can only mix in mixins and classes.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -7808,11 +7844,11 @@
class C {}
```
MIXIN_SUPER_CLASS_CONSTRAINT_DEFERRED_CLASS:
- template: "Deferred classes can't be used as super-class constraints."
- tip: Try changing the import to not be deferred.
+ problemMessage: "Deferred classes can't be used as super-class constraints."
+ correctionMessage: Try changing the import to not be deferred.
comment: No parameters.
MIXIN_SUPER_CLASS_CONSTRAINT_NON_INTERFACE:
- template: Only classes and mixins can be used as superclass constraints.
+ problemMessage: Only classes and mixins can be used as superclass constraints.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -7839,19 +7875,19 @@
Otherwise, remove the type from the `on` clause.
MIXIN_WITH_NON_CLASS_SUPERCLASS:
- template: Mixin can only be applied to class.
+ problemMessage: Mixin can only be applied to class.
comment: |-
9.1 Mixin Application: It is a compile-time error if <i>S</i> does not
denote a class available in the immediately enclosing scope.
MULTIPLE_REDIRECTING_CONSTRUCTOR_INVOCATIONS:
- template: "Constructors can have at most one 'this' redirection."
- tip: Try removing all but one of the redirections.
+ problemMessage: "Constructors can have at most one 'this' redirection."
+ correctionMessage: Try removing all but one of the redirections.
comment: |-
7.6.1 Generative Constructors: A generative constructor may be redirecting,
in which case its only action is to invoke another generative constructor.
MULTIPLE_SUPER_INITIALIZERS:
- template: "A constructor can have at most one 'super' initializer."
- tip: "Try removing all but one of the 'super' initializers."
+ problemMessage: "A constructor can have at most one 'super' initializer."
+ correctionMessage: "Try removing all but one of the 'super' initializers."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -7937,8 +7973,8 @@
}
```
NEW_WITH_UNDEFINED_CONSTRUCTOR:
- template: "The class '{0}' doesn't have a constructor named '{1}'."
- tip: "Try invoking a different constructor, or define a constructor named '{1}'."
+ problemMessage: "The class '{0}' doesn't have a constructor named '{1}'."
+ correctionMessage: "Try invoking a different constructor, or define a constructor named '{1}'."
comment: |-
12.11.1 New: If <i>T</i> is a class or parameterized type accessible in the
current scope then:
@@ -7952,8 +7988,8 @@
a<sub>n+kM/sub>)</i> it is a static warning if the type <i>T</i> does not
declare a constructor with the same name as the declaration of <i>T</i>.
NEW_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT:
- template: "The class '{0}' doesn't have an unnamed constructor."
- tip: "Try using one of the named constructors defined in '{0}'."
+ problemMessage: "The class '{0}' doesn't have an unnamed constructor."
+ correctionMessage: "Try using one of the named constructors defined in '{0}'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -8003,8 +8039,8 @@
```
NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FIVE_PLUS:
sharedName: NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER
- template: "Missing concrete implementations of '{0}', '{1}', '{2}', '{3}', and {4} more."
- tip: Try implementing the missing methods, or make the class abstract.
+ problemMessage: "Missing concrete implementations of '{0}', '{1}', '{2}', '{3}', and {4} more."
+ correctionMessage: Try implementing the missing methods, or make the class abstract.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -8015,8 +8051,8 @@
4: the number of additional missing members that aren't listed
NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FOUR:
sharedName: NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER
- template: "Missing concrete implementations of '{0}', '{1}', '{2}', and '{3}'."
- tip: Try implementing the missing methods, or make the class abstract.
+ problemMessage: "Missing concrete implementations of '{0}', '{1}', '{2}', and '{3}'."
+ correctionMessage: Try implementing the missing methods, or make the class abstract.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -8026,8 +8062,8 @@
3: the name of the fourth member
NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE:
sharedName: NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER
- template: "Missing concrete implementation of '{0}'."
- tip: Try implementing the missing method, or make the class abstract.
+ problemMessage: "Missing concrete implementation of '{0}'."
+ correctionMessage: Try implementing the missing method, or make the class abstract.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -8094,8 +8130,8 @@
```
NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_THREE:
sharedName: NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER
- template: "Missing concrete implementations of '{0}', '{1}', and '{2}'."
- tip: Try implementing the missing methods, or make the class abstract.
+ problemMessage: "Missing concrete implementations of '{0}', '{1}', and '{2}'."
+ correctionMessage: Try implementing the missing methods, or make the class abstract.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -8104,16 +8140,16 @@
2: the name of the third member
NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_TWO:
sharedName: NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER
- template: "Missing concrete implementations of '{0}' and '{1}'."
- tip: Try implementing the missing methods, or make the class abstract.
+ problemMessage: "Missing concrete implementations of '{0}' and '{1}'."
+ correctionMessage: Try implementing the missing methods, or make the class abstract.
hasPublishedDocs: true
comment: |-
Parameters:
0: the name of the first member
1: the name of the second member
NON_BOOL_CONDITION:
- template: "Conditions must have a static type of 'bool'."
- tip: Try changing the condition.
+ problemMessage: "Conditions must have a static type of 'bool'."
+ correctionMessage: Try changing the condition.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -8147,8 +8183,8 @@
}
```
NON_BOOL_EXPRESSION:
- template: "The expression in an assert must be of type 'bool'."
- tip: Try changing the expression.
+ problemMessage: "The expression in an assert must be of type 'bool'."
+ correctionMessage: Try changing the expression.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -8178,8 +8214,8 @@
}
```
NON_BOOL_NEGATION_EXPRESSION:
- template: "A negation operand must have a static type of 'bool'."
- tip: "Try changing the operand to the '!' operator."
+ problemMessage: "A negation operand must have a static type of 'bool'."
+ correctionMessage: "Try changing the operand to the '!' operator."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -8207,7 +8243,7 @@
bool y = !(x > 0);
```
NON_BOOL_OPERAND:
- template: "The operands of the operator '{0}' must be assignable to 'bool'."
+ problemMessage: "The operands of the operator '{0}' must be assignable to 'bool'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -8237,7 +8273,7 @@
bool b = a == 0 || a > 1;
```
NON_CONSTANT_ANNOTATION_CONSTRUCTOR:
- template: Annotation creation can only call a const constructor.
+ problemMessage: Annotation creation can only call a const constructor.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -8280,7 +8316,7 @@
If it isn't valid for the class to have a const constructor, then either
remove the annotation or use a different class for the annotation.
NON_CONSTANT_CASE_EXPRESSION:
- template: Case expressions must be constant.
+ problemMessage: Case expressions must be constant.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -8316,8 +8352,8 @@
}
```
NON_CONSTANT_CASE_EXPRESSION_FROM_DEFERRED_LIBRARY:
- template: "Constant values from a deferred library can't be used as a case expression."
- tip: Try re-writing the switch as a series of if statements, or changing the import to not be deferred.
+ problemMessage: "Constant values from a deferred library can't be used as a case expression."
+ correctionMessage: Try re-writing the switch as a series of if statements, or changing the import to not be deferred.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -8401,7 +8437,7 @@
}
```
NON_CONSTANT_DEFAULT_VALUE:
- template: The default value of an optional parameter must be constant.
+ problemMessage: The default value of an optional parameter must be constant.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -8445,8 +8481,8 @@
}
```
NON_CONSTANT_DEFAULT_VALUE_FROM_DEFERRED_LIBRARY:
- template: "Constant values from a deferred library can't be used as a default parameter value."
- tip: Try leaving the default as null and initializing the parameter inside the function body.
+ problemMessage: "Constant values from a deferred library can't be used as a default parameter value."
+ correctionMessage: Try leaving the default as null and initializing the parameter inside the function body.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -8496,8 +8532,8 @@
void f({int x = 0}) {}
```
NON_CONSTANT_LIST_ELEMENT:
- template: The values in a const list literal must be constants.
- tip: "Try removing the keyword 'const' from the list literal."
+ problemMessage: The values in a const list literal must be constants.
+ correctionMessage: "Try removing the keyword 'const' from the list literal."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -8539,8 +8575,8 @@
var y = <int>[0, 1, x];
```
NON_CONSTANT_MAP_ELEMENT:
- template: The elements in a const map literal must be constant.
- tip: "Try removing the keyword 'const' from the map literal."
+ problemMessage: The elements in a const map literal must be constant.
+ correctionMessage: "Try removing the keyword 'const' from the map literal."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -8586,8 +8622,8 @@
var map = <int, int>{if (notConst) 1 : 2};
```
NON_CONSTANT_MAP_KEY:
- template: The keys in a const map literal must be constant.
- tip: "Try removing the keyword 'const' from the map literal."
+ problemMessage: The keys in a const map literal must be constant.
+ correctionMessage: "Try removing the keyword 'const' from the map literal."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -8622,8 +8658,8 @@
var m = {a: 0};
```
NON_CONSTANT_MAP_VALUE:
- template: The values in a const map literal must be constant.
- tip: "Try removing the keyword 'const' from the map literal."
+ problemMessage: The values in a const map literal must be constant.
+ correctionMessage: "Try removing the keyword 'const' from the map literal."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -8658,8 +8694,8 @@
var m = {0: a};
```
NON_CONSTANT_SET_ELEMENT:
- template: The values in a const set literal must be constants.
- tip: "Try removing the keyword 'const' from the set literal."
+ problemMessage: The values in a const set literal must be constants.
+ correctionMessage: "Try removing the keyword 'const' from the set literal."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -8696,14 +8732,14 @@
var s = {i};
```
NON_CONST_MAP_AS_EXPRESSION_STATEMENT:
- template: "A non-constant map or set literal without type arguments can't be used as an expression statement."
+ problemMessage: "A non-constant map or set literal without type arguments can't be used as an expression statement."
comment: |-
13.2 Expression Statements: It is a compile-time error if a non-constant
map literal that has no explicit type arguments appears in a place where a
statement is expected.
NON_GENERATIVE_CONSTRUCTOR:
- template: "The generative constructor '{0}' is expected, but a factory was found."
- tip: Try calling a different constructor of the superclass, or making the called constructor not be a factory constructor.
+ problemMessage: "The generative constructor '{0}' is expected, but a factory was found."
+ correctionMessage: Try calling a different constructor of the superclass, or making the called constructor not be a factory constructor.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -8750,8 +8786,8 @@
If the generative constructor is the unnamed constructor, and if there are
no arguments being passed to it, then you can remove the super invocation.
NON_GENERATIVE_IMPLICIT_CONSTRUCTOR:
- template: "The unnamed constructor of superclass '{0}' (called by the default constructor of '{1}') must be a generative constructor, but factory found."
- tip: "Try adding an explicit constructor that has a different superinitializer or changing the superclass constructor '{2}' to not be a factory constructor."
+ problemMessage: "The unnamed constructor of superclass '{0}' (called by the default constructor of '{1}') must be a generative constructor, but factory found."
+ correctionMessage: "Try adding an explicit constructor that has a different superinitializer or changing the superclass constructor '{2}' to not be a factory constructor."
comment: |-
An error code for when a class has no explicit constructor, and therefore
a constructor is implicitly defined which uses a factory as a
@@ -8762,7 +8798,7 @@
1: the name of the current class
2: the implicitly called factory constructor of the superclass
NON_SYNC_FACTORY:
- template: "Factory bodies can't use 'async', 'async*', or 'sync*'."
+ problemMessage: "Factory bodies can't use 'async', 'async*', or 'sync*'."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -8813,8 +8849,8 @@
}
```
NON_TYPE_AS_TYPE_ARGUMENT:
- template: "The name '{0}' isn't a type so it can't be used as a type argument."
- tip: "Try correcting the name to an existing type, or defining a type named '{0}'."
+ problemMessage: "The name '{0}' isn't a type so it can't be used as a type argument."
+ correctionMessage: "Try correcting the name to an existing type, or defining a type named '{0}'."
isUnresolvedIdentifier: true
hasPublishedDocs: true
comment: |-
@@ -8845,8 +8881,8 @@
List<int> xList = [];
```
NON_TYPE_IN_CATCH_CLAUSE:
- template: "The name '{0}' isn't a type and can't be used in an on-catch clause."
- tip: Try correcting the name to match an existing class.
+ problemMessage: "The name '{0}' isn't a type and can't be used in an on-catch clause."
+ correctionMessage: Try correcting the name to match an existing class.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -8888,8 +8924,8 @@
}
```
NON_VOID_RETURN_FOR_OPERATOR:
- template: "The return type of the operator []= must be 'void'."
- tip: "Try changing the return type to 'void'."
+ problemMessage: "The return type of the operator []= must be 'void'."
+ correctionMessage: "Try changing the return type to 'void'."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -8919,8 +8955,8 @@
}
```
NON_VOID_RETURN_FOR_SETTER:
- template: "The return type of the setter must be 'void' or absent."
- tip: Try removing the return type, or define a method rather than a setter.
+ problemMessage: "The return type of the setter must be 'void' or absent."
+ correctionMessage: Try removing the return type, or define a method rather than a setter.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -8950,8 +8986,8 @@
}
```
NOT_ASSIGNED_POTENTIALLY_NON_NULLABLE_LOCAL_VARIABLE:
- template: "The non-nullable local variable '{0}' must be assigned before it can be used."
- tip: "Try giving it an initializer expression, or ensure that it's assigned on every execution path."
+ problemMessage: "The non-nullable local variable '{0}' must be assigned before it can be used."
+ correctionMessage: "Try giving it an initializer expression, or ensure that it's assigned on every execution path."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -9067,8 +9103,8 @@
}
```
NOT_A_TYPE:
- template: "{0} isn't a type."
- tip: Try correcting the name to match an existing type.
+ problemMessage: "{0} isn't a type."
+ correctionMessage: Try correcting the name to match an existing type.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -9092,7 +9128,7 @@
Replace the name with the name of a type.
NOT_BINARY_OPERATOR:
- template: "'{0}' isn't a binary operator."
+ problemMessage: "'{0}' isn't a binary operator."
comment: |-
Parameters:
0: the name of the operator that is not a binary operator.
@@ -9119,8 +9155,8 @@
var a = 5 - 3;
```
NOT_ENOUGH_POSITIONAL_ARGUMENTS:
- template: "{0} positional argument(s) expected, but {1} found."
- tip: Try adding the missing arguments.
+ problemMessage: "{0} positional argument(s) expected, but {1} found."
+ correctionMessage: Try adding the missing arguments.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -9156,8 +9192,8 @@
}
```
NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD:
- template: "Non-nullable instance field '{0}' must be initialized."
- tip: "Try adding an initializer expression, or a generative constructor that initializes it, or mark it 'late'."
+ problemMessage: "Non-nullable instance field '{0}' must be initialized."
+ correctionMessage: "Try adding an initializer expression, or a generative constructor that initializes it, or mark it 'late'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -9232,15 +9268,15 @@
```
NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD_CONSTRUCTOR:
sharedName: NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD
- template: "Non-nullable instance field '{0}' must be initialized."
- tip: "Try adding an initializer expression, or add a field initializer in this constructor, or mark it 'late'."
+ problemMessage: "Non-nullable instance field '{0}' must be initialized."
+ correctionMessage: "Try adding an initializer expression, or add a field initializer in this constructor, or mark it 'late'."
hasPublishedDocs: true
comment: |-
Parameters:
0: the name of the field that is not initialized
NOT_INITIALIZED_NON_NULLABLE_VARIABLE:
- template: "The non-nullable variable '{0}' must be initialized."
- tip: Try adding an initializer expression.
+ problemMessage: "The non-nullable variable '{0}' must be initialized."
+ correctionMessage: Try adding an initializer expression.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -9299,11 +9335,11 @@
}
```
NOT_INSTANTIATED_BOUND:
- template: Type parameter bound types must be instantiated.
- tip: Try adding type arguments to the type parameter bound.
+ problemMessage: Type parameter bound types must be instantiated.
+ correctionMessage: Try adding type arguments to the type parameter bound.
comment: No parameters.
NOT_ITERABLE_SPREAD:
- template: "Spread elements in list or set literals must implement 'Iterable'."
+ problemMessage: "Spread elements in list or set literals must implement 'Iterable'."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -9332,7 +9368,7 @@
var s = <String>{...m.keys};
```
NOT_MAP_SPREAD:
- template: "Spread elements in map literals must implement 'Map'."
+ problemMessage: "Spread elements in map literals must implement 'Map'."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -9361,11 +9397,11 @@
var m = <int, String>{...l.asMap()};
```
NOT_NULL_AWARE_NULL_SPREAD:
- template: "The Null typed expression can't be used with a non-null-aware spread."
+ problemMessage: "The Null typed expression can't be used with a non-null-aware spread."
comment: No parameters.
NO_ANNOTATION_CONSTRUCTOR_ARGUMENTS:
- template: Annotation creation must have arguments.
- tip: Try adding an empty argument list.
+ problemMessage: Annotation creation must have arguments.
+ correctionMessage: Try adding an empty argument list.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -9404,8 +9440,8 @@
var x;
```
NO_COMBINED_SUPER_SIGNATURE:
- template: "Can't infer missing types in '{0}' from overridden methods: {1}."
- tip: "Try providing explicit types for this method's parameters and return type."
+ problemMessage: "Can't infer missing types in '{0}' from overridden methods: {1}."
+ correctionMessage: "Try providing explicit types for this method's parameters and return type."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -9465,24 +9501,24 @@
```
NO_DEFAULT_SUPER_CONSTRUCTOR_EXPLICIT:
sharedName: NO_DEFAULT_SUPER_CONSTRUCTOR
- template: "The superclass '{0}' doesn't have a zero argument constructor."
- tip: "Try declaring a zero argument constructor in '{0}', or explicitly invoking a different constructor in '{0}'."
+ problemMessage: "The superclass '{0}' doesn't have a zero argument constructor."
+ correctionMessage: "Try declaring a zero argument constructor in '{0}', or explicitly invoking a different constructor in '{0}'."
comment: |-
Parameters:
0: the name of the superclass that does not define an implicitly invoked
constructor
NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT:
sharedName: NO_DEFAULT_SUPER_CONSTRUCTOR
- template: "The superclass '{0}' doesn't have a zero argument constructor."
- tip: "Try declaring a zero argument constructor in '{0}', or declaring a constructor in {1} that explicitly invokes a constructor in '{0}'."
+ problemMessage: "The superclass '{0}' doesn't have a zero argument constructor."
+ correctionMessage: "Try declaring a zero argument constructor in '{0}', or declaring a constructor in {1} that explicitly invokes a constructor in '{0}'."
comment: |-
Parameters:
0: the name of the superclass that does not define an implicitly invoked
constructor
1: the name of the subclass that does not contain any explicit constructors
NO_GENERATIVE_CONSTRUCTORS_IN_SUPERCLASS:
- template: "The class '{0}' cannot extend '{1}' because '{1}' only has factory constructors (no generative constructors), and '{0}' has at least one generative constructor."
- tip: "Try implementing the class instead, adding a generative (not factory) constructor to the superclass {0}, or a factory constructor to the subclass."
+ problemMessage: "The class '{0}' cannot extend '{1}' because '{1}' only has factory constructors (no generative constructors), and '{0}' has at least one generative constructor."
+ correctionMessage: "Try implementing the class instead, adding a generative (not factory) constructor to the superclass {0}, or a factory constructor to the subclass."
comment: |-
User friendly specialized error for [NON_GENERATIVE_CONSTRUCTOR]. This
handles the case of `class E extends Exception` which will never work
@@ -9492,8 +9528,8 @@
0: the name of the subclass
1: the name of the superclass
NULLABLE_TYPE_IN_EXTENDS_CLAUSE:
- template: "A class can't extend a nullable type."
- tip: Try removing the question mark.
+ problemMessage: "A class can't extend a nullable type."
+ correctionMessage: Try removing the question mark.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -9529,8 +9565,8 @@
class B extends A {}
```
NULLABLE_TYPE_IN_IMPLEMENTS_CLAUSE:
- template: "A class or mixin can't implement a nullable type."
- tip: Try removing the question mark.
+ problemMessage: "A class or mixin can't implement a nullable type."
+ correctionMessage: Try removing the question mark.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -9566,8 +9602,8 @@
class B implements A {}
```
NULLABLE_TYPE_IN_ON_CLAUSE:
- template: "A mixin can't have a nullable type as a superclass constraint."
- tip: Try removing the question mark.
+ problemMessage: "A mixin can't have a nullable type as a superclass constraint."
+ correctionMessage: Try removing the question mark.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -9604,8 +9640,8 @@
mixin M on C {}
```
NULLABLE_TYPE_IN_WITH_CLAUSE:
- template: "A class or mixin can't mix in a nullable type."
- tip: Try removing the question mark.
+ problemMessage: "A class or mixin can't mix in a nullable type."
+ correctionMessage: Try removing the question mark.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -9640,13 +9676,13 @@
class C with M {}
```
OBJECT_CANNOT_EXTEND_ANOTHER_CLASS:
- template: "The class 'Object' can't extend any other class."
+ problemMessage: "The class 'Object' can't extend any other class."
comment: |-
7.9 Superclasses: It is a compile-time error to specify an extends clause
for class Object.
ON_REPEATED:
- template: "The type '{0}' can be included in the superclass constraints only once."
- tip: Try removing all except one occurrence of the type name.
+ problemMessage: "The type '{0}' can be included in the superclass constraints only once."
+ correctionMessage: Try removing all except one occurrence of the type name.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -9693,8 +9729,8 @@
class B {}
```
OPTIONAL_PARAMETER_IN_OPERATOR:
- template: "Optional parameters aren't allowed when defining an operator."
- tip: Try removing the optional parameters.
+ problemMessage: "Optional parameters aren't allowed when defining an operator."
+ correctionMessage: Try removing the optional parameters.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -9724,8 +9760,8 @@
}
```
PART_OF_DIFFERENT_LIBRARY:
- template: "Expected this library to be part of '{0}', not '{1}'."
- tip: "Try including a different part, or changing the name of the library in the part's part-of directive."
+ problemMessage: "Expected this library to be part of '{0}', not '{1}'."
+ correctionMessage: "Try including a different part, or changing the name of the library in the part's part-of directive."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -9764,8 +9800,8 @@
library name) in the part-of directive to be the URI (or name) of the
correct library.
PART_OF_NON_PART:
- template: "The included part '{0}' must have a part-of directive."
- tip: "Try adding a part-of directive to '{0}'."
+ problemMessage: "The included part '{0}' must have a part-of directive."
+ correctionMessage: "Try adding a part-of directive to '{0}'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -9810,8 +9846,8 @@
import 'a.dart';
```
PART_OF_UNNAMED_LIBRARY:
- template: "The library is unnamed. A URI is expected, not a library name '{0}', in the part-of directive."
- tip: Try changing the part-of directive to a URI, or try including a different part.
+ problemMessage: "The library is unnamed. A URI is expected, not a library name '{0}', in the part-of directive."
+ correctionMessage: Try changing the part-of directive to a URI, or try including a different part.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -9851,8 +9887,8 @@
part of 'test.dart';
```
PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER:
- template: "The name '{0}' is already used as an import prefix and can't be used to name a top-level element."
- tip: Try renaming either the top-level element or the prefix.
+ problemMessage: "The name '{0}' is already used as an import prefix and can't be used to name a top-level element."
+ correctionMessage: Try renaming either the top-level element or the prefix.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -9894,8 +9930,8 @@
int f() => math.min(0, 1);
```
PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT:
- template: "The name '{0}' refers to an import prefix, so it must be followed by '.'."
- tip: Try correcting the name to refer to something other than a prefix, or renaming the prefix.
+ problemMessage: "The name '{0}' refers to an import prefix, so it must be followed by '.'."
+ correctionMessage: Try correcting the name to refer to something other than a prefix, or renaming the prefix.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -9936,8 +9972,8 @@
If the name is wrong, then correct the name.
PREFIX_SHADOWED_BY_LOCAL_DECLARATION:
- template: "The prefix '{0}' can't be used here because it is shadowed by a local declaration."
- tip: Try renaming either the prefix or the local declaration.
+ problemMessage: "The prefix '{0}' can't be used here because it is shadowed by a local declaration."
+ correctionMessage: Try renaming either the prefix or the local declaration.
comment: |-
From the `Static Types` section of the spec:
@@ -9948,8 +9984,8 @@
In particular, this means that if an import prefix is shadowed by a local
declaration, it is an error to try to use it as a prefix for a type name.
PRIVATE_COLLISION_IN_MIXIN_APPLICATION:
- template: "The private name '{0}', defined by '{1}', conflicts with the same name defined by '{2}'."
- tip: "Try removing '{1}' from the 'with' clause."
+ problemMessage: "The private name '{0}', defined by '{1}', conflicts with the same name defined by '{2}'."
+ correctionMessage: "Try removing '{1}' from the 'with' clause."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -10001,7 +10037,7 @@
If you need both of the mixins, then rename the conflicting member in one
of the two mixins.
PRIVATE_OPTIONAL_PARAMETER:
- template: "Named parameters can't start with an underscore."
+ problemMessage: "Named parameters can't start with an underscore."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -10031,13 +10067,13 @@
}
```
PRIVATE_SETTER:
- template: "The setter '{0}' is private and can't be accessed outside of the library that declares it."
- tip: Try making it public.
+ problemMessage: "The setter '{0}' is private and can't be accessed outside of the library that declares it."
+ correctionMessage: Try making it public.
READ_POTENTIALLY_UNASSIGNED_FINAL:
- template: "The final variable '{0}' can't be read because it is potentially unassigned at this point."
- tip: Ensure that it is assigned on necessary execution paths.
+ problemMessage: "The final variable '{0}' can't be read because it is potentially unassigned at this point."
+ correctionMessage: Ensure that it is assigned on necessary execution paths.
RECURSIVE_COMPILE_TIME_CONSTANT:
- template: The compile-time constant expression depends on itself.
+ problemMessage: The compile-time constant expression depends on itself.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -10067,8 +10103,8 @@
const minutesPerHour = 60;
```
RECURSIVE_CONSTRUCTOR_REDIRECT:
- template: "Constructors can't redirect to themselves either directly or indirectly."
- tip: Try changing one of the constructors in the loop to not redirect.
+ problemMessage: "Constructors can't redirect to themselves either directly or indirectly."
+ correctionMessage: Try changing one of the constructors in the loop to not redirect.
hasPublishedDocs: true
comment: |-
No parameters.
@@ -10164,12 +10200,12 @@
```
RECURSIVE_FACTORY_REDIRECT:
sharedName: RECURSIVE_CONSTRUCTOR_REDIRECT
- template: "Constructors can't redirect to themselves either directly or indirectly."
- tip: Try changing one of the constructors in the loop to not redirect.
+ problemMessage: "Constructors can't redirect to themselves either directly or indirectly."
+ correctionMessage: Try changing one of the constructors in the loop to not redirect.
hasPublishedDocs: true
comment: No parameters.
RECURSIVE_INTERFACE_INHERITANCE:
- template: "'{0}' can't be a superinterface of itself: {1}."
+ problemMessage: "'{0}' can't be a superinterface of itself: {1}."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -10197,7 +10233,7 @@
Change the type hierarchy so that there's no circularity.
RECURSIVE_INTERFACE_INHERITANCE_EXTENDS:
sharedName: RECURSIVE_INTERFACE_INHERITANCE
- template: "'{0}' can't extend itself."
+ problemMessage: "'{0}' can't extend itself."
hasPublishedDocs: true
comment: |-
7.10 Superinterfaces: It is a compile-time error if the interface of a
@@ -10213,7 +10249,7 @@
0: the name of the class that implements itself recursively
RECURSIVE_INTERFACE_INHERITANCE_IMPLEMENTS:
sharedName: RECURSIVE_INTERFACE_INHERITANCE
- template: "'{0}' can't implement itself."
+ problemMessage: "'{0}' can't implement itself."
hasPublishedDocs: true
comment: |-
7.10 Superinterfaces: It is a compile-time error if the interface of a
@@ -10229,14 +10265,14 @@
0: the name of the class that implements itself recursively
RECURSIVE_INTERFACE_INHERITANCE_ON:
sharedName: RECURSIVE_INTERFACE_INHERITANCE
- template: "'{0}' can't use itself as a superclass constraint."
+ problemMessage: "'{0}' can't use itself as a superclass constraint."
hasPublishedDocs: true
comment: |-
Parameters:
0: the name of the mixin that constraints itself recursively
RECURSIVE_INTERFACE_INHERITANCE_WITH:
sharedName: RECURSIVE_INTERFACE_INHERITANCE
- template: "'{0}' can't use itself as a mixin."
+ problemMessage: "'{0}' can't use itself as a mixin."
hasPublishedDocs: true
comment: |-
7.10 Superinterfaces: It is a compile-time error if the interface of a
@@ -10251,8 +10287,8 @@
Parameters:
0: the name of the class that implements itself recursively
REDIRECT_GENERATIVE_TO_MISSING_CONSTRUCTOR:
- template: "The constructor '{0}' couldn't be found in '{1}'."
- tip: "Try redirecting to a different constructor, or defining the constructor named '{0}'."
+ problemMessage: "The constructor '{0}' couldn't be found in '{1}'."
+ correctionMessage: "Try redirecting to a different constructor, or defining the constructor named '{0}'."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -10292,8 +10328,8 @@
}
```
REDIRECT_GENERATIVE_TO_NON_GENERATIVE_CONSTRUCTOR:
- template: "Generative constructors can't redirect to a factory constructor."
- tip: Try redirecting to a different constructor.
+ problemMessage: "Generative constructors can't redirect to a factory constructor."
+ correctionMessage: Try redirecting to a different constructor.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -10336,14 +10372,14 @@
}
```
REDIRECT_TO_ABSTRACT_CLASS_CONSTRUCTOR:
- template: "The redirecting constructor '{0}' can't redirect to a constructor of the abstract class '{1}'."
- tip: Try redirecting to a constructor of a different class.
+ problemMessage: "The redirecting constructor '{0}' can't redirect to a constructor of the abstract class '{1}'."
+ correctionMessage: Try redirecting to a constructor of a different class.
comment: |-
A factory constructor can't redirect to a non-generative constructor of an
abstract class.
REDIRECT_TO_INVALID_FUNCTION_TYPE:
- template: "The redirected constructor '{0}' has incompatible parameters with '{1}'."
- tip: Try redirecting to a different constructor.
+ problemMessage: "The redirected constructor '{0}' has incompatible parameters with '{1}'."
+ correctionMessage: Try redirecting to a different constructor.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -10417,8 +10453,8 @@
}
```
REDIRECT_TO_INVALID_RETURN_TYPE:
- template: "The return type '{0}' of the redirected constructor isn't a subtype of '{1}'."
- tip: Try redirecting to a different constructor.
+ problemMessage: "The return type '{0}' of the redirected constructor isn't a subtype of '{1}'."
+ correctionMessage: Try redirecting to a different constructor.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -10476,14 +10512,14 @@
}
```
REDIRECT_TO_MISSING_CONSTRUCTOR:
- template: "The constructor '{0}' couldn't be found in '{1}'."
- tip: "Try redirecting to a different constructor, or define the constructor named '{0}'."
+ problemMessage: "The constructor '{0}' couldn't be found in '{1}'."
+ correctionMessage: "Try redirecting to a different constructor, or define the constructor named '{0}'."
comment: |-
7.6.2 Factories: It is a compile-time error if <i>k</i> is prefixed with
the const modifier but <i>k'</i> is not a constant constructor.
REDIRECT_TO_NON_CLASS:
- template: "The name '{0}' isn't a type and can't be used in a redirected constructor."
- tip: Try redirecting to a different constructor.
+ problemMessage: "The name '{0}' isn't a type and can't be used in a redirected constructor."
+ correctionMessage: Try redirecting to a different constructor.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -10527,8 +10563,8 @@
}
```
REDIRECT_TO_NON_CONST_CONSTRUCTOR:
- template: "A constant redirecting constructor can't redirect to a non-constant constructor."
- tip: Try redirecting to a different constructor.
+ problemMessage: "A constant redirecting constructor can't redirect to a non-constant constructor."
+ correctionMessage: Try redirecting to a different constructor.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -10571,8 +10607,8 @@
}
```
REDIRECT_TO_TYPE_ALIAS_EXPANDS_TO_TYPE_PARAMETER:
- template: "A redirecting constructor can't redirect to a type alias that expands to a type parameter."
- tip: Try replacing it with a class.
+ problemMessage: "A redirecting constructor can't redirect to a type alias that expands to a type parameter."
+ correctionMessage: Try replacing it with a class.
comment: No parameters.
documentation: |-
#### Description
@@ -10611,8 +10647,8 @@
}
```
REFERENCED_BEFORE_DECLARATION:
- template: "Local variable '{0}' can't be referenced before it is declared."
- tip: "Try moving the declaration to before the first use, or renaming the local variable so that it doesn't hide a name from an enclosing scope."
+ problemMessage: "Local variable '{0}' can't be referenced before it is declared."
+ correctionMessage: "Try moving the declaration to before the first use, or renaming the local variable so that it doesn't hide a name from an enclosing scope."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -10665,8 +10701,8 @@
}
```
RETHROW_OUTSIDE_CATCH:
- template: A rethrow must be inside of a catch clause.
- tip: "Try moving the expression into a catch clause, or using a 'throw' expression."
+ problemMessage: A rethrow must be inside of a catch clause.
+ correctionMessage: "Try moving the expression into a catch clause, or using a 'throw' expression."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -10712,8 +10748,8 @@
}
```
RETURN_IN_GENERATIVE_CONSTRUCTOR:
- template: "Constructors can't return values."
- tip: Try removing the return statement or using a factory constructor.
+ problemMessage: "Constructors can't return values."
+ correctionMessage: Try removing the return statement or using a factory constructor.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -10763,8 +10799,8 @@
}
```
RETURN_IN_GENERATOR:
- template: "Can't return a value from a generator function that uses the 'async*' or 'sync*' modifier."
- tip: "Try replacing 'return' with 'yield', using a block function body, or changing the method body modifier."
+ problemMessage: "Can't return a value from a generator function that uses the 'async*' or 'sync*' modifier."
+ correctionMessage: "Try replacing 'return' with 'yield', using a block function body, or changing the method body modifier."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -10823,7 +10859,7 @@
```
RETURN_OF_INVALID_TYPE_FROM_CONSTRUCTOR:
sharedName: RETURN_OF_INVALID_TYPE
- template: "A value of type '{0}' can't be returned from the constructor '{2}' because it has a return type of '{1}'."
+ problemMessage: "A value of type '{0}' can't be returned from the constructor '{2}' because it has a return type of '{1}'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -10832,7 +10868,7 @@
2: the name of the constructor
RETURN_OF_INVALID_TYPE_FROM_FUNCTION:
sharedName: RETURN_OF_INVALID_TYPE
- template: "A value of type '{0}' can't be returned from the function '{2}' because it has a return type of '{1}'."
+ problemMessage: "A value of type '{0}' can't be returned from the function '{2}' because it has a return type of '{1}'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -10870,7 +10906,7 @@
```
RETURN_OF_INVALID_TYPE_FROM_METHOD:
sharedName: RETURN_OF_INVALID_TYPE
- template: "A value of type '{0}' can't be returned from the method '{2}' because it has a return type of '{1}'."
+ problemMessage: "A value of type '{0}' can't be returned from the method '{2}' because it has a return type of '{1}'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -10878,7 +10914,7 @@
1: the expected return type as defined by the method
2: the name of the method
RETURN_OF_INVALID_TYPE_FROM_CLOSURE:
- template: "The return type '{0}' isn't a '{1}', as required by the closure's context."
+ problemMessage: "The return type '{0}' isn't a '{1}', as required by the closure's context."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -10910,7 +10946,7 @@
String Function(String) f = (s) => 3.toString();
```
RETURN_WITHOUT_VALUE:
- template: "The return value is missing after 'return'."
+ problemMessage: "The return value is missing after 'return'."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -10940,7 +10976,7 @@
}
```
SET_ELEMENT_TYPE_NOT_ASSIGNABLE:
- template: "The element type '{0}' can't be assigned to the set type '{1}'."
+ problemMessage: "The element type '{0}' can't be assigned to the set type '{1}'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -10977,8 +11013,8 @@
var s = <int>{'0'.length};
```
SHARED_DEFERRED_PREFIX:
- template: "The prefix of a deferred import can't be used in other import directives."
- tip: Try renaming one of the prefixes.
+ problemMessage: "The prefix of a deferred import can't be used in other import directives."
+ correctionMessage: Try renaming one of the prefixes.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -11021,10 +11057,10 @@
var y = convert.json.encode(x.min(0, 1));
```
SPREAD_EXPRESSION_FROM_DEFERRED_LIBRARY:
- template: "Constant values from a deferred library can't be spread into a const literal."
- tip: Try making the deferred import non-deferred.
+ problemMessage: "Constant values from a deferred library can't be spread into a const literal."
+ correctionMessage: Try making the deferred import non-deferred.
STATIC_ACCESS_TO_INSTANCE_MEMBER:
- template: "Instance member '{0}' can't be accessed using static access."
+ problemMessage: "Instance member '{0}' can't be accessed using static access."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -11083,20 +11119,20 @@
```
IMPLEMENTS_DEFERRED_CLASS:
sharedName: SUBTYPE_OF_DEFERRED_CLASS
- template: "Classes and mixins can't implement deferred classes."
- tip: Try specifying a different interface, removing the class from the list, or changing the import to not be deferred.
+ problemMessage: "Classes and mixins can't implement deferred classes."
+ correctionMessage: Try specifying a different interface, removing the class from the list, or changing the import to not be deferred.
hasPublishedDocs: true
comment: No parameters.
MIXIN_DEFERRED_CLASS:
sharedName: SUBTYPE_OF_DEFERRED_CLASS
- template: "Classes can't mixin deferred classes."
- tip: Try changing the import to not be deferred.
+ problemMessage: "Classes can't mixin deferred classes."
+ correctionMessage: Try changing the import to not be deferred.
hasPublishedDocs: true
comment: No parameters.
EXTENDS_DEFERRED_CLASS:
sharedName: SUBTYPE_OF_DEFERRED_CLASS
- template: "Classes can't extend deferred classes."
- tip: Try specifying a different superclass, or removing the extends clause.
+ problemMessage: "Classes can't extend deferred classes."
+ correctionMessage: Try specifying a different superclass, or removing the extends clause.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -11141,8 +11177,8 @@
```
EXTENDS_DISALLOWED_CLASS:
sharedName: SUBTYPE_OF_DISALLOWED_TYPE
- template: "Classes can't extend '{0}'."
- tip: Try specifying a different superclass, or removing the extends clause.
+ problemMessage: "Classes can't extend '{0}'."
+ correctionMessage: Try specifying a different superclass, or removing the extends clause.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -11202,32 +11238,32 @@
```
MIXIN_OF_DISALLOWED_CLASS:
sharedName: SUBTYPE_OF_DISALLOWED_TYPE
- template: "Classes can't mixin '{0}'."
- tip: Try specifying a different class or mixin, or remove the class or mixin from the list.
+ problemMessage: "Classes can't mixin '{0}'."
+ correctionMessage: Try specifying a different class or mixin, or remove the class or mixin from the list.
hasPublishedDocs: true
comment: |-
Parameters:
0: the name of the disallowed type
MIXIN_SUPER_CLASS_CONSTRAINT_DISALLOWED_CLASS:
sharedName: SUBTYPE_OF_DISALLOWED_TYPE
- template: "''{0}' can't be used as a superclass constraint."
- tip: "Try specifying a different super-class constraint, or remove the 'on' clause."
+ problemMessage: "''{0}' can't be used as a superclass constraint."
+ correctionMessage: "Try specifying a different super-class constraint, or remove the 'on' clause."
hasPublishedDocs: true
comment: |-
Parameters:
0: the name of the disallowed type
IMPLEMENTS_DISALLOWED_CLASS:
sharedName: SUBTYPE_OF_DISALLOWED_TYPE
- template: "Classes and mixins can't implement '{0}'."
- tip: Try specifying a different interface, or remove the class from the list.
+ problemMessage: "Classes and mixins can't implement '{0}'."
+ correctionMessage: Try specifying a different interface, or remove the class from the list.
hasPublishedDocs: true
comment: |-
Parameters:
0: the name of the disallowed type
EXTENDS_TYPE_ALIAS_EXPANDS_TO_TYPE_PARAMETER:
sharedName: SUPERTYPE_EXPANDS_TO_TYPE_PARAMETER
- template: "A type alias that expands to a type parameter can't be used as a superclass."
- tip: Try specifying a different superclass, or removing the extends clause.
+ problemMessage: "A type alias that expands to a type parameter can't be used as a superclass."
+ correctionMessage: Try specifying a different superclass, or removing the extends clause.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -11260,28 +11296,28 @@
```
MIXIN_ON_TYPE_ALIAS_EXPANDS_TO_TYPE_PARAMETER:
sharedName: SUPERTYPE_EXPANDS_TO_TYPE_PARAMETER
- template: "A type alias that expands to a type parameter can't be used as a superclass constraint."
+ problemMessage: "A type alias that expands to a type parameter can't be used as a superclass constraint."
hasPublishedDocs: true
comment: No parameters.
MIXIN_OF_TYPE_ALIAS_EXPANDS_TO_TYPE_PARAMETER:
sharedName: SUPERTYPE_EXPANDS_TO_TYPE_PARAMETER
- template: "A type alias that expands to a type parameter can't be mixed in."
+ problemMessage: "A type alias that expands to a type parameter can't be mixed in."
hasPublishedDocs: true
comment: No parameters.
IMPLEMENTS_TYPE_ALIAS_EXPANDS_TO_TYPE_PARAMETER:
sharedName: SUPERTYPE_EXPANDS_TO_TYPE_PARAMETER
- template: "A type alias that expands to a type parameter can't be implemented."
- tip: Try specifying a class or mixin, or removing the list.
+ problemMessage: "A type alias that expands to a type parameter can't be implemented."
+ correctionMessage: Try specifying a class or mixin, or removing the list.
hasPublishedDocs: true
comment: No parameters.
SUPER_INITIALIZER_IN_OBJECT:
- template: "The class 'Object' can't invoke a constructor from a superclass."
+ problemMessage: "The class 'Object' can't invoke a constructor from a superclass."
comment: |-
7.6.1 Generative Constructors: Let <i>k</i> be a generative constructor. It
is a compile-time error if a generative constructor of class Object
includes a superinitializer.
SUPER_IN_EXTENSION:
- template: "The 'super' keyword can't be used in an extension because an extension doesn't have a superclass."
+ problemMessage: "The 'super' keyword can't be used in an extension because an extension doesn't have a superclass."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -11312,7 +11348,7 @@
}
```
SUPER_IN_INVALID_CONTEXT:
- template: "Invalid context for 'super' invocation."
+ problemMessage: "Invalid context for 'super' invocation."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -11336,7 +11372,7 @@
Rewrite the code to not use `super`.
SUPER_IN_REDIRECTING_CONSTRUCTOR:
- template: "The redirecting constructor can't have a 'super' initializer."
+ problemMessage: "The redirecting constructor can't have a 'super' initializer."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -11370,8 +11406,8 @@
}
```
SWITCH_CASE_COMPLETES_NORMALLY:
- template: "The 'case' should not complete normally."
- tip: "Try adding 'break', or 'return', etc."
+ problemMessage: "The 'case' should not complete normally."
+ correctionMessage: "Try adding 'break', or 'return', etc."
comment: |-
It is an error if any case of a switch statement except the last case (the
default case if present) may complete normally. The previous syntactic
@@ -11379,7 +11415,7 @@
enumerated list of statements (break, continue, return, throw, or rethrow)
is removed.
SWITCH_EXPRESSION_NOT_ASSIGNABLE:
- template: "Type '{0}' of the switch expression isn't assignable to the type '{1}' of case expressions."
+ problemMessage: "Type '{0}' of the switch expression isn't assignable to the type '{1}' of case expressions."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -11435,8 +11471,8 @@
}
```
TEAROFF_OF_GENERATIVE_CONSTRUCTOR_OF_ABSTRACT_CLASS:
- template: "A generative constructor of an abstract class can't be torn off."
- tip: Try tearing off a constructor of a concrete class, or a non-generative constructor.
+ problemMessage: "A generative constructor of an abstract class can't be torn off."
+ correctionMessage: Try tearing off a constructor of a concrete class, or a non-generative constructor.
comment: No parameters.
documentation: |-
#### Description
@@ -11465,7 +11501,7 @@
Tear off the constructor of a concrete class.
THROW_OF_INVALID_TYPE:
- template: "The type '{0}' of the thrown expression must be assignable to 'Object'."
+ problemMessage: "The type '{0}' of the thrown expression must be assignable to 'Object'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -11498,8 +11534,8 @@
}
```
TOP_LEVEL_CYCLE:
- template: "The type of '{0}' can't be inferred because it depends on itself through the cycle: {1}."
- tip: Try adding an explicit type to one or more of the variables in the cycle in order to break the cycle.
+ problemMessage: "The type of '{0}' can't be inferred because it depends on itself through the cycle: {1}."
+ correctionMessage: Try adding an explicit type to one or more of the variables in the cycle in order to break the cycle.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -11546,7 +11582,7 @@
variables is assigned a value that doesn't depend on the other variables
before any of the variables in the cycle are referenced.
TYPE_ALIAS_CANNOT_REFERENCE_ITSELF:
- template: "Typedefs can't reference themselves directly or recursively via another typedef."
+ problemMessage: "Typedefs can't reference themselves directly or recursively via another typedef."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -11575,8 +11611,8 @@
typedef G = void Function(int);
```
TYPE_ANNOTATION_DEFERRED_CLASS:
- template: "The deferred type '{0}' can't be used in a declaration, cast, or type test."
- tip: Try using a different type, or changing the import to not be deferred.
+ problemMessage: "The deferred type '{0}' can't be used in a declaration, cast, or type test."
+ correctionMessage: Try using a different type, or changing the import to not be deferred.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -11619,8 +11655,8 @@
appropriate, then use that type in place of the type from the deferred
library.
TYPE_ARGUMENT_NOT_MATCHING_BOUNDS:
- template: "'{0}' doesn't conform to the bound '{2}' of the type parameter '{1}'."
- tip: "Try using a type that is or is a subclass of '{2}'."
+ problemMessage: "'{0}' doesn't conform to the bound '{2}' of the type parameter '{1}'."
+ correctionMessage: "Try using a type that is or is a subclass of '{2}'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -11655,8 +11691,8 @@
var a = A<int>();
```
TYPE_PARAMETER_REFERENCED_BY_STATIC:
- template: "Static members can't reference type parameters of the class."
- tip: Try removing the reference to the type parameter, or making the member an instance member.
+ problemMessage: "Static members can't reference type parameters of the class."
+ correctionMessage: Try removing the reference to the type parameter, or making the member an instance member.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -11698,8 +11734,8 @@
Note, however, that there isn’t a relationship between `T` and `S`, so this
second option changes the semantics from what was likely to be intended.
TYPE_PARAMETER_SUPERTYPE_OF_ITS_BOUND:
- template: "'{0}' can't be a supertype of its upper bound."
- tip: "Try using a type that is the same as or a subclass of '{1}'."
+ problemMessage: "'{0}' can't be a supertype of its upper bound."
+ correctionMessage: "Try using a type that is the same as or a subclass of '{1}'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -11748,8 +11784,8 @@
class C<T> {}
```
TYPE_TEST_WITH_NON_TYPE:
- template: "The name '{0}' isn't a type and can't be used in an 'is' expression."
- tip: Try correcting the name to match an existing type.
+ problemMessage: "The name '{0}' isn't a type and can't be used in an 'is' expression."
+ correctionMessage: Try correcting the name to match an existing type.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -11800,8 +11836,8 @@
}
```
TYPE_TEST_WITH_UNDEFINED_NAME:
- template: "The name '{0}' isn't defined, so it can't be used in an 'is' expression."
- tip: "Try changing the name to the name of an existing type, or creating a type with the name '{0}'."
+ problemMessage: "The name '{0}' isn't defined, so it can't be used in an 'is' expression."
+ correctionMessage: "Try changing the name to the name of an existing type, or creating a type with the name '{0}'."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -11836,33 +11872,33 @@
```
UNCHECKED_USE_OF_NULLABLE_VALUE_IN_SPREAD:
sharedName: UNCHECKED_USE_OF_NULLABLE_VALUE
- template: "A nullable expression can't be used in a spread."
- tip: "Try checking that the value isn't 'null' before using it in a spread, or use a null-aware spread."
+ problemMessage: "A nullable expression can't be used in a spread."
+ correctionMessage: "Try checking that the value isn't 'null' before using it in a spread, or use a null-aware spread."
hasPublishedDocs: true
UNCHECKED_INVOCATION_OF_NULLABLE_VALUE:
sharedName: UNCHECKED_USE_OF_NULLABLE_VALUE
- template: "The function can't be unconditionally invoked because it can be 'null'."
- tip: "Try adding a null check ('!')."
+ problemMessage: "The function can't be unconditionally invoked because it can be 'null'."
+ correctionMessage: "Try adding a null check ('!')."
hasPublishedDocs: true
UNCHECKED_METHOD_INVOCATION_OF_NULLABLE_VALUE:
sharedName: UNCHECKED_USE_OF_NULLABLE_VALUE
- template: "The method '{0}' can't be unconditionally invoked because the receiver can be 'null'."
- tip: "Try making the call conditional (using '?.') or adding a null check to the target ('!')."
+ problemMessage: "The method '{0}' can't be unconditionally invoked because the receiver can be 'null'."
+ correctionMessage: "Try making the call conditional (using '?.') or adding a null check to the target ('!')."
hasPublishedDocs: true
UNCHECKED_OPERATOR_INVOCATION_OF_NULLABLE_VALUE:
sharedName: UNCHECKED_USE_OF_NULLABLE_VALUE
- template: "The operator '{0}' can't be unconditionally invoked because the receiver can be 'null'."
- tip: "Try adding a null check to the target ('!')."
+ problemMessage: "The operator '{0}' can't be unconditionally invoked because the receiver can be 'null'."
+ correctionMessage: "Try adding a null check to the target ('!')."
hasPublishedDocs: true
UNCHECKED_USE_OF_NULLABLE_VALUE_IN_YIELD_EACH:
sharedName: UNCHECKED_USE_OF_NULLABLE_VALUE
- template: "A nullable expression can't be used in a yield-each statement."
- tip: "Try checking that the value isn't 'null' before using it in a yield-each statement."
+ problemMessage: "A nullable expression can't be used in a yield-each statement."
+ correctionMessage: "Try checking that the value isn't 'null' before using it in a yield-each statement."
hasPublishedDocs: true
UNCHECKED_USE_OF_NULLABLE_VALUE_AS_CONDITION:
sharedName: UNCHECKED_USE_OF_NULLABLE_VALUE
- template: "A nullable expression can't be used as a condition."
- tip: "Try checking that the value isn't 'null' before using it as a condition."
+ problemMessage: "A nullable expression can't be used as a condition."
+ correctionMessage: "Try checking that the value isn't 'null' before using it as a condition."
hasPublishedDocs: true
documentation: |-
#### Description
@@ -11922,17 +11958,17 @@
```
UNCHECKED_USE_OF_NULLABLE_VALUE_AS_ITERATOR:
sharedName: UNCHECKED_USE_OF_NULLABLE_VALUE
- template: "A nullable expression can't be used as an iterator in a for-in loop."
- tip: "Try checking that the value isn't 'null' before using it as an iterator."
+ problemMessage: "A nullable expression can't be used as an iterator in a for-in loop."
+ correctionMessage: "Try checking that the value isn't 'null' before using it as an iterator."
hasPublishedDocs: true
UNCHECKED_PROPERTY_ACCESS_OF_NULLABLE_VALUE:
sharedName: UNCHECKED_USE_OF_NULLABLE_VALUE
- template: "The property '{0}' can't be unconditionally accessed because the receiver can be 'null'."
- tip: "Try making the access conditional (using '?.') or adding a null check to the target ('!')."
+ problemMessage: "The property '{0}' can't be unconditionally accessed because the receiver can be 'null'."
+ correctionMessage: "Try making the access conditional (using '?.') or adding a null check to the target ('!')."
hasPublishedDocs: true
UNDEFINED_ANNOTATION:
- template: "Undefined name '{0}' used as an annotation."
- tip: Try defining the name or importing it from another library.
+ problemMessage: "Undefined name '{0}' used as an annotation."
+ correctionMessage: Try defining the name or importing it from another library.
isUnresolvedIdentifier: true
hasPublishedDocs: true
comment: No parameters.
@@ -11973,8 +12009,8 @@
Otherwise, remove the annotation.
UNDEFINED_CLASS:
- template: "Undefined class '{0}'."
- tip: "Try changing the name to the name of an existing class, or creating a class with the name '{0}'."
+ problemMessage: "Undefined class '{0}'."
+ correctionMessage: "Try changing the name to the name of an existing class, or creating a class with the name '{0}'."
isUnresolvedIdentifier: true
hasPublishedDocs: true
comment: |-
@@ -12013,8 +12049,8 @@
import.
UNDEFINED_CLASS_BOOLEAN:
sharedName: UNDEFINED_CLASS
- template: "Undefined class '{0}'."
- tip: "Try using the type 'bool'."
+ problemMessage: "Undefined class '{0}'."
+ correctionMessage: "Try using the type 'bool'."
isUnresolvedIdentifier: true
hasPublishedDocs: true
comment: |-
@@ -12024,8 +12060,8 @@
Parameters:
0: the name of the undefined class
UNDEFINED_CONSTRUCTOR_IN_INITIALIZER:
- template: "The class '{0}' doesn't have a constructor named '{1}'."
- tip: "Try defining a constructor named '{1}' in '{0}', or invoking a different constructor."
+ problemMessage: "The class '{0}' doesn't have a constructor named '{1}'."
+ correctionMessage: "Try defining a constructor named '{1}' in '{0}', or invoking a different constructor."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -12092,15 +12128,15 @@
```
UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT:
sharedName: UNDEFINED_CONSTRUCTOR_IN_INITIALIZER
- template: "The class '{0}' doesn't have an unnamed constructor."
- tip: "Try defining an unnamed constructor in '{0}', or invoking a different constructor."
+ problemMessage: "The class '{0}' doesn't have an unnamed constructor."
+ correctionMessage: "Try defining an unnamed constructor in '{0}', or invoking a different constructor."
hasPublishedDocs: true
comment: |-
Parameters:
0: the name of the superclass that does not define the invoked constructor
UNDEFINED_ENUM_CONSTANT:
- template: "There's no constant named '{0}' in '{1}'."
- tip: "Try correcting the name to the name of an existing constant, or defining a constant named '{0}'."
+ problemMessage: "There's no constant named '{0}' in '{1}'."
+ correctionMessage: "Try correcting the name to the name of an existing constant, or defining a constant named '{0}'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -12144,8 +12180,8 @@
var e = E.b;
```
UNDEFINED_EXTENSION_GETTER:
- template: "The getter '{0}' isn't defined for the extension '{1}'."
- tip: "Try correcting the name to the name of an existing getter, or defining a getter named '{0}'."
+ problemMessage: "The getter '{0}' isn't defined for the extension '{1}'."
+ correctionMessage: "Try correcting the name to the name of an existing getter, or defining a getter named '{0}'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -12241,8 +12277,8 @@
}
```
UNDEFINED_EXTENSION_METHOD:
- template: "The method '{0}' isn't defined for the extension '{1}'."
- tip: "Try correcting the name to the name of an existing method, or defining a method named '{0}'."
+ problemMessage: "The method '{0}' isn't defined for the extension '{1}'."
+ correctionMessage: "Try correcting the name to the name of an existing method, or defining a method named '{0}'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -12338,8 +12374,8 @@
}
```
UNDEFINED_EXTENSION_OPERATOR:
- template: "The operator '{0}' isn't defined for the extension '{1}'."
- tip: "Try defining the operator '{0}'."
+ problemMessage: "The operator '{0}' isn't defined for the extension '{1}'."
+ correctionMessage: "Try defining the operator '{0}'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -12387,8 +12423,8 @@
extension E on String {}
```
UNDEFINED_EXTENSION_SETTER:
- template: "The setter '{0}' isn't defined for the extension '{1}'."
- tip: "Try correcting the name to the name of an existing setter, or defining a setter named '{0}'."
+ problemMessage: "The setter '{0}' isn't defined for the extension '{1}'."
+ correctionMessage: "Try correcting the name to the name of an existing setter, or defining a setter named '{0}'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -12486,8 +12522,8 @@
}
```
UNDEFINED_FUNCTION:
- template: "The function '{0}' isn't defined."
- tip: "Try importing the library that defines '{0}', correcting the name to the name of an existing function, or defining a function named '{0}'."
+ problemMessage: "The function '{0}' isn't defined."
+ correctionMessage: "Try importing the library that defines '{0}', correcting the name to the name of an existing function, or defining a function named '{0}'."
isUnresolvedIdentifier: true
hasPublishedDocs: true
comment: |-
@@ -12530,8 +12566,8 @@
If the function is defined but isn't visible, then you probably need to add
an import or re-arrange your code to make the function visible.
UNDEFINED_GETTER:
- template: "The getter '{0}' isn't defined for the type '{1}'."
- tip: "Try importing the library that defines '{0}', correcting the name to the name of an existing getter, or defining a getter or field named '{0}'."
+ problemMessage: "The getter '{0}' isn't defined for the type '{1}'."
+ correctionMessage: "Try importing the library that defines '{0}', correcting the name to the name of an existing getter, or defining a getter or field named '{0}'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -12564,16 +12600,16 @@
```
UNDEFINED_GETTER_ON_FUNCTION_TYPE:
sharedName: UNDEFINED_GETTER
- template: "The getter '{0}' isn't defined for the '{1}' function type."
- tip: "Try wrapping the function type alias in parentheses in order to access '{0}' as an extension getter on 'Type'."
+ problemMessage: "The getter '{0}' isn't defined for the '{1}' function type."
+ correctionMessage: "Try wrapping the function type alias in parentheses in order to access '{0}' as an extension getter on 'Type'."
hasPublishedDocs: true
comment: |-
Parameters:
0: the name of the getter
1: the name of the function type alias
UNDEFINED_IDENTIFIER:
- template: "Undefined name '{0}'."
- tip: Try correcting the name to one that is defined, or defining the name.
+ problemMessage: "Undefined name '{0}'."
+ correctionMessage: Try correcting the name to one that is defined, or defining the name.
isUnresolvedIdentifier: true
hasPublishedDocs: true
comment: |-
@@ -12608,8 +12644,8 @@
If the identifier is defined but isn't visible, then you probably need to
add an import or re-arrange your code to make the identifier visible.
UNDEFINED_IDENTIFIER_AWAIT:
- template: "Undefined name 'await' in function body not marked with 'async'."
- tip: "Try correcting the name to one that is defined, defining the name, or adding 'async' to the enclosing function body."
+ problemMessage: "Undefined name 'await' in function body not marked with 'async'."
+ correctionMessage: "Try correcting the name to one that is defined, defining the name, or adding 'async' to the enclosing function body."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -12638,8 +12674,8 @@
void f(p) async { await p; }
```
UNDEFINED_METHOD:
- template: "The method '{0}' isn't defined for the type '{1}'."
- tip: "Try correcting the name to the name of an existing method, or defining a method named '{0}'."
+ problemMessage: "The method '{0}' isn't defined for the type '{1}'."
+ correctionMessage: "Try correcting the name to the name of an existing method, or defining a method named '{0}'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -12672,16 +12708,16 @@
```
UNDEFINED_METHOD_ON_FUNCTION_TYPE:
sharedName: UNDEFINED_METHOD
- template: "The method '{0}' isn't defined for the '{1}' function type."
- tip: "Try wrapping the function type alias in parentheses in order to access '{0}' as an extension method on 'Type'."
+ problemMessage: "The method '{0}' isn't defined for the '{1}' function type."
+ correctionMessage: "Try wrapping the function type alias in parentheses in order to access '{0}' as an extension method on 'Type'."
hasPublishedDocs: true
comment: |-
Parameters:
0: the name of the method
1: the name of the function type alias
UNDEFINED_NAMED_PARAMETER:
- template: "The named parameter '{0}' isn't defined."
- tip: "Try correcting the name to an existing named parameter's name, or defining a named parameter with the name '{0}'."
+ problemMessage: "The named parameter '{0}' isn't defined."
+ correctionMessage: "Try correcting the name to an existing named parameter's name, or defining a named parameter with the name '{0}'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -12756,8 +12792,8 @@
}
```
UNDEFINED_OPERATOR:
- template: "The operator '{0}' isn't defined for the type '{1}'."
- tip: "Try defining the operator '{0}'."
+ problemMessage: "The operator '{0}' isn't defined for the type '{1}'."
+ correctionMessage: "Try defining the operator '{0}'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -12792,8 +12828,8 @@
C f(C c) => c + 2;
```
UNDEFINED_PREFIXED_NAME:
- template: "The name '{0}' is being referenced through the prefix '{1}', but it isn't defined in any of the libraries imported using that prefix."
- tip: "Try correcting the prefix or importing the library that defines '{0}'."
+ problemMessage: "The name '{0}' is being referenced through the prefix '{1}', but it isn't defined in any of the libraries imported using that prefix."
+ correctionMessage: "Try correcting the prefix or importing the library that defines '{0}'."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -12824,8 +12860,8 @@
If the name is wrong, then change it to one of the names that's declared in
the imported libraries.
UNDEFINED_SETTER:
- template: "The setter '{0}' isn't defined for the type '{1}'."
- tip: "Try importing the library that defines '{0}', correcting the name to the name of an existing setter, or defining a setter or field named '{0}'."
+ problemMessage: "The setter '{0}' isn't defined for the type '{1}'."
+ correctionMessage: "Try importing the library that defines '{0}', correcting the name to the name of an existing setter, or defining a setter or field named '{0}'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -12868,8 +12904,8 @@
```
UNDEFINED_SETTER_ON_FUNCTION_TYPE:
sharedName: UNDEFINED_SETTER
- template: "The setter '{0}' isn't defined for the '{1}' function type."
- tip: "Try wrapping the function type alias in parentheses in order to access '{0}' as an extension getter on 'Type'."
+ problemMessage: "The setter '{0}' isn't defined for the '{1}' function type."
+ correctionMessage: "Try wrapping the function type alias in parentheses in order to access '{0}' as an extension getter on 'Type'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -12877,8 +12913,8 @@
1: the name of the function type alias
UNDEFINED_SUPER_GETTER:
sharedName: UNDEFINED_SUPER_MEMBER
- template: "The getter '{0}' isn't defined in a superclass of '{1}'."
- tip: "Try correcting the name to the name of an existing getter, or defining a getter or field named '{0}' in a superclass."
+ problemMessage: "The getter '{0}' isn't defined in a superclass of '{1}'."
+ correctionMessage: "Try correcting the name to the name of an existing getter, or defining a getter or field named '{0}' in a superclass."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -12886,8 +12922,8 @@
1: the name of the enclosing type where the getter is being looked for
UNDEFINED_SUPER_METHOD:
sharedName: UNDEFINED_SUPER_MEMBER
- template: "The method '{0}' isn't defined in a superclass of '{1}'."
- tip: "Try correcting the name to the name of an existing method, or defining a method named '{0}' in a superclass."
+ problemMessage: "The method '{0}' isn't defined in a superclass of '{1}'."
+ correctionMessage: "Try correcting the name to the name of an existing method, or defining a method named '{0}' in a superclass."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -12936,8 +12972,8 @@
superclasses or remove the invocation.
UNDEFINED_SUPER_OPERATOR:
sharedName: UNDEFINED_SUPER_MEMBER
- template: "The operator '{0}' isn't defined in a superclass of '{1}'."
- tip: "Try defining the operator '{0}' in a superclass."
+ problemMessage: "The operator '{0}' isn't defined in a superclass of '{1}'."
+ correctionMessage: "Try defining the operator '{0}' in a superclass."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -12945,16 +12981,16 @@
1: the name of the enclosing type where the operator is being looked for
UNDEFINED_SUPER_SETTER:
sharedName: UNDEFINED_SUPER_MEMBER
- template: "The setter '{0}' isn't defined in a superclass of '{1}'."
- tip: "Try correcting the name to the name of an existing setter, or defining a setter or field named '{0}' in a superclass."
+ problemMessage: "The setter '{0}' isn't defined in a superclass of '{1}'."
+ correctionMessage: "Try correcting the name to the name of an existing setter, or defining a setter or field named '{0}' in a superclass."
hasPublishedDocs: true
comment: |-
Parameters:
0: the name of the setter
1: the name of the enclosing type where the setter is being looked for
UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER:
- template: Static members from supertypes must be qualified by the name of the defining type.
- tip: "Try adding '{0}.' before the name."
+ problemMessage: Static members from supertypes must be qualified by the name of the defining type.
+ correctionMessage: "Try adding '{0}.' before the name."
hasPublishedDocs: true
comment: |-
This is a specialization of [INSTANCE_ACCESS_TO_STATIC_MEMBER] that is used
@@ -13001,8 +13037,8 @@
}
```
UNQUALIFIED_REFERENCE_TO_STATIC_MEMBER_OF_EXTENDED_TYPE:
- template: Static members from the extended type or one of its superclasses must be qualified by the name of the defining type.
- tip: "Try adding '{0}.' before the name."
+ problemMessage: Static members from the extended type or one of its superclasses must be qualified by the name of the defining type.
+ correctionMessage: "Try adding '{0}.' before the name."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -13065,8 +13101,8 @@
}
```
URI_DOES_NOT_EXIST:
- template: "Target of URI doesn't exist: '{0}'."
- tip: Try creating the file referenced by the URI, or Try using a URI for a file that does exist.
+ problemMessage: "Target of URI doesn't exist: '{0}'."
+ correctionMessage: Try creating the file referenced by the URI, or Try using a URI for a file that does exist.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -13092,8 +13128,8 @@
If the URI is correct, then create the file.
URI_HAS_NOT_BEEN_GENERATED:
- template: "Target of URI hasn't been generated: '{0}'."
- tip: Try running the generator that will generate the file referenced by the URI.
+ problemMessage: "Target of URI hasn't been generated: '{0}'."
+ correctionMessage: Try running the generator that will generate the file referenced by the URI.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -13129,7 +13165,7 @@
If the file isn't a generated file, then check the spelling of the URI or
create the file.
URI_WITH_INTERPOLATION:
- template: "URIs can't use string interpolation."
+ problemMessage: "URIs can't use string interpolation."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -13162,8 +13198,8 @@
var zero = min(0, 0);
```
USE_OF_VOID_RESULT:
- template: "This expression has a type of 'void' so its value can't be used."
- tip: "Try checking to see if you're using the correct API; there might be a function or call that returns void you didn't expect. Also check type parameters and variables which might also be void."
+ problemMessage: "This expression has a type of 'void' so its value can't be used."
+ correctionMessage: "Try checking to see if you're using the correct API; there might be a function or call that returns void you didn't expect. Also check type parameters and variables which might also be void."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -13192,8 +13228,8 @@
Either rewrite the code so that the expression has a value or rewrite the
code so that it doesn't depend on the value.
VARIABLE_TYPE_MISMATCH:
- template: "A value of type '{0}' can't be assigned to a const variable of type '{1}'."
- tip: "Try using a subtype, or removing the 'const' keyword"
+ problemMessage: "A value of type '{0}' can't be assigned to a const variable of type '{1}'."
+ correctionMessage: "Try using a subtype, or removing the 'const' keyword"
hasPublishedDocs: true
comment: |-
Parameters:
@@ -13236,8 +13272,8 @@
const int y = x;
```
WRONG_EXPLICIT_TYPE_PARAMETER_VARIANCE_IN_SUPERINTERFACE:
- template: "'{0}' is an '{1}' type parameter and can't be used in an '{2}' position in '{3}'."
- tip: "Try using 'in' type parameters in 'in' positions and 'out' type parameters in 'out' positions in the superinterface."
+ problemMessage: "'{0}' is an '{1}' type parameter and can't be used in an '{2}' position in '{3}'."
+ correctionMessage: "Try using 'in' type parameters in 'in' positions and 'out' type parameters in 'out' positions in the superinterface."
comment: |-
Let `C` be a generic class that declares a formal type parameter `X`, and
assume that `T` is a direct superinterface of `C`.
@@ -13255,7 +13291,7 @@
superinterface {3}
3: the name of the superinterface
WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR:
- template: "Operator '{0}' should declare exactly {1} parameters, but {2} found."
+ problemMessage: "Operator '{0}' should declare exactly {1} parameters, but {2} found."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -13293,7 +13329,7 @@
but I don't know what to link to.
WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR_MINUS:
sharedName: WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR
- template: "Operator '-' should declare 0 or 1 parameter, but {0} found."
+ problemMessage: "Operator '-' should declare 0 or 1 parameter, but {0} found."
hasPublishedDocs: true
comment: |-
7.1.1 Operators: It is a compile time error if the arity of the
@@ -13302,7 +13338,7 @@
Parameters:
0: the number of parameters found in the operator declaration
WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER:
- template: Setters must declare exactly one required positional parameter.
+ problemMessage: Setters must declare exactly one required positional parameter.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -13345,8 +13381,8 @@
}
```
WRONG_NUMBER_OF_TYPE_ARGUMENTS:
- template: "The type '{0}' is declared with {1} type parameters, but {2} type arguments were given."
- tip: Try adjusting the number of type arguments to match the number of type parameters.
+ problemMessage: "The type '{0}' is declared with {1} type parameters, but {2} type arguments were given."
+ correctionMessage: Try adjusting the number of type arguments to match the number of type parameters.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -13396,8 +13432,8 @@
void f(C<int> x) {}
```
WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR:
- template: "The constructor '{0}.{1}' doesn't have type parameters."
- tip: Try moving type arguments to after the type name.
+ problemMessage: "The constructor '{0}.{1}' doesn't have type parameters."
+ correctionMessage: Try moving type arguments to after the type name.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -13447,8 +13483,8 @@
C f() => C.named();
```
WRONG_NUMBER_OF_TYPE_ARGUMENTS_EXTENSION:
- template: "The extension '{0}' is declared with {1} type parameters, but {2} type arguments were given."
- tip: Try adjusting the number of type arguments.
+ problemMessage: "The extension '{0}' is declared with {1} type parameters, but {2} type arguments were given."
+ correctionMessage: Try adjusting the number of type arguments.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -13494,23 +13530,23 @@
```
WRONG_NUMBER_OF_TYPE_ARGUMENTS_ANONYMOUS_FUNCTION:
sharedName: WRONG_NUMBER_OF_TYPE_ARGUMENTS_FUNCTION
- template: "This function is declared with {0} type parameters, but {1} type arguments were given."
- tip: Try adjusting the number of type arguments to match the number of type parameters.
+ problemMessage: "This function is declared with {0} type parameters, but {1} type arguments were given."
+ correctionMessage: Try adjusting the number of type arguments to match the number of type parameters.
comment: |-
Parameters:
0: the number of type parameters that were declared
1: the number of type arguments provided
WRONG_NUMBER_OF_TYPE_ARGUMENTS_FUNCTION:
- template: "The function '{0}' is declared with {1} type parameters, but {2} type arguments were given."
- tip: Try adjusting the number of type arguments to match the number of type parameters.
+ problemMessage: "The function '{0}' is declared with {1} type parameters, but {2} type arguments were given."
+ correctionMessage: Try adjusting the number of type arguments to match the number of type parameters.
comment: |-
Parameters:
0: the name of the function being referenced
1: the number of type parameters that were declared
2: the number of type arguments provided
WRONG_NUMBER_OF_TYPE_ARGUMENTS_METHOD:
- template: "The method '{0}' is declared with {1} type parameters, but {2} type arguments are given."
- tip: Try adjusting the number of type arguments.
+ problemMessage: "The method '{0}' is declared with {1} type parameters, but {2} type arguments are given."
+ correctionMessage: Try adjusting the number of type arguments.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -13562,15 +13598,15 @@
int f(C c) => c.m(2);
```
WRONG_TYPE_PARAMETER_VARIANCE_IN_SUPERINTERFACE:
- template: "'{0}' can't be used contravariantly or invariantly in '{1}'."
- tip: Try not using class type parameters in types of formal parameters of function types, nor in explicitly contravariant or invariant superinterfaces.
+ problemMessage: "'{0}' can't be used contravariantly or invariantly in '{1}'."
+ correctionMessage: Try not using class type parameters in types of formal parameters of function types, nor in explicitly contravariant or invariant superinterfaces.
comment: |-
Let `C` be a generic class that declares a formal type parameter `X`, and
assume that `T` is a direct superinterface of `C`. It is a compile-time
error if `X` occurs contravariantly or invariantly in `T`.
WRONG_TYPE_PARAMETER_VARIANCE_POSITION:
- template: "The '{0}' type parameter '{1}' can't be used in an '{2}' position."
- tip: "Try removing the type parameter or change the explicit variance modifier declaration for the type parameter to another one of 'in', 'out', or 'inout'."
+ problemMessage: "The '{0}' type parameter '{1}' can't be used in an '{2}' position."
+ correctionMessage: "Try removing the type parameter or change the explicit variance modifier declaration for the type parameter to another one of 'in', 'out', or 'inout'."
comment: |-
Let `C` be a generic class that declares a formal type parameter `X`.
@@ -13590,8 +13626,8 @@
2: the variance position that the type parameter {1} is in
YIELD_EACH_IN_NON_GENERATOR:
sharedName: YIELD_IN_NON_GENERATOR
- template: "Yield-each statements must be in a generator function (one marked with either 'async*' or 'sync*')."
- tip: "Try adding 'async*' or 'sync*' to the enclosing function."
+ problemMessage: "Yield-each statements must be in a generator function (one marked with either 'async*' or 'sync*')."
+ correctionMessage: "Try adding 'async*' or 'sync*' to the enclosing function."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -13633,8 +13669,8 @@
}
```
YIELD_IN_NON_GENERATOR:
- template: "Yield statements must be in a generator function (one marked with either 'async*' or 'sync*')."
- tip: "Try adding 'async*' or 'sync*' to the enclosing function."
+ problemMessage: "Yield statements must be in a generator function (one marked with either 'async*' or 'sync*')."
+ correctionMessage: "Try adding 'async*' or 'sync*' to the enclosing function."
hasPublishedDocs: true
comment: |-
?? Yield: It is a compile-time error if a yield statement appears in a
@@ -13642,7 +13678,7 @@
No parameters.
YIELD_OF_INVALID_TYPE:
- template: "The type '{0}' implied by the 'yield' expression must be assignable to '{1}'."
+ problemMessage: "The type '{0}' implied by the 'yield' expression must be assignable to '{1}'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -13689,202 +13725,202 @@
```
FfiCode:
ANNOTATION_ON_POINTER_FIELD:
- template: "Fields in a struct class whose type is 'Pointer' should not have any annotations."
- tip: Try removing the annotation.
+ problemMessage: "Fields in a struct class whose type is 'Pointer' should not have any annotations."
+ correctionMessage: Try removing the annotation.
comment: No parameters.
ARGUMENT_MUST_BE_A_CONSTANT:
- template: "Argument '{0}' must be a constant."
- tip: Try replacing the value with a literal or const.
+ problemMessage: "Argument '{0}' must be a constant."
+ correctionMessage: Try replacing the value with a literal or const.
comment: |-
Parameters:
0: the name of the argument
CREATION_OF_STRUCT_OR_UNION:
- template: "Subclasses of 'Struct' and 'Union' are backed by native memory, and can't be instantiated by a generative constructor."
- tip: "Try allocating it via allocation, or load from a 'Pointer'."
+ problemMessage: "Subclasses of 'Struct' and 'Union' are backed by native memory, and can't be instantiated by a generative constructor."
+ correctionMessage: "Try allocating it via allocation, or load from a 'Pointer'."
comment: No parameters.
EMPTY_STRUCT:
- template: "Struct '{0}' is empty. Empty structs are undefined behavior."
- tip: "Try adding a field to '{0}' or use a different Struct."
+ problemMessage: "Struct '{0}' is empty. Empty structs are undefined behavior."
+ correctionMessage: "Try adding a field to '{0}' or use a different Struct."
comment: |-
Parameters:
0: the name of the struct class
EXTRA_ANNOTATION_ON_STRUCT_FIELD:
- template: Fields in a struct class must have exactly one annotation indicating the native type.
- tip: Try removing the extra annotation.
+ problemMessage: Fields in a struct class must have exactly one annotation indicating the native type.
+ correctionMessage: Try removing the extra annotation.
comment: No parameters.
EXTRA_SIZE_ANNOTATION_CARRAY:
- template: "'Array's must have exactly one 'Array' annotation."
- tip: Try removing the extra annotation.
+ problemMessage: "'Array's must have exactly one 'Array' annotation."
+ correctionMessage: Try removing the extra annotation.
comment: No parameters.
FFI_NATIVE_ONLY_STATIC:
- template: FfiNative annotations can only be used on static functions.
- tip: Change the method to static.
+ problemMessage: FfiNative annotations can only be used on static functions.
+ correctionMessage: Change the method to static.
comment: No parameters.
FIELD_INITIALIZER_IN_STRUCT:
- template: "Constructors in subclasses of 'Struct' and 'Union' can't have field initializers."
- tip: Try removing the field initializer and marking the field as external.
+ problemMessage: "Constructors in subclasses of 'Struct' and 'Union' can't have field initializers."
+ correctionMessage: Try removing the field initializer and marking the field as external.
comment: No parameters.
FIELD_IN_STRUCT_WITH_INITIALIZER:
- template: "Fields in subclasses of 'Struct' and 'Union' can't have initializers."
- tip: Try removing the initializer and marking the field as external.
+ problemMessage: "Fields in subclasses of 'Struct' and 'Union' can't have initializers."
+ correctionMessage: Try removing the initializer and marking the field as external.
comment: No parameters.
FIELD_MUST_BE_EXTERNAL_IN_STRUCT:
- template: "Fields of 'Struct' and 'Union' subclasses must be marked external."
- tip: "Try adding the 'external' modifier."
+ problemMessage: "Fields of 'Struct' and 'Union' subclasses must be marked external."
+ correctionMessage: "Try adding the 'external' modifier."
comment: No parameters.
GENERIC_STRUCT_SUBCLASS:
- template: "The class '{0}' can't extend 'Struct' or 'Union' because it is generic."
- tip: "Try removing the type parameters from '{0}'."
+ problemMessage: "The class '{0}' can't extend 'Struct' or 'Union' because it is generic."
+ correctionMessage: "Try removing the type parameters from '{0}'."
comment: |-
Parameters:
0: the name of the struct class
INVALID_EXCEPTION_VALUE:
- template: "The method 'Pointer.fromFunction' must not have an exceptional return value (the second argument) when the return type of the function is either 'void', 'Handle' or 'Pointer'."
- tip: Try removing the exceptional return value.
+ problemMessage: "The method 'Pointer.fromFunction' must not have an exceptional return value (the second argument) when the return type of the function is either 'void', 'Handle' or 'Pointer'."
+ correctionMessage: Try removing the exceptional return value.
comment: No parameters.
INVALID_FIELD_TYPE_IN_STRUCT:
- template: "Fields in struct classes can't have the type '{0}'. They can only be declared as 'int', 'double', 'Array', 'Pointer', or subtype of 'Struct' or 'Union'."
- tip: "Try using 'int', 'double', 'Array', 'Pointer', or subtype of 'Struct' or 'Union'."
+ problemMessage: "Fields in struct classes can't have the type '{0}'. They can only be declared as 'int', 'double', 'Array', 'Pointer', or subtype of 'Struct' or 'Union'."
+ correctionMessage: "Try using 'int', 'double', 'Array', 'Pointer', or subtype of 'Struct' or 'Union'."
comment: |-
Parameters:
0: the type of the field
LEAF_CALL_MUST_NOT_RETURN_HANDLE:
- template: FFI leaf call must not return a Handle.
- tip: Try changing the return type to primitive or struct.
+ problemMessage: FFI leaf call must not return a Handle.
+ correctionMessage: Try changing the return type to primitive or struct.
comment: No parameters.
LEAF_CALL_MUST_NOT_TAKE_HANDLE:
- template: FFI leaf call must not take arguments of type Handle.
- tip: Try changing the argument type to primitive or struct.
+ problemMessage: FFI leaf call must not take arguments of type Handle.
+ correctionMessage: Try changing the argument type to primitive or struct.
comment: No parameters.
MISMATCHED_ANNOTATION_ON_STRUCT_FIELD:
- template: The annotation does not match the declared type of the field.
- tip: Try using a different annotation or changing the declared type to match.
+ problemMessage: The annotation does not match the declared type of the field.
+ correctionMessage: Try using a different annotation or changing the declared type to match.
comment: No parameters.
MISSING_ANNOTATION_ON_STRUCT_FIELD:
- template: "Fields in a struct class must either have the type 'Pointer' or an annotation indicating the native type."
- tip: Try adding an annotation.
+ problemMessage: "Fields in a struct class must either have the type 'Pointer' or an annotation indicating the native type."
+ correctionMessage: Try adding an annotation.
comment: No parameters.
MISSING_EXCEPTION_VALUE:
- template: "The method 'Pointer.fromFunction' must have an exceptional return value (the second argument) when the return type of the function is neither 'void', 'Handle' or 'Pointer'."
- tip: Try adding an exceptional return value.
+ problemMessage: "The method 'Pointer.fromFunction' must have an exceptional return value (the second argument) when the return type of the function is neither 'void', 'Handle' or 'Pointer'."
+ correctionMessage: Try adding an exceptional return value.
comment: No parameters.
MISSING_FIELD_TYPE_IN_STRUCT:
- template: "Fields in struct classes must have an explicitly declared type of 'int', 'double' or 'Pointer'."
- tip: "Try using 'int', 'double' or 'Pointer'."
+ problemMessage: "Fields in struct classes must have an explicitly declared type of 'int', 'double' or 'Pointer'."
+ correctionMessage: "Try using 'int', 'double' or 'Pointer'."
comment: |-
Parameters:
0: the type of the field
MISSING_SIZE_ANNOTATION_CARRAY:
- template: "'Array's must have exactly one 'Array' annotation."
- tip: "Try adding a 'Array' annotation."
+ problemMessage: "'Array's must have exactly one 'Array' annotation."
+ correctionMessage: "Try adding a 'Array' annotation."
comment: No parameters.
MUST_BE_A_NATIVE_FUNCTION_TYPE:
- template: "The type '{0}' given to '{1}' must be a valid 'dart:ffi' native function type."
- tip: "Try changing the type to only use members for 'dart:ffi'."
+ problemMessage: "The type '{0}' given to '{1}' must be a valid 'dart:ffi' native function type."
+ correctionMessage: "Try changing the type to only use members for 'dart:ffi'."
comment: |-
Parameters:
0: the type that should be a valid dart:ffi native type.
1: the name of the function whose invocation depends on this relationship
MUST_BE_A_SUBTYPE:
- template: "The type '{0}' must be a subtype of '{1}' for '{2}'."
- tip: Try changing one or both of the type arguments.
+ problemMessage: "The type '{0}' must be a subtype of '{1}' for '{2}'."
+ correctionMessage: Try changing one or both of the type arguments.
comment: |-
Parameters:
0: the type that should be a subtype
1: the supertype that the subtype is compared to
2: the name of the function whose invocation depends on this relationship
NON_CONSTANT_TYPE_ARGUMENT:
- template: "The type arguments to '{0}' must be compile time constants but type parameters are not constants."
- tip: Try changing the type argument to be a constant type.
+ problemMessage: "The type arguments to '{0}' must be compile time constants but type parameters are not constants."
+ correctionMessage: Try changing the type argument to be a constant type.
comment: |-
Parameters:
0: the name of the function, method, or constructor having type arguments
NON_NATIVE_FUNCTION_TYPE_ARGUMENT_TO_POINTER:
- template: "The type argument for the pointer '{0}' must be a 'NativeFunction' in order to use 'asFunction'."
- tip: "Try changing the type argument to be a 'NativeFunction'."
+ problemMessage: "The type argument for the pointer '{0}' must be a 'NativeFunction' in order to use 'asFunction'."
+ correctionMessage: "Try changing the type argument to be a 'NativeFunction'."
comment: |-
Parameters:
0: the type that should be a valid dart:ffi native type.
NON_POSITIVE_ARRAY_DIMENSION:
- template: Array dimensions must be positive numbers.
- tip: Try changing the input to a positive number.
+ problemMessage: Array dimensions must be positive numbers.
+ correctionMessage: Try changing the input to a positive number.
comment: No parameters.
NON_SIZED_TYPE_ARGUMENT:
- template: "Type arguments to '{0}' can't have the type '{1}'. They can only be declared as native integer, 'Float', 'Double', 'Pointer', or subtype of 'Struct' or 'Union'."
- tip: "Try using a native integer, 'Float', 'Double', 'Pointer', or subtype of 'Struct' or 'Union'."
+ problemMessage: "Type arguments to '{0}' can't have the type '{1}'. They can only be declared as native integer, 'Float', 'Double', 'Pointer', or subtype of 'Struct' or 'Union'."
+ correctionMessage: "Try using a native integer, 'Float', 'Double', 'Pointer', or subtype of 'Struct' or 'Union'."
comment: |-
Parameters:
0: the type of the field
PACKED_ANNOTATION:
- template: "Structs must have at most one 'Packed' annotation."
- tip: "Try removing extra 'Packed' annotations."
+ problemMessage: "Structs must have at most one 'Packed' annotation."
+ correctionMessage: "Try removing extra 'Packed' annotations."
comment: No parameters.
PACKED_ANNOTATION_ALIGNMENT:
- template: Only packing to 1, 2, 4, 8, and 16 bytes is supported.
- tip: "Try changing the 'Packed' annotation alignment to 1, 2, 4, 8, or 16."
+ problemMessage: Only packing to 1, 2, 4, 8, and 16 bytes is supported.
+ correctionMessage: "Try changing the 'Packed' annotation alignment to 1, 2, 4, 8, or 16."
comment: No parameters.
PACKED_NESTING_NON_PACKED:
- template: "Nesting the non-packed or less tightly packed struct '{0}' in a packed struct '{1}' is not supported."
- tip: Try packing the nested struct or packing the nested struct more tightly.
+ problemMessage: "Nesting the non-packed or less tightly packed struct '{0}' in a packed struct '{1}' is not supported."
+ correctionMessage: Try packing the nested struct or packing the nested struct more tightly.
comment: |-
Parameters:
0: the name of the outer struct
1: the name of the struct being nested
SIZE_ANNOTATION_DIMENSIONS:
- template: "'Array's must have an 'Array' annotation that matches the dimensions."
- tip: "Try adjusting the arguments in the 'Array' annotation."
+ problemMessage: "'Array's must have an 'Array' annotation that matches the dimensions."
+ correctionMessage: "Try adjusting the arguments in the 'Array' annotation."
comment: No parameters.
SUBTYPE_OF_FFI_CLASS_IN_EXTENDS:
sharedName: SUBTYPE_OF_FFI_CLASS
- template: "The class '{0}' can't extend '{1}'."
- tip: "Try extending 'Struct' or 'Union'."
+ problemMessage: "The class '{0}' can't extend '{1}'."
+ correctionMessage: "Try extending 'Struct' or 'Union'."
comment: |-
Parameters:
0: the name of the subclass
1: the name of the class being extended, implemented, or mixed in
SUBTYPE_OF_FFI_CLASS_IN_IMPLEMENTS:
sharedName: SUBTYPE_OF_FFI_CLASS
- template: "The class '{0}' can't implement '{1}'."
- tip: "Try extending 'Struct' or 'Union'."
+ problemMessage: "The class '{0}' can't implement '{1}'."
+ correctionMessage: "Try extending 'Struct' or 'Union'."
comment: |-
Parameters:
0: the name of the subclass
1: the name of the class being extended, implemented, or mixed in
SUBTYPE_OF_FFI_CLASS_IN_WITH:
sharedName: SUBTYPE_OF_FFI_CLASS
- template: "The class '{0}' can't mix in '{1}'."
- tip: "Try extending 'Struct' or 'Union'."
+ problemMessage: "The class '{0}' can't mix in '{1}'."
+ correctionMessage: "Try extending 'Struct' or 'Union'."
comment: |-
Parameters:
0: the name of the subclass
1: the name of the class being extended, implemented, or mixed in
SUBTYPE_OF_STRUCT_CLASS_IN_EXTENDS:
sharedName: SUBTYPE_OF_STRUCT_CLASS
- template: "The class '{0}' can't extend '{1}' because '{1}' is a subtype of 'Struct' or 'Union'."
- tip: "Try extending 'Struct' or 'Union' directly."
+ problemMessage: "The class '{0}' can't extend '{1}' because '{1}' is a subtype of 'Struct' or 'Union'."
+ correctionMessage: "Try extending 'Struct' or 'Union' directly."
comment: |-
Parameters:
0: the name of the subclass
1: the name of the class being extended, implemented, or mixed in
SUBTYPE_OF_STRUCT_CLASS_IN_IMPLEMENTS:
sharedName: SUBTYPE_OF_STRUCT_CLASS
- template: "The class '{0}' can't implement '{1}' because '{1}' is a subtype of 'Struct' or 'Union'."
- tip: "Try extending 'Struct' or 'Union' directly."
+ problemMessage: "The class '{0}' can't implement '{1}' because '{1}' is a subtype of 'Struct' or 'Union'."
+ correctionMessage: "Try extending 'Struct' or 'Union' directly."
comment: |-
Parameters:
0: the name of the subclass
1: the name of the class being extended, implemented, or mixed in
SUBTYPE_OF_STRUCT_CLASS_IN_WITH:
sharedName: SUBTYPE_OF_STRUCT_CLASS
- template: "The class '{0}' can't mix in '{1}' because '{1}' is a subtype of 'Struct' or 'Union'."
- tip: "Try extending 'Struct' or 'Union' directly."
+ problemMessage: "The class '{0}' can't mix in '{1}' because '{1}' is a subtype of 'Struct' or 'Union'."
+ correctionMessage: "Try extending 'Struct' or 'Union' directly."
comment: |-
Parameters:
0: the name of the subclass
1: the name of the class being extended, implemented, or mixed in
HintCode:
ARGUMENT_TYPE_NOT_ASSIGNABLE_TO_ERROR_HANDLER:
- template: "The argument type '{0}' can't be assigned to the parameter type '{1} Function(Object)' or '{1} Function(Object, StackTrace)'."
+ problemMessage: "The argument type '{0}' can't be assigned to the parameter type '{1} Function(Object)' or '{1} Function(Object, StackTrace)'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -13944,18 +13980,18 @@
}
```
ASSIGNMENT_OF_DO_NOT_STORE:
- template: "'{0}' is marked 'doNotStore' and shouldn't be assigned to a field or top-level variable."
- tip: Try removing the assignment.
+ problemMessage: "'{0}' is marked 'doNotStore' and shouldn't be assigned to a field or top-level variable."
+ correctionMessage: Try removing the assignment.
comment: Users should not assign values marked `@doNotStore`.
CAN_BE_NULL_AFTER_NULL_AWARE:
- template: "The receiver uses '?.', so its value can be null."
- tip: "Replace the '.' with a '?.' in the invocation."
+ problemMessage: "The receiver uses '?.', so its value can be null."
+ correctionMessage: "Replace the '.' with a '?.' in the invocation."
comment: |-
When the target expression uses '?.' operator, it can be `null`, so all the
subsequent invocations should also use '?.' operator.
DEAD_CODE:
- template: Dead code.
- tip: Try removing the code, or fixing the code before it so that it can be reached.
+ problemMessage: Dead code.
+ correctionMessage: Try removing the code, or fixing the code before it so that it can be reached.
hasPublishedDocs: true
comment: |-
Dead code is code that is never reached, this can happen for instance if a
@@ -14011,8 +14047,8 @@
}
```
DEAD_CODE_CATCH_FOLLOWING_CATCH:
- template: "Dead code: Catch clauses after a 'catch (e)' or an 'on Object catch (e)' are never reached."
- tip: Try reordering the catch clauses so that they can be reached, or removing the unreachable catch clauses.
+ problemMessage: "Dead code: Catch clauses after a 'catch (e)' or an 'on Object catch (e)' are never reached."
+ correctionMessage: Try reordering the catch clauses so that they can be reached, or removing the unreachable catch clauses.
hasPublishedDocs: true
comment: |-
Dead code is code that is never reached. This case covers cases where the
@@ -14065,8 +14101,8 @@
}
```
DEAD_CODE_ON_CATCH_SUBTYPE:
- template: "Dead code: This on-catch block won’t be executed because '{0}' is a subtype of '{1}' and hence will have been caught already."
- tip: Try reordering the catch clauses so that this block can be reached, or removing the unreachable catch clause.
+ problemMessage: "Dead code: This on-catch block won’t be executed because '{0}' is a subtype of '{1}' and hence will have been caught already."
+ correctionMessage: Try reordering the catch clauses so that this block can be reached, or removing the unreachable catch clause.
hasPublishedDocs: true
comment: |-
Dead code is code that is never reached. This case covers cases where the
@@ -14123,12 +14159,12 @@
}
```
DEPRECATED_FUNCTION_CLASS_DECLARATION:
- template: "Declaring a class named 'Function' is deprecated."
- tip: Try renaming the class.
+ problemMessage: "Declaring a class named 'Function' is deprecated."
+ correctionMessage: Try renaming the class.
comment: Users should not create a class named `Function` anymore.
DEPRECATED_MEMBER_USE:
- template: "'{0}' is deprecated and shouldn't be used."
- tip: Try replacing the use of the deprecated member with the replacement.
+ problemMessage: "'{0}' is deprecated and shouldn't be used."
+ correctionMessage: Try replacing the use of the deprecated member with the replacement.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -14156,16 +14192,16 @@
should indicate what code to use in place of the deprecated code.
DEPRECATED_MEMBER_USE_WITH_MESSAGE:
sharedName: DEPRECATED_MEMBER_USE
- template: "'{0}' is deprecated and shouldn't be used. {1}."
- tip: Try replacing the use of the deprecated member with the replacement.
+ problemMessage: "'{0}' is deprecated and shouldn't be used. {1}."
+ correctionMessage: Try replacing the use of the deprecated member with the replacement.
hasPublishedDocs: true
comment: |-
Parameters:
0: the name of the member
1: message details
DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE:
- template: "'{0}' is deprecated and shouldn't be used."
- tip: Try replacing the use of the deprecated member with the replacement.
+ problemMessage: "'{0}' is deprecated and shouldn't be used."
+ correctionMessage: Try replacing the use of the deprecated member with the replacement.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -14193,8 +14229,8 @@
in place of the deprecated code.
DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE_WITH_MESSAGE:
sharedName: DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE
- template: "'{0}' is deprecated and shouldn't be used. {1}."
- tip: Try replacing the use of the deprecated member with the replacement.
+ problemMessage: "'{0}' is deprecated and shouldn't be used. {1}."
+ correctionMessage: Try replacing the use of the deprecated member with the replacement.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -14202,20 +14238,20 @@
1: message details
DEPRECATED_MIXIN_FUNCTION:
sharedName: DEPRECATED_SUBTYPE_OF_FUNCTION
- template: "Mixing in 'Function' is deprecated."
- tip: "Try removing 'Function' from the 'with' clause."
+ problemMessage: "Mixing in 'Function' is deprecated."
+ correctionMessage: "Try removing 'Function' from the 'with' clause."
hasPublishedDocs: true
comment: No parameters.
DEPRECATED_IMPLEMENTS_FUNCTION:
sharedName: DEPRECATED_SUBTYPE_OF_FUNCTION
- template: "Implementing 'Function' has no effect."
- tip: "Try removing 'Function' from the 'implements' clause."
+ problemMessage: "Implementing 'Function' has no effect."
+ correctionMessage: "Try removing 'Function' from the 'implements' clause."
hasPublishedDocs: true
comment: No parameters.
DEPRECATED_EXTENDS_FUNCTION:
sharedName: DEPRECATED_SUBTYPE_OF_FUNCTION
- template: "Extending 'Function' is deprecated."
- tip: "Try removing 'Function' from the 'extends' clause."
+ problemMessage: "Extending 'Function' is deprecated."
+ correctionMessage: "Try removing 'Function' from the 'extends' clause."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -14244,12 +14280,12 @@
class F {}
```
DIVISION_OPTIMIZATION:
- template: The operator x ~/ y is more efficient than (x / y).toInt().
- tip: "Try re-writing the expression to use the '~/' operator."
+ problemMessage: The operator x ~/ y is more efficient than (x / y).toInt().
+ correctionMessage: "Try re-writing the expression to use the '~/' operator."
comment: Hint to use the ~/ operator.
DUPLICATE_HIDDEN_NAME:
- template: Duplicate hidden name.
- tip: Try removing the repeated name from the list of hidden members.
+ problemMessage: Duplicate hidden name.
+ correctionMessage: Try removing the repeated name from the list of hidden members.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -14289,8 +14325,8 @@
var x = pi;
```
DUPLICATE_IGNORE:
- template: "The diagnostic '{0}' doesn't need to be ignored here because it's already being ignored."
- tip: Try removing the name from the list, or removing the whole comment if this is the only name in the list.
+ problemMessage: "The diagnostic '{0}' doesn't need to be ignored here because it's already being ignored."
+ correctionMessage: Try removing the name from the list, or removing the whole comment if this is the only name in the list.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -14339,8 +14375,8 @@
}
```
DUPLICATE_IMPORT:
- template: Duplicate import.
- tip: Try removing all but one import of the library.
+ problemMessage: Duplicate import.
+ correctionMessage: Try removing all but one import of the library.
hasPublishedDocs: true
comment: |-
Duplicate imports.
@@ -14374,8 +14410,8 @@
@sealed class C {}
```
DUPLICATE_SHOWN_NAME:
- template: Duplicate shown name.
- tip: Try removing the repeated name from the list of shown members.
+ problemMessage: Duplicate shown name.
+ correctionMessage: Try removing the repeated name from the list of shown members.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -14415,8 +14451,8 @@
var x = min(2, min(0, 1));
```
EQUAL_ELEMENTS_IN_SET:
- template: "Two elements in a set literal shouldn't be equal."
- tip: Change or remove the duplicate element.
+ problemMessage: "Two elements in a set literal shouldn't be equal."
+ correctionMessage: Change or remove the duplicate element.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -14461,8 +14497,8 @@
of which element to remove might affect the order in which elements are
returned by an iterator.
EQUAL_KEYS_IN_MAP:
- template: "Two keys in a map literal shouldn't be equal."
- tip: Change or remove the duplicate key.
+ problemMessage: "Two keys in a map literal shouldn't be equal."
+ correctionMessage: Change or remove the duplicate key.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -14506,8 +14542,8 @@
of which entry to remove might affect the order in which the keys and
values are returned by an iterator.
FILE_IMPORT_INSIDE_LIB_REFERENCES_FILE_OUTSIDE:
- template: "A file in the 'lib' directory shouldn't import a file outside the 'lib' directory."
- tip: "Try removing the import, or moving the imported file inside the 'lib' directory."
+ problemMessage: "A file in the 'lib' directory shouldn't import a file outside the 'lib' directory."
+ correctionMessage: "Try removing the import, or moving the imported file inside the 'lib' directory."
comment: |-
It is a bad practice for a source file in a package "lib" directory
hierarchy to traverse outside that directory hierarchy. For example, a
@@ -14515,8 +14551,8 @@
`import '../web/some.dart'` which references a file outside the lib
directory.
FILE_IMPORT_OUTSIDE_LIB_REFERENCES_FILE_INSIDE:
- template: "A file outside the 'lib' directory shouldn't reference a file inside the 'lib' directory using a relative path."
- tip: "Try using a package: URI instead."
+ problemMessage: "A file outside the 'lib' directory shouldn't reference a file inside the 'lib' directory using a relative path."
+ correctionMessage: "Try using a package: URI instead."
comment: |-
It is a bad practice for a source file ouside a package "lib" directory
hierarchy to traverse into that directory hierarchy. For example, a source
@@ -14524,8 +14560,8 @@
`import '../lib/some.dart'` which references a file inside the lib
directory.
IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION:
- template: "The imported library defines a top-level function named 'loadLibrary' that is hidden by deferring this library."
- tip: Try changing the import to not be deferred, or rename the function in the imported library.
+ problemMessage: "The imported library defines a top-level function named 'loadLibrary' that is hidden by deferring this library."
+ correctionMessage: Try changing the import to not be deferred, or rename the function in the imported library.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -14600,24 +14636,24 @@
If type arguments shouldn't be required for the class, then mark the class
with the `@optionalTypeArgs` annotation (from `package:meta`):
IMPORT_OF_LEGACY_LIBRARY_INTO_NULL_SAFE:
- template: "The library '{0}' is legacy, and should not be imported into a null safe library."
- tip: Try migrating the imported library.
+ problemMessage: "The library '{0}' is legacy, and should not be imported into a null safe library."
+ correctionMessage: Try migrating the imported library.
comment: "https://github.com/dart-lang/sdk/issues/44063"
INFERENCE_FAILURE_ON_COLLECTION_LITERAL:
- template: "The type argument(s) of '{0}' can't be inferred."
- tip: "Use explicit type argument(s) for '{0}'."
+ problemMessage: "The type argument(s) of '{0}' can't be inferred."
+ correctionMessage: "Use explicit type argument(s) for '{0}'."
comment: |-
When "strict-inference" is enabled, collection literal types must be
inferred via the context type, or have type arguments.
INFERENCE_FAILURE_ON_FUNCTION_INVOCATION:
- template: "The type argument(s) of the function '{0}' can't be inferred."
- tip: "Use explicit type argument(s) for '{0}'."
+ problemMessage: "The type argument(s) of the function '{0}' can't be inferred."
+ correctionMessage: "Use explicit type argument(s) for '{0}'."
comment: |-
When "strict-inference" is enabled, types in function invocations must be
inferred via the context type, or have type arguments.
INFERENCE_FAILURE_ON_FUNCTION_RETURN_TYPE:
- template: "The return type of '{0}' cannot be inferred."
- tip: "Declare the return type of '{0}'."
+ problemMessage: "The return type of '{0}' cannot be inferred."
+ correctionMessage: "Declare the return type of '{0}'."
comment: |-
When "strict-inference" is enabled, recursive local functions, top-level
functions, methods, and function-typed function parameters must all
@@ -14625,39 +14661,39 @@
https://github.com/dart-lang/language/blob/master/resources/type-system/strict-inference.md
INFERENCE_FAILURE_ON_GENERIC_INVOCATION:
- template: "The type argument(s) of the generic function type '{0}' can't be inferred."
- tip: "Use explicit type argument(s) for '{0}'."
+ problemMessage: "The type argument(s) of the generic function type '{0}' can't be inferred."
+ correctionMessage: "Use explicit type argument(s) for '{0}'."
comment: |-
When "strict-inference" is enabled, types in function invocations must be
inferred via the context type, or have type arguments.
INFERENCE_FAILURE_ON_INSTANCE_CREATION:
- template: "The type argument(s) of the constructor '{0}' can't be inferred."
- tip: "Use explicit type argument(s) for '{0}'."
+ problemMessage: "The type argument(s) of the constructor '{0}' can't be inferred."
+ correctionMessage: "Use explicit type argument(s) for '{0}'."
comment: |-
When "strict-inference" is enabled, types in instance creation
(constructor calls) must be inferred via the context type, or have type
arguments.
INFERENCE_FAILURE_ON_UNINITIALIZED_VARIABLE:
- template: "The type of {0} can't be inferred without either a type or initializer."
- tip: Try specifying the type of the variable.
+ problemMessage: "The type of {0} can't be inferred without either a type or initializer."
+ correctionMessage: Try specifying the type of the variable.
comment: |-
When "strict-inference" in enabled, uninitialized variables must be
declared with a specific type.
INFERENCE_FAILURE_ON_UNTYPED_PARAMETER:
- template: "The type of {0} can't be inferred; a type must be explicitly provided."
- tip: Try specifying the type of the parameter.
+ problemMessage: "The type of {0} can't be inferred; a type must be explicitly provided."
+ correctionMessage: Try specifying the type of the parameter.
comment: |-
When "strict-inference" in enabled, function parameters must be
declared with a specific type, or inherit a type.
INVALID_ANNOTATION_TARGET:
- template: "The annotation '{0}' can only be used on {1}"
+ problemMessage: "The annotation '{0}' can only be used on {1}"
comment: |-
Parameters:
0: the name of the annotation
1: the list of valid targets
INVALID_EXPORT_OF_INTERNAL_ELEMENT:
- template: "The member '{0}' can't be exported as a part of a package's public API."
- tip: "Try using a hide clause to hide '{0}'."
+ problemMessage: "The member '{0}' can't be exported as a part of a package's public API."
+ correctionMessage: "Try using a hide clause to hide '{0}'."
comment: |-
This hint is generated anywhere where an element annotated with `@internal`
is exported as a part of a package's public API.
@@ -14665,8 +14701,8 @@
Parameters:
0: the name of the element
INVALID_EXPORT_OF_INTERNAL_ELEMENT_INDIRECTLY:
- template: "The member '{0}' can't be exported as a part of a package's public API, but is indirectly exported as part of the signature of '{1}'."
- tip: "Try using a hide clause to hide '{0}'."
+ problemMessage: "The member '{0}' can't be exported as a part of a package's public API, but is indirectly exported as part of the signature of '{1}'."
+ correctionMessage: "Try using a hide clause to hide '{0}'."
comment: |-
This hint is generated anywhere where an element annotated with `@internal`
is exported indirectly as a part of a package's public API.
@@ -14674,17 +14710,17 @@
Parameters:
0: the name of the element
INVALID_FACTORY_ANNOTATION:
- template: Only methods can be annotated as factories.
+ problemMessage: Only methods can be annotated as factories.
comment: |-
This hint is generated anywhere a @factory annotation is associated with
anything other than a method.
INVALID_FACTORY_METHOD_DECL:
- template: "Factory method '{0}' must have a return type."
+ problemMessage: "Factory method '{0}' must have a return type."
comment: |-
This hint is generated anywhere a @factory annotation is associated with
a method that does not declare a return type.
INVALID_FACTORY_METHOD_IMPL:
- template: "Factory method '{0}' doesn't return a newly allocated object."
+ problemMessage: "Factory method '{0}' doesn't return a newly allocated object."
comment: |-
This hint is generated anywhere a @factory annotation is associated with
a non-abstract method that can return anything other than a newly allocated
@@ -14693,23 +14729,23 @@
Parameters:
0: the name of the method
INVALID_IMMUTABLE_ANNOTATION:
- template: Only classes can be annotated as being immutable.
+ problemMessage: Only classes can be annotated as being immutable.
comment: |-
This hint is generated anywhere an @immutable annotation is associated with
anything other than a class.
INVALID_INTERNAL_ANNOTATION:
- template: "Only public elements in a package's private API can be annotated as being internal."
+ problemMessage: "Only public elements in a package's private API can be annotated as being internal."
comment: |-
This hint is generated anywhere a @internal annotation is associated with
an element found in a package's public API.
INVALID_LANGUAGE_VERSION_OVERRIDE_GREATER:
sharedName: INVALID_LANGUAGE_VERSION_OVERRIDE
- template: "The language version override can't specify a version greater than the latest known language version: {0}.{1}"
- tip: Try removing the language version override.
+ problemMessage: "The language version override can't specify a version greater than the latest known language version: {0}.{1}"
+ correctionMessage: Try removing the language version override.
INVALID_LANGUAGE_VERSION_OVERRIDE_AT_SIGN:
sharedName: INVALID_LANGUAGE_VERSION_OVERRIDE
- template: "The Dart language version override number must begin with '@dart'"
- tip: "Specify a Dart language version override with a comment like '// @dart = 2.0'."
+ problemMessage: "The Dart language version override number must begin with '@dart'"
+ correctionMessage: "Specify a Dart language version override with a comment like '// @dart = 2.0'."
comment: |-
Invalid Dart language version comments don't follow the specification [1].
If a comment begins with "@dart" or "dart" (letters in any case),
@@ -14723,12 +14759,12 @@
[1] https://github.com/dart-lang/language/blob/master/accepted/future-releases/language-versioning/feature-specification.md#individual-library-language-version-override
INVALID_LANGUAGE_VERSION_OVERRIDE_LOCATION:
sharedName: INVALID_LANGUAGE_VERSION_OVERRIDE
- template: The language version override must be before any declaration or directive.
- tip: Try moving the language version override to the top of the file.
+ problemMessage: The language version override must be before any declaration or directive.
+ correctionMessage: Try moving the language version override to the top of the file.
INVALID_LANGUAGE_VERSION_OVERRIDE_LOWER_CASE:
sharedName: INVALID_LANGUAGE_VERSION_OVERRIDE
- template: "The Dart language version override comment must be specified with the word 'dart' in all lower case"
- tip: "Specify a Dart language version override with a comment like '// @dart = 2.0'."
+ problemMessage: "The Dart language version override comment must be specified with the word 'dart' in all lower case"
+ correctionMessage: "Specify a Dart language version override with a comment like '// @dart = 2.0'."
comment: |-
Invalid Dart language version comments don't follow the specification [1].
If a comment begins with "@dart" or "dart" (letters in any case),
@@ -14742,8 +14778,8 @@
[1] https://github.com/dart-lang/language/blob/master/accepted/future-releases/language-versioning/feature-specification.md#individual-library-language-version-override
INVALID_LANGUAGE_VERSION_OVERRIDE_NUMBER:
sharedName: INVALID_LANGUAGE_VERSION_OVERRIDE
- template: "The Dart language version override comment must be specified with a version number, like '2.0', after the '=' character."
- tip: "Specify a Dart language version override with a comment like '// @dart = 2.0'."
+ problemMessage: "The Dart language version override comment must be specified with a version number, like '2.0', after the '=' character."
+ correctionMessage: "Specify a Dart language version override with a comment like '// @dart = 2.0'."
comment: |-
Invalid Dart language version comments don't follow the specification [1].
If a comment begins with "@dart" or "dart" (letters in any case),
@@ -14757,8 +14793,8 @@
[1] https://github.com/dart-lang/language/blob/master/accepted/future-releases/language-versioning/feature-specification.md#individual-library-language-version-override
INVALID_LANGUAGE_VERSION_OVERRIDE_PREFIX:
sharedName: INVALID_LANGUAGE_VERSION_OVERRIDE
- template: "The Dart language version override number can't be prefixed with a letter"
- tip: "Specify a Dart language version override with a comment like '// @dart = 2.0'."
+ problemMessage: "The Dart language version override number can't be prefixed with a letter"
+ correctionMessage: "Specify a Dart language version override with a comment like '// @dart = 2.0'."
comment: |-
Invalid Dart language version comments don't follow the specification [1].
If a comment begins with "@dart" or "dart" (letters in any case),
@@ -14772,8 +14808,8 @@
[1] https://github.com/dart-lang/language/blob/master/accepted/future-releases/language-versioning/feature-specification.md#individual-library-language-version-override
INVALID_LANGUAGE_VERSION_OVERRIDE_TRAILING_CHARACTERS:
sharedName: INVALID_LANGUAGE_VERSION_OVERRIDE
- template: "The Dart language version override comment can't be followed by any non-whitespace characters"
- tip: "Specify a Dart language version override with a comment like '// @dart = 2.0'."
+ problemMessage: "The Dart language version override comment can't be followed by any non-whitespace characters"
+ correctionMessage: "Specify a Dart language version override with a comment like '// @dart = 2.0'."
comment: |-
Invalid Dart language version comments don't follow the specification [1].
If a comment begins with "@dart" or "dart" (letters in any case),
@@ -14787,8 +14823,8 @@
[1] https://github.com/dart-lang/language/blob/master/accepted/future-releases/language-versioning/feature-specification.md#individual-library-language-version-override
INVALID_LANGUAGE_VERSION_OVERRIDE_TWO_SLASHES:
sharedName: INVALID_LANGUAGE_VERSION_OVERRIDE
- template: The Dart language version override comment must be specified with exactly two slashes.
- tip: "Specify a Dart language version override with a comment like '// @dart = 2.0'."
+ problemMessage: The Dart language version override comment must be specified with exactly two slashes.
+ correctionMessage: "Specify a Dart language version override with a comment like '// @dart = 2.0'."
comment: |-
Invalid Dart language version comments don't follow the specification [1].
If a comment begins with "@dart" or "dart" (letters in any case),
@@ -14802,8 +14838,8 @@
[1] https://github.com/dart-lang/language/blob/master/accepted/future-releases/language-versioning/feature-specification.md#individual-library-language-version-override
INVALID_LANGUAGE_VERSION_OVERRIDE_EQUALS:
sharedName: INVALID_LANGUAGE_VERSION_OVERRIDE
- template: "The Dart language version override comment must be specified with an '=' character"
- tip: "Specify a Dart language version override with a comment like '// @dart = 2.0'."
+ problemMessage: "The Dart language version override comment must be specified with an '=' character"
+ correctionMessage: "Specify a Dart language version override with a comment like '// @dart = 2.0'."
comment: |-
Invalid Dart language version comments don't follow the specification [1].
If a comment begins with "@dart" or "dart" (letters in any case),
@@ -14816,7 +14852,7 @@
[1] https://github.com/dart-lang/language/blob/master/accepted/future-releases/language-versioning/feature-specification.md#individual-library-language-version-override
INVALID_LITERAL_ANNOTATION:
- template: Only const constructors can have the `@literal` annotation.
+ problemMessage: Only const constructors can have the `@literal` annotation.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -14873,8 +14909,8 @@
var x;
```
INVALID_NON_VIRTUAL_ANNOTATION:
- template: "The member '{0}' can't be '@nonVirtual' because it isn't a concrete instance member."
- tip: Try removing @nonVirtual.
+ problemMessage: "The member '{0}' can't be '@nonVirtual' because it isn't a concrete instance member."
+ correctionMessage: Try removing @nonVirtual.
comment: |-
This hint is generated anywhere where `@nonVirtual` annotates something
other than a non-abstract instance member in a class or mixin.
@@ -14882,7 +14918,7 @@
Parameters:
0: the name of the member
INVALID_OVERRIDE_OF_NON_VIRTUAL_MEMBER:
- template: "The member '{0}' is declared non-virtual in '{1}' and can't be overridden in subclasses."
+ problemMessage: "The member '{0}' is declared non-virtual in '{1}' and can't be overridden in subclasses."
comment: |-
This hint is generated anywhere where an instance member annotated with
`@nonVirtual` is overridden in a subclass.
@@ -14891,8 +14927,8 @@
0: the name of the member
1: the name of the defining class
INVALID_REQUIRED_NAMED_PARAM:
- template: "The type parameter '{0}' is annotated with @required but only named parameters without a default value can be annotated with it."
- tip: Remove @required.
+ problemMessage: "The type parameter '{0}' is annotated with @required but only named parameters without a default value can be annotated with it."
+ correctionMessage: Remove @required.
comment: |-
This hint is generated anywhere where `@required` annotates a named
parameter with a default value.
@@ -14900,8 +14936,8 @@
Parameters:
0: the name of the member
INVALID_REQUIRED_OPTIONAL_POSITIONAL_PARAM:
- template: "Incorrect use of the annotation @required on the optional positional parameter '{0}'. Optional positional parameters cannot be required."
- tip: Remove @required.
+ problemMessage: "Incorrect use of the annotation @required on the optional positional parameter '{0}'. Optional positional parameters cannot be required."
+ correctionMessage: Remove @required.
comment: |-
This hint is generated anywhere where `@required` annotates an optional
positional parameter.
@@ -14909,8 +14945,8 @@
Parameters:
0: the name of the member
INVALID_REQUIRED_POSITIONAL_PARAM:
- template: "Redundant use of the annotation @required on the required positional parameter '{0}'."
- tip: Remove @required.
+ problemMessage: "Redundant use of the annotation @required on the required positional parameter '{0}'."
+ correctionMessage: Remove @required.
comment: |-
This hint is generated anywhere where `@required` annotates a non optional
positional parameter.
@@ -14919,7 +14955,7 @@
0: the name of the member
RETURN_TYPE_INVALID_FOR_CATCH_ERROR:
sharedName: INVALID_RETURN_TYPE_FOR_CATCH_ERROR
- template: "The return type '{0}' isn't assignable to '{1}', as required by 'Future.catchError'."
+ problemMessage: "The return type '{0}' isn't assignable to '{1}', as required by 'Future.catchError'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -14927,7 +14963,7 @@
1: the expected return type as defined by the type of the Future
RETURN_OF_INVALID_TYPE_FROM_CATCH_ERROR:
sharedName: INVALID_RETURN_TYPE_FOR_CATCH_ERROR
- template: "A value of type '{0}' can't be returned by the 'onError' handler because it must be assignable to '{1}'."
+ problemMessage: "A value of type '{0}' can't be returned by the 'onError' handler because it must be assignable to '{1}'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -14984,8 +15020,8 @@
}
```
INVALID_SEALED_ANNOTATION:
- template: "The member '{0}' is annotated with '@sealed' but only classes can be annotated with it."
- tip: Remove @sealed.
+ problemMessage: "The member '{0}' is annotated with '@sealed' but only classes can be annotated with it."
+ correctionMessage: Remove @sealed.
comment: |-
This hint is generated anywhere where `@sealed` annotates something other
than a class.
@@ -14993,7 +15029,7 @@
Parameters:
0: the name of the member
INVALID_USE_OF_INTERNAL_MEMBER:
- template: "The member '{0}' can only be used within its package."
+ problemMessage: "The member '{0}' can only be used within its package."
comment: |-
This hint is generated anywhere where a member annotated with `@internal`
is used outside of the package in which it is declared.
@@ -15001,7 +15037,7 @@
Parameters:
0: the name of the member
INVALID_USE_OF_PROTECTED_MEMBER:
- template: "The member '{0}' can only be used within instance members of subclasses of '{1}'."
+ problemMessage: "The member '{0}' can only be used within instance members of subclasses of '{1}'."
comment: |-
This hint is generated anywhere where a member annotated with `@protected`
is used outside of an instance member of a subclass.
@@ -15010,7 +15046,7 @@
0: the name of the member
1: the name of the defining class
INVALID_USE_OF_VISIBLE_FOR_OVERRIDING_MEMBER:
- template: "The member '{0}' can only be used for overriding."
+ problemMessage: "The member '{0}' can only be used for overriding."
comment: |-
Parameters:
0: the name of the member
@@ -15053,7 +15089,7 @@
Remove the invalid use of the member.
INVALID_USE_OF_VISIBLE_FOR_TEMPLATE_MEMBER:
- template: "The member '{0}' can only be used within '{1}' or a template library."
+ problemMessage: "The member '{0}' can only be used within '{1}' or a template library."
comment: |-
This hint is generated anywhere where a member annotated with
`@visibleForTemplate` is used outside of a "template" Dart file.
@@ -15062,7 +15098,7 @@
0: the name of the member
1: the name of the defining class
INVALID_USE_OF_VISIBLE_FOR_TESTING_MEMBER:
- template: "The member '{0}' can only be used within '{1}' or a test."
+ problemMessage: "The member '{0}' can only be used within '{1}' or a test."
comment: |-
This hint is generated anywhere where a member annotated with
`@visibleForTesting` is used outside the defining library, or a test.
@@ -15071,7 +15107,7 @@
0: the name of the member
1: the name of the defining class
INVALID_VISIBILITY_ANNOTATION:
- template: "The member '{0}' is annotated with '{1}', but this annotation is only meaningful on declarations of public members."
+ problemMessage: "The member '{0}' is annotated with '{1}', but this annotation is only meaningful on declarations of public members."
hasPublishedDocs: true
comment: |-
This hint is generated anywhere where a private declaration is annotated
@@ -15121,7 +15157,7 @@
void f() => someFunction();
```
INVALID_VISIBLE_FOR_OVERRIDING_ANNOTATION:
- template: "The declaration '{0}' is annotated with 'visibleForOverriding'. Because '{0}' isn't an interface member that could be overridden, the annotation is meaningless."
+ problemMessage: "The declaration '{0}' is annotated with 'visibleForOverriding'. Because '{0}' isn't an interface member that could be overridden, the annotation is meaningless."
comment: No parameters.
documentation: |-
#### Description
@@ -15151,13 +15187,13 @@
class C {}
```
MISSING_JS_LIB_ANNOTATION:
- template: The @JS() annotation can only be used if it is also declared on the library directive.
- tip: Try adding the annotation to the library directive.
+ problemMessage: The @JS() annotation can only be used if it is also declared on the library directive.
+ correctionMessage: Try adding the annotation to the library directive.
comment: |-
Generate a hint for an element that is annotated with `@JS(...)` whose
library declaration is not similarly annotated.
MISSING_REQUIRED_PARAM:
- template: "The parameter '{0}' is required."
+ problemMessage: "The parameter '{0}' is required."
hasPublishedDocs: true
comment: |-
Generate a hint for a constructor, function or method invocation where a
@@ -15204,7 +15240,7 @@
```
MISSING_REQUIRED_PARAM_WITH_DETAILS:
sharedName: MISSING_REQUIRED_PARAM
- template: "The parameter '{0}' is required. {1}."
+ problemMessage: "The parameter '{0}' is required. {1}."
hasPublishedDocs: true
comment: |-
Generate a hint for a constructor, function or method invocation where a
@@ -15214,8 +15250,8 @@
0: the name of the parameter
1: message details
MISSING_RETURN:
- template: "This function has a return type of '{0}', but doesn't end with a return statement."
- tip: "Try adding a return statement, or changing the return type to 'void'."
+ problemMessage: "This function has a return type of '{0}', but doesn't end with a return statement."
+ correctionMessage: "Try adding a return statement, or changing the return type to 'void'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -15246,8 +15282,8 @@
Add a `return` statement that makes the return value explicit, even if
`null` is the appropriate value.
MIXIN_ON_SEALED_CLASS:
- template: "The class '{0}' shouldn't be used as a mixin constraint because it is sealed, and any class mixing in this mixin must have '{0}' as a superclass."
- tip: Try composing with this class, or refer to its documentation for more information.
+ problemMessage: "The class '{0}' shouldn't be used as a mixin constraint because it is sealed, and any class mixing in this mixin must have '{0}' as a superclass."
+ correctionMessage: Try composing with this class, or refer to its documentation for more information.
hasPublishedDocs: true
comment: |-
This hint is generated anywhere where a `@sealed` class is used as a
@@ -15290,7 +15326,7 @@
class, then consider adding a field and delegating to the wrapped instance
of the sealed class.
MUST_BE_IMMUTABLE:
- template: "This class (or a class that this class inherits from) is marked as '@immutable', but one or more of its instance fields aren't final: {0}"
+ problemMessage: "This class (or a class that this class inherits from) is marked as '@immutable', but one or more of its instance fields aren't final: {0}"
hasPublishedDocs: true
comment: |-
Generate a hint for classes that inherit from classes annotated with
@@ -15347,7 +15383,7 @@
}
```
MUST_CALL_SUPER:
- template: "This method overrides a method annotated as '@mustCallSuper' in '{0}', but doesn't invoke the overridden method."
+ problemMessage: "This method overrides a method annotated as '@mustCallSuper' in '{0}', but doesn't invoke the overridden method."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -15399,8 +15435,8 @@
```
NON_CONST_CALL_TO_LITERAL_CONSTRUCTOR_USING_NEW:
sharedName: NON_CONST_CALL_TO_LITERAL_CONSTRUCTOR
- template: "This instance creation must be 'const', because the {0} constructor is marked as '@literal'."
- tip: "Try replacing the 'new' keyword with 'const'."
+ problemMessage: "This instance creation must be 'const', because the {0} constructor is marked as '@literal'."
+ correctionMessage: "Try replacing the 'new' keyword with 'const'."
hasPublishedDocs: true
comment: |-
Generate a hint for non-const instance creation (with the `new` keyword)
@@ -15409,8 +15445,8 @@
Parameters:
0: the name of the class defining the annotated constructor
NON_CONST_CALL_TO_LITERAL_CONSTRUCTOR:
- template: "This instance creation must be 'const', because the {0} constructor is marked as '@literal'."
- tip: "Try adding a 'const' keyword."
+ problemMessage: "This instance creation must be 'const', because the {0} constructor is marked as '@literal'."
+ correctionMessage: "Try adding a 'const' keyword."
hasPublishedDocs: true
comment: |-
Generate a hint for non-const instance creation using a constructor
@@ -15457,8 +15493,8 @@
void f() => const C();
```
NULLABLE_TYPE_IN_CATCH_CLAUSE:
- template: "A potentially nullable type can't be used in an 'on' clause because it isn't valid to throw a nullable expression."
- tip: Try using a non-nullable type.
+ problemMessage: "A potentially nullable type can't be used in an 'on' clause because it isn't valid to throw a nullable expression."
+ correctionMessage: Try using a non-nullable type.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -15496,8 +15532,8 @@
}
```
NULL_ARGUMENT_TO_NON_NULL_TYPE:
- template: "'{0}' shouldn't be called with a null argument for the non-nullable type argument '{1}'."
- tip: Try adding a non-null argument.
+ problemMessage: "'{0}' shouldn't be called with a null argument for the non-nullable type argument '{1}'."
+ correctionMessage: Try adding a non-null argument.
comment: |-
Parameters:
0: the name of the method being invoked
@@ -15533,30 +15569,30 @@
}
```
NULL_AWARE_BEFORE_OPERATOR:
- template: "The left operand uses '?.', so its value can be null."
+ problemMessage: "The left operand uses '?.', so its value can be null."
comment: |-
When the left operand of a binary expression uses '?.' operator, it can be
`null`.
NULL_AWARE_IN_CONDITION:
- template: "The value of the '?.' operator can be 'null', which isn't appropriate in a condition."
- tip: "Try replacing the '?.' with a '.', testing the left-hand side for null if necessary."
+ problemMessage: "The value of the '?.' operator can be 'null', which isn't appropriate in a condition."
+ correctionMessage: "Try replacing the '?.' with a '.', testing the left-hand side for null if necessary."
comment: |-
A condition in a control flow statement could evaluate to `null` because it
uses the null-aware '?.' operator.
NULL_AWARE_IN_LOGICAL_OPERATOR:
- template: "The value of the '?.' operator can be 'null', which isn't appropriate as an operand of a logical operator."
+ problemMessage: "The value of the '?.' operator can be 'null', which isn't appropriate as an operand of a logical operator."
comment: |-
A condition in operands of a logical operator could evaluate to `null`
because it uses the null-aware '?.' operator.
NULL_CHECK_ALWAYS_FAILS:
- template: "This null-check will always throw an exception because the expression will always evaluate to 'null'."
+ problemMessage: "This null-check will always throw an exception because the expression will always evaluate to 'null'."
comment: |-
This hint indicates that a null literal is null-checked with `!`, but null
is never not null.
OVERRIDE_ON_NON_OVERRIDING_FIELD:
sharedName: OVERRIDE_ON_NON_OVERRIDING_MEMBER
- template: "The field doesn't override an inherited getter or setter."
- tip: Try updating this class to match the superclass, or removing the override annotation.
+ problemMessage: "The field doesn't override an inherited getter or setter."
+ correctionMessage: Try updating this class to match the superclass, or removing the override annotation.
hasPublishedDocs: true
comment: |-
A field with the override annotation does not override a getter or setter.
@@ -15564,8 +15600,8 @@
No parameters.
OVERRIDE_ON_NON_OVERRIDING_GETTER:
sharedName: OVERRIDE_ON_NON_OVERRIDING_MEMBER
- template: "The getter doesn't override an inherited getter."
- tip: Try updating this class to match the superclass, or removing the override annotation.
+ problemMessage: "The getter doesn't override an inherited getter."
+ correctionMessage: Try updating this class to match the superclass, or removing the override annotation.
hasPublishedDocs: true
comment: |-
A getter with the override annotation does not override an existing getter.
@@ -15573,8 +15609,8 @@
No parameters.
OVERRIDE_ON_NON_OVERRIDING_METHOD:
sharedName: OVERRIDE_ON_NON_OVERRIDING_MEMBER
- template: "The method doesn't override an inherited method."
- tip: Try updating this class to match the superclass, or removing the override annotation.
+ problemMessage: "The method doesn't override an inherited method."
+ correctionMessage: Try updating this class to match the superclass, or removing the override annotation.
hasPublishedDocs: true
comment: |-
A method with the override annotation does not override an existing method.
@@ -15617,23 +15653,23 @@
If the member can't be removed, then remove the annotation.
OVERRIDE_ON_NON_OVERRIDING_SETTER:
sharedName: OVERRIDE_ON_NON_OVERRIDING_MEMBER
- template: "The setter doesn't override an inherited setter."
- tip: Try updating this class to match the superclass, or removing the override annotation.
+ problemMessage: "The setter doesn't override an inherited setter."
+ correctionMessage: Try updating this class to match the superclass, or removing the override annotation.
hasPublishedDocs: true
comment: |-
A setter with the override annotation does not override an existing setter.
No parameters.
PACKAGE_IMPORT_CONTAINS_DOT_DOT:
- template: "A package import shouldn't contain '..'."
+ problemMessage: "A package import shouldn't contain '..'."
comment: |-
It is a bad practice for a package import to reference anything outside the
given package, or more generally, it is bad practice for a package import
to contain a "..". For example, a source file should not contain a
directive such as `import 'package:foo/../some.dart'`.
RECEIVER_OF_TYPE_NEVER:
- template: "The receiver is of type 'Never', and will never complete with a value."
- tip: Try checking for throw expressions or type errors in the receiver
+ problemMessage: "The receiver is of type 'Never', and will never complete with a value."
+ correctionMessage: Try checking for throw expressions or type errors in the receiver
comment: |-
It is not an error to call or tear-off a method, setter, or getter, or to
read or write a field, on a receiver of static type `Never`.
@@ -15648,14 +15684,14 @@
Parameters: none
RETURN_OF_DO_NOT_STORE:
- template: "'{0}' is annotated with 'doNotStore' and shouldn't be returned unless '{1}' is also annotated."
- tip: "Annotate '{1}' with 'doNotStore'."
+ problemMessage: "'{0}' is annotated with 'doNotStore' and shouldn't be returned unless '{1}' is also annotated."
+ correctionMessage: "Annotate '{1}' with 'doNotStore'."
comment: |-
Users should not return values marked `@doNotStore` from functions,
methods or getters not marked `@doNotStore`.
SDK_VERSION_ASYNC_EXPORTED_FROM_CORE:
- template: "The class '{0}' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions."
- tip: "Try either importing 'dart:async' or updating the SDK constraints."
+ problemMessage: "The class '{0}' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions."
+ correctionMessage: "Try either importing 'dart:async' or updating the SDK constraints."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -15704,8 +15740,8 @@
void f(Future f) {}
```
SDK_VERSION_AS_EXPRESSION_IN_CONST_CONTEXT:
- template: "The use of an as expression in a constant expression wasn't supported until version 2.3.2, but this code is required to be able to run on earlier versions."
- tip: Try updating the SDK constraints.
+ problemMessage: "The use of an as expression in a constant expression wasn't supported until version 2.3.2, but this code is required to be able to run on earlier versions."
+ correctionMessage: Try updating the SDK constraints.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -15755,8 +15791,8 @@
int y = x as int;
```
SDK_VERSION_BOOL_OPERATOR_IN_CONST_CONTEXT:
- template: "The use of the operator '{0}' for 'bool' operands in a constant context wasn't supported until version 2.3.2, but this code is required to be able to run on earlier versions."
- tip: Try updating the SDK constraints.
+ problemMessage: "The use of the operator '{0}' for 'bool' operands in a constant context wasn't supported until version 2.3.2, but this code is required to be able to run on earlier versions."
+ correctionMessage: Try updating the SDK constraints.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -15809,8 +15845,8 @@
bool c = a & b;
```
SDK_VERSION_CONSTRUCTOR_TEAROFFS:
- template: "Tearing off a constructor requires the 'constructor-tearoffs' language feature."
- tip: "Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'."
+ problemMessage: "Tearing off a constructor requires the 'constructor-tearoffs' language feature."
+ correctionMessage: "Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'."
comment: |-
No parameters.
@@ -15863,8 +15899,8 @@
var setConstructor = () => Set.identity();
```
SDK_VERSION_EQ_EQ_OPERATOR_IN_CONST_CONTEXT:
- template: "Using the operator '==' for non-primitive types wasn't supported until version 2.3.2, but this code is required to be able to run on earlier versions."
- tip: Try updating the SDK constraints.
+ problemMessage: "Using the operator '==' for non-primitive types wasn't supported until version 2.3.2, but this code is required to be able to run on earlier versions."
+ correctionMessage: Try updating the SDK constraints.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -15920,8 +15956,8 @@
bool same = a == b;
```
SDK_VERSION_EXTENSION_METHODS:
- template: "Extension methods weren't supported until version 2.6.0, but this code is required to be able to run on earlier versions."
- tip: Try updating the SDK constraints.
+ problemMessage: "Extension methods weren't supported until version 2.6.0, but this code is required to be able to run on earlier versions."
+ correctionMessage: Try updating the SDK constraints.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -15976,8 +16012,8 @@
}
```
SDK_VERSION_GT_GT_GT_OPERATOR:
- template: "The operator '>>>' wasn't supported until version 2.14.0, but this code is required to be able to run on earlier versions."
- tip: Try updating the SDK constraints.
+ problemMessage: "The operator '>>>' wasn't supported until version 2.14.0, but this code is required to be able to run on earlier versions."
+ correctionMessage: Try updating the SDK constraints.
comment: No parameters.
documentation: |-
#### Description
@@ -16030,8 +16066,8 @@
}
```
SDK_VERSION_IS_EXPRESSION_IN_CONST_CONTEXT:
- template: "The use of an is expression in a constant context wasn't supported until version 2.3.2, but this code is required to be able to run on earlier versions."
- tip: Try updating the SDK constraints.
+ problemMessage: "The use of an is expression in a constant context wasn't supported until version 2.3.2, but this code is required to be able to run on earlier versions."
+ correctionMessage: Try updating the SDK constraints.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -16082,8 +16118,8 @@
var y = x is int ? 0 : 1;
```
SDK_VERSION_NEVER:
- template: "The type 'Never' wasn't supported until version 2.12.0, but this code is required to be able to run on earlier versions."
- tip: Try updating the SDK constraints.
+ problemMessage: "The type 'Never' wasn't supported until version 2.12.0, but this code is required to be able to run on earlier versions."
+ correctionMessage: Try updating the SDK constraints.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -16130,8 +16166,8 @@
dynamic x;
```
SDK_VERSION_SET_LITERAL:
- template: "Set literals weren't supported until version 2.2, but this code is required to be able to run on earlier versions."
- tip: Try updating the SDK constraints.
+ problemMessage: "Set literals weren't supported until version 2.2, but this code is required to be able to run on earlier versions."
+ correctionMessage: Try updating the SDK constraints.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -16177,8 +16213,8 @@
var s = new Set<int>();
```
SDK_VERSION_UI_AS_CODE:
- template: "The for, if, and spread elements weren't supported until version 2.3.0, but this code is required to be able to run on earlier versions."
- tip: Try updating the SDK constraints.
+ problemMessage: "The for, if, and spread elements weren't supported until version 2.3.0, but this code is required to be able to run on earlier versions."
+ correctionMessage: Try updating the SDK constraints.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -16233,8 +16269,8 @@
}
```
SDK_VERSION_UI_AS_CODE_IN_CONST_CONTEXT:
- template: "The if and spread elements weren't supported in constant expressions until version 2.5.0, but this code is required to be able to run on earlier versions."
- tip: Try updating the SDK constraints.
+ problemMessage: "The if and spread elements weren't supported in constant expressions until version 2.5.0, but this code is required to be able to run on earlier versions."
+ correctionMessage: Try updating the SDK constraints.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -16291,16 +16327,16 @@
var b = [...a];
```
STRICT_RAW_TYPE:
- template: "The generic type '{0}' should have explicit type arguments but doesn't."
- tip: "Use explicit type arguments for '{0}'."
+ problemMessage: "The generic type '{0}' should have explicit type arguments but doesn't."
+ correctionMessage: "Use explicit type arguments for '{0}'."
comment: |-
When "strict-raw-types" is enabled, "raw types" must have type arguments.
A "raw type" is a type name that does not use inference to fill in missing
type arguments; instead, each type argument is instantiated to its bound.
SUBTYPE_OF_SEALED_CLASS:
- template: "The class '{0}' shouldn't be extended, mixed in, or implemented because it's sealed."
- tip: "Try composing instead of inheriting, or refer to the documentation of '{0}' for more information."
+ problemMessage: "The class '{0}' shouldn't be extended, mixed in, or implemented because it's sealed."
+ correctionMessage: "Try composing instead of inheriting, or refer to the documentation of '{0}' for more information."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -16354,8 +16390,8 @@
the same package as the sealed class.
TYPE_CHECK_IS_NOT_NULL:
sharedName: TYPE_CHECK_WITH_NULL
- template: "Tests for non-null should be done with '!= null'."
- tip: "Try replacing the 'is! Null' check with '!= null'."
+ problemMessage: "Tests for non-null should be done with '!= null'."
+ correctionMessage: "Try replacing the 'is! Null' check with '!= null'."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -16406,13 +16442,13 @@
```
TYPE_CHECK_IS_NULL:
sharedName: TYPE_CHECK_WITH_NULL
- template: "Tests for null should be done with '== null'."
- tip: "Try replacing the 'is Null' check with '== null'."
+ problemMessage: "Tests for null should be done with '== null'."
+ correctionMessage: "Try replacing the 'is Null' check with '== null'."
hasPublishedDocs: true
comment: No parameters.
UNDEFINED_HIDDEN_NAME:
- template: "The library '{0}' doesn't export a member with the hidden name '{1}'."
- tip: Try removing the name from the list of hidden members.
+ problemMessage: "The library '{0}' doesn't export a member with the hidden name '{1}'."
+ correctionMessage: Try removing the name from the list of hidden members.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -16446,7 +16482,7 @@
var x = min(0, 1);
```
UNDEFINED_REFERENCED_PARAMETER:
- template: "The parameter '{0}' is not defined by '{1}'."
+ problemMessage: "The parameter '{0}' is not defined by '{1}'."
comment: |-
Parameters:
0: the name of the undefined parameter
@@ -16482,8 +16518,8 @@
int f([int? a]) => a ?? 0;
```
UNDEFINED_SHOWN_NAME:
- template: "The library '{0}' doesn't export a member with the shown name '{1}'."
- tip: Try removing the name from the list of shown members.
+ problemMessage: "The library '{0}' doesn't export a member with the shown name '{1}'."
+ correctionMessage: Try removing the name from the list of shown members.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -16517,14 +16553,14 @@
var x = min(0, 1);
```
UNIGNORABLE_IGNORE:
- template: "The diagnostic '{0}' can't be ignored."
- tip: Try removing the name from the list, or removing the whole comment if this is the only name in the list.
+ problemMessage: "The diagnostic '{0}' can't be ignored."
+ correctionMessage: Try removing the name from the list, or removing the whole comment if this is the only name in the list.
comment: |-
Parameters:
0: the name of the non-diagnostic being ignored
UNNECESSARY_CAST:
- template: Unnecessary cast.
- tip: Try removing the cast.
+ problemMessage: Unnecessary cast.
+ correctionMessage: Try removing the cast.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -16558,14 +16594,14 @@
}
```
UNNECESSARY_IGNORE:
- template: "The diagnostic '{0}' isn't produced at this location so it doesn't need to be ignored."
- tip: Try removing the name from the list, or removing the whole comment if this is the only name in the list.
+ problemMessage: "The diagnostic '{0}' isn't produced at this location so it doesn't need to be ignored."
+ correctionMessage: Try removing the name from the list, or removing the whole comment if this is the only name in the list.
comment: |-
Parameters:
0: the name of the diagnostic being ignored
UNNECESSARY_IMPORT:
- template: "The import of '{0}' is unnecessary because all of the used elements are also provided by the import of '{1}'."
- tip: Try removing the import directive.
+ problemMessage: "The import of '{0}' is unnecessary because all of the used elements are also provided by the import of '{1}'."
+ correctionMessage: Try removing the import directive.
comment: |-
Parameters:
0: the uri that is not necessary
@@ -16614,8 +16650,8 @@
aren't yet, and if those names aren't imported by other imports, then add
the missing references to those names.
UNNECESSARY_NO_SUCH_METHOD:
- template: "Unnecessary 'noSuchMethod' declaration."
- tip: "Try removing the declaration of 'noSuchMethod'."
+ problemMessage: "Unnecessary 'noSuchMethod' declaration."
+ correctionMessage: "Try removing the declaration of 'noSuchMethod'."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -16664,8 +16700,8 @@
```
UNNECESSARY_NULL_COMPARISON_FALSE:
sharedName: UNNECESSARY_NULL_COMPARISON
- template: "The operand can't be null, so the condition is always false."
- tip: Try removing the condition, an enclosing condition, or the whole conditional statement.
+ problemMessage: "The operand can't be null, so the condition is always false."
+ correctionMessage: Try removing the condition, an enclosing condition, or the whole conditional statement.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -16722,12 +16758,12 @@
```
UNNECESSARY_NULL_COMPARISON_TRUE:
sharedName: UNNECESSARY_NULL_COMPARISON
- template: "The operand can't be null, so the condition is always true."
- tip: Remove the condition.
+ problemMessage: "The operand can't be null, so the condition is always true."
+ correctionMessage: Remove the condition.
hasPublishedDocs: true
comment: No parameters.
UNNECESSARY_QUESTION_MARK:
- template: "The '?' is unnecessary because '{0}' is nullable without it."
+ problemMessage: "The '?' is unnecessary because '{0}' is nullable without it."
comment: |-
Parameters:
0: the name of the type
@@ -16756,8 +16792,8 @@
```
UNNECESSARY_TYPE_CHECK_FALSE:
sharedName: UNNECESSARY_TYPE_CHECK
- template: "Unnecessary type check; the result is always 'false'."
- tip: Try correcting the type check, or removing the type check.
+ problemMessage: "Unnecessary type check; the result is always 'false'."
+ correctionMessage: Try correcting the type check, or removing the type check.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -16792,13 +16828,13 @@
```
UNNECESSARY_TYPE_CHECK_TRUE:
sharedName: UNNECESSARY_TYPE_CHECK
- template: "Unnecessary type check; the result is always 'true'."
- tip: Try correcting the type check, or removing the type check.
+ problemMessage: "Unnecessary type check; the result is always 'true'."
+ correctionMessage: Try correcting the type check, or removing the type check.
hasPublishedDocs: true
comment: No parameters.
UNUSED_CATCH_CLAUSE:
- template: "The exception variable '{0}' isn't used, so the 'catch' clause can be removed."
- tip: Try removing the catch clause.
+ problemMessage: "The exception variable '{0}' isn't used, so the 'catch' clause can be removed."
+ correctionMessage: Try removing the catch clause.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -16838,8 +16874,8 @@
}
```
UNUSED_CATCH_STACK:
- template: "The stack trace variable '{0}' isn't used and can be removed."
- tip: Try removing the stack trace variable, or using it.
+ problemMessage: "The stack trace variable '{0}' isn't used and can be removed."
+ correctionMessage: Try removing the stack trace variable, or using it.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -16880,8 +16916,8 @@
}
```
UNUSED_ELEMENT:
- template: "The declaration '{0}' isn't referenced."
- tip: "Try removing the declaration of '{0}'."
+ problemMessage: "The declaration '{0}' isn't referenced."
+ correctionMessage: "Try removing the declaration of '{0}'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -16934,15 +16970,15 @@
If the declaration is intended to be used, then add the code to use it.
UNUSED_ELEMENT_PARAMETER:
sharedName: UNUSED_ELEMENT
- template: "A value for optional parameter '{0}' isn't ever given."
- tip: Try removing the unused parameter.
+ problemMessage: "A value for optional parameter '{0}' isn't ever given."
+ correctionMessage: Try removing the unused parameter.
hasPublishedDocs: true
comment: |-
Parameters:
0: the name of the parameter that is declared but not used
UNUSED_FIELD:
- template: "The value of the field '{0}' isn't used."
- tip: Try removing the field, or using it.
+ problemMessage: "The value of the field '{0}' isn't used."
+ correctionMessage: Try removing the field, or using it.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -16979,8 +17015,8 @@
If the field was intended to be used, then add the missing code.
UNUSED_IMPORT:
- template: "Unused import: '{0}'."
- tip: Try removing the import directive.
+ problemMessage: "Unused import: '{0}'."
+ correctionMessage: Try removing the import directive.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -17010,8 +17046,8 @@
If some of the imported names are intended to be used, then add the missing
code.
UNUSED_LABEL:
- template: "The label '{0}' isn't used."
- tip: "Try removing the label, or using it in either a 'break' or 'continue' statement."
+ problemMessage: "The label '{0}' isn't used."
+ correctionMessage: "Try removing the label, or using it in either a 'break' or 'continue' statement."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -17059,8 +17095,8 @@
```
TODO(brianwilkerson) Highlight the identifier without the colon.
UNUSED_LOCAL_VARIABLE:
- template: "The value of the local variable '{0}' isn't used."
- tip: Try removing the variable or using it.
+ problemMessage: "The value of the local variable '{0}' isn't used."
+ correctionMessage: Try removing the variable or using it.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -17088,8 +17124,8 @@
If the variable was intended to be used, then add the missing code.
UNUSED_RESULT:
- template: "The value of '{0}' should be used."
- tip: Try using the result by invoking a member, passing it to a function, or returning it from this function.
+ problemMessage: "The value of '{0}' should be used."
+ correctionMessage: Try using the result by invoking a member, passing it to a function, or returning it from this function.
comment: |-
Parameters:
0: the name of the annotated method, property or function
@@ -17162,8 +17198,8 @@
```
UNUSED_RESULT_WITH_MESSAGE:
sharedName: UNUSED_RESULT
- template: "'{0}' should be used. {1}."
- tip: Try using the result by invoking a member, passing it to a function, or returning it from this function.
+ problemMessage: "'{0}' should be used. {1}."
+ correctionMessage: Try using the result by invoking a member, passing it to a function, or returning it from this function.
comment: |-
The result of invoking a method, property, or function annotated with
`@useResult` must be used (assigned, passed to a function as an argument,
@@ -17173,8 +17209,8 @@
0: the name of the annotated method, property or function
1: message details
UNUSED_SHOWN_NAME:
- template: "The name {0} is shown, but isn’t used."
- tip: Try removing the name from the list of shown members.
+ problemMessage: "The name {0} is shown, but isn’t used."
+ correctionMessage: Try removing the name from the list of shown members.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -17207,8 +17243,8 @@
var x = min(0, 1);
```
USE_OF_NATIVE_EXTENSION:
- template: Dart native extensions are deprecated and aren’t available in Dart 2.15.
- tip: "Try using dart:ffi for C interop."
+ problemMessage: Dart native extensions are deprecated and aren’t available in Dart 2.15.
+ correctionMessage: "Try using dart:ffi for C interop."
comment: No parameters.
documentation: |-
#### Description
@@ -17232,69 +17268,69 @@
native library.
LanguageCode:
IMPLICIT_DYNAMIC_FIELD:
- template: "Missing field type for '{0}'."
- tip: Try adding an explicit type, or remove implicit-dynamic from your analysis options file.
+ problemMessage: "Missing field type for '{0}'."
+ correctionMessage: Try adding an explicit type, or remove implicit-dynamic from your analysis options file.
IMPLICIT_DYNAMIC_FUNCTION:
- template: "Missing type arguments for generic function '{0}<{1}>'."
- tip: Try adding an explicit type, or remove implicit-dynamic from your analysis options file.
+ problemMessage: "Missing type arguments for generic function '{0}<{1}>'."
+ correctionMessage: Try adding an explicit type, or remove implicit-dynamic from your analysis options file.
IMPLICIT_DYNAMIC_INVOKE:
- template: "Missing type arguments for calling generic function type '{0}'."
- tip: Try adding an explicit type, or remove implicit-dynamic from your analysis options file.
+ problemMessage: "Missing type arguments for calling generic function type '{0}'."
+ correctionMessage: Try adding an explicit type, or remove implicit-dynamic from your analysis options file.
IMPLICIT_DYNAMIC_LIST_LITERAL:
- template: Missing type argument for list literal.
- tip: Try adding an explicit type, or remove implicit-dynamic from your analysis options file.
+ problemMessage: Missing type argument for list literal.
+ correctionMessage: Try adding an explicit type, or remove implicit-dynamic from your analysis options file.
IMPLICIT_DYNAMIC_MAP_LITERAL:
- template: Missing type arguments for map literal.
- tip: Try adding an explicit type, or remove implicit-dynamic from your analysis options file.
+ problemMessage: Missing type arguments for map literal.
+ correctionMessage: Try adding an explicit type, or remove implicit-dynamic from your analysis options file.
IMPLICIT_DYNAMIC_METHOD:
- template: "Missing type arguments for generic method '{0}<{1}>'."
- tip: Try adding an explicit type, or remove implicit-dynamic from your analysis options file.
+ problemMessage: "Missing type arguments for generic method '{0}<{1}>'."
+ correctionMessage: Try adding an explicit type, or remove implicit-dynamic from your analysis options file.
IMPLICIT_DYNAMIC_PARAMETER:
- template: "Missing parameter type for '{0}'."
- tip: Try adding an explicit type, or remove implicit-dynamic from your analysis options file.
+ problemMessage: "Missing parameter type for '{0}'."
+ correctionMessage: Try adding an explicit type, or remove implicit-dynamic from your analysis options file.
IMPLICIT_DYNAMIC_RETURN:
- template: "Missing return type for '{0}'."
- tip: Try adding an explicit type, or remove implicit-dynamic from your analysis options file.
+ problemMessage: "Missing return type for '{0}'."
+ correctionMessage: Try adding an explicit type, or remove implicit-dynamic from your analysis options file.
IMPLICIT_DYNAMIC_TYPE:
- template: "Missing type arguments for generic type '{0}'."
- tip: Try adding an explicit type, or remove implicit-dynamic from your analysis options file.
+ problemMessage: "Missing type arguments for generic type '{0}'."
+ correctionMessage: Try adding an explicit type, or remove implicit-dynamic from your analysis options file.
IMPLICIT_DYNAMIC_VARIABLE:
- template: "Missing variable type for '{0}'."
- tip: Try adding an explicit type, or remove implicit-dynamic from your analysis options file.
+ problemMessage: "Missing variable type for '{0}'."
+ correctionMessage: Try adding an explicit type, or remove implicit-dynamic from your analysis options file.
ManifestWarningCode:
CAMERA_PERMISSIONS_INCOMPATIBLE:
- template: Camera permissions make app incompatible for Chrome OS, consider adding optional features "android.hardware.camera" and "android.hardware.camera.autofocus".
- tip: "Try adding `<uses-feature android:name=\"android.hardware.camera\" android:required=\"false\">` `<uses-feature android:name=\"android.hardware.camera.autofocus\" android:required=\"false\">`."
+ problemMessage: Camera permissions make app incompatible for Chrome OS, consider adding optional features "android.hardware.camera" and "android.hardware.camera.autofocus".
+ correctionMessage: "Try adding `<uses-feature android:name=\"android.hardware.camera\" android:required=\"false\">` `<uses-feature android:name=\"android.hardware.camera.autofocus\" android:required=\"false\">`."
comment: |-
A code indicating that the camera permissions is not supported on Chrome
OS.
NON_RESIZABLE_ACTIVITY:
- template: The `<activity>` element should be allowed to be resized to allow users to take advantage of the multi-window environment on Chrome OS
- tip: Consider declaring the corresponding activity element with `resizableActivity="true"` attribute.
+ problemMessage: The `<activity>` element should be allowed to be resized to allow users to take advantage of the multi-window environment on Chrome OS
+ correctionMessage: Consider declaring the corresponding activity element with `resizableActivity="true"` attribute.
comment: A code indicating that the activity is set to be non resizable.
NO_TOUCHSCREEN_FEATURE:
- template: "The default \"android.hardware.touchscreen\" needs to be optional for Chrome OS. "
- tip: "Consider adding <uses-feature android:name=\"android.hardware.touchscreen\" android:required=\"false\" /> to the manifest."
+ problemMessage: "The default \"android.hardware.touchscreen\" needs to be optional for Chrome OS. "
+ correctionMessage: "Consider adding <uses-feature android:name=\"android.hardware.touchscreen\" android:required=\"false\" /> to the manifest."
comment: |-
A code indicating that the touchscreen feature is not specified in the
manifest.
PERMISSION_IMPLIES_UNSUPPORTED_HARDWARE:
- template: "Permission makes app incompatible for Chrome OS, consider adding optional {0} feature tag, "
- tip: " Try adding `<uses-feature android:name=\"{0}\" android:required=\"false\">`."
+ problemMessage: "Permission makes app incompatible for Chrome OS, consider adding optional {0} feature tag, "
+ correctionMessage: " Try adding `<uses-feature android:name=\"{0}\" android:required=\"false\">`."
comment: |-
A code indicating that a specified permission is not supported on Chrome
OS.
SETTING_ORIENTATION_ON_ACTIVITY:
- template: The `<activity>` element should not be locked to any orientation so that users can take advantage of the multi-window environments and larger screens on Chrome OS
- tip: Consider declaring the corresponding activity element with `screenOrientation="unspecified"` or `"fullSensor"` attribute.
+ problemMessage: The `<activity>` element should not be locked to any orientation so that users can take advantage of the multi-window environments and larger screens on Chrome OS
+ correctionMessage: Consider declaring the corresponding activity element with `screenOrientation="unspecified"` or `"fullSensor"` attribute.
comment: A code indicating that the activity is locked to an orientation.
UNSUPPORTED_CHROME_OS_FEATURE:
- template: "The feature {0} is not supported on Chrome OS, consider making it optional."
- tip: "Try changing to `android:required=\"false\"` for this feature."
+ problemMessage: "The feature {0} is not supported on Chrome OS, consider making it optional."
+ correctionMessage: "Try changing to `android:required=\"false\"` for this feature."
comment: A code indicating that a specified feature is not supported on Chrome OS.
UNSUPPORTED_CHROME_OS_HARDWARE:
- template: "The feature {0} is not supported on Chrome OS, consider making it optional."
- tip: "Try adding `android:required=\"false\"` for this feature."
+ problemMessage: "The feature {0} is not supported on Chrome OS, consider making it optional."
+ correctionMessage: "Try adding `android:required=\"false\"` for this feature."
comment: |-
A code indicating that a specified hardware feature is not supported on
Chrome OS.
@@ -17302,8 +17338,8 @@
ABSTRACT_CLASS_MEMBER:
copyFromCfe: true
ABSTRACT_ENUM:
- template: "Enums can't be declared to be 'abstract'."
- tip: "Try removing the keyword 'abstract'."
+ problemMessage: "Enums can't be declared to be 'abstract'."
+ correctionMessage: "Try removing the keyword 'abstract'."
ABSTRACT_EXTERNAL_FIELD:
copyFromCfe: true
ABSTRACT_LATE_FIELD:
@@ -17311,17 +17347,17 @@
ABSTRACT_STATIC_FIELD:
copyFromCfe: true
ABSTRACT_STATIC_METHOD:
- template: "Static methods can't be declared to be 'abstract'."
- tip: "Try removing the keyword 'abstract'."
+ problemMessage: "Static methods can't be declared to be 'abstract'."
+ correctionMessage: "Try removing the keyword 'abstract'."
ABSTRACT_TOP_LEVEL_FUNCTION:
- template: "Top-level functions can't be declared to be 'abstract'."
- tip: "Try removing the keyword 'abstract'."
+ problemMessage: "Top-level functions can't be declared to be 'abstract'."
+ correctionMessage: "Try removing the keyword 'abstract'."
ABSTRACT_TOP_LEVEL_VARIABLE:
- template: "Top-level variables can't be declared to be 'abstract'."
- tip: "Try removing the keyword 'abstract'."
+ problemMessage: "Top-level variables can't be declared to be 'abstract'."
+ correctionMessage: "Try removing the keyword 'abstract'."
ABSTRACT_TYPEDEF:
- template: "Typedefs can't be declared to be 'abstract'."
- tip: "Try removing the keyword 'abstract'."
+ problemMessage: "Typedefs can't be declared to be 'abstract'."
+ correctionMessage: "Try removing the keyword 'abstract'."
ANNOTATION_ON_TYPE_ARGUMENT:
copyFromCfe: true
ANNOTATION_WITH_TYPE_ARGUMENTS:
@@ -17329,7 +17365,7 @@
ANNOTATION_WITH_TYPE_ARGUMENTS_UNINSTANTIATED:
copyFromCfe: true
ASYNC_KEYWORD_USED_AS_IDENTIFIER:
- template: "The keywords 'await' and 'yield' can't be used as identifiers in an asynchronous or generator function."
+ problemMessage: "The keywords 'await' and 'yield' can't be used as identifiers in an asynchronous or generator function."
comment: |-
16.32 Identifier Reference: It is a compile-time error if any of the
identifiers async, await, or yield is used as an identifier in a function
@@ -17357,18 +17393,18 @@
CONST_CLASS:
copyFromCfe: true
CONST_CONSTRUCTOR_WITH_BODY:
- template: "Const constructors can't have a body."
- tip: "Try removing either the 'const' keyword or the body."
+ problemMessage: "Const constructors can't have a body."
+ correctionMessage: "Try removing either the 'const' keyword or the body."
CONST_ENUM:
- template: "Enums can't be declared to be 'const'."
- tip: "Try removing the 'const' keyword."
+ problemMessage: "Enums can't be declared to be 'const'."
+ correctionMessage: "Try removing the 'const' keyword."
CONST_FACTORY:
copyFromCfe: true
CONST_METHOD:
copyFromCfe: true
CONST_TYPEDEF:
- template: "Type aliases can't be declared to be 'const'."
- tip: "Try removing the 'const' keyword."
+ problemMessage: "Type aliases can't be declared to be 'const'."
+ correctionMessage: "Try removing the 'const' keyword."
CONTINUE_OUTSIDE_OF_LOOP:
copyFromCfe: true
CONTINUE_WITHOUT_LABEL_IN_CASE:
@@ -17376,16 +17412,16 @@
COVARIANT_AND_STATIC:
copyFromCfe: true
COVARIANT_CONSTRUCTOR:
- template: "A constructor can't be declared to be 'covariant'."
- tip: "Try removing the keyword 'covariant'."
+ problemMessage: "A constructor can't be declared to be 'covariant'."
+ correctionMessage: "Try removing the keyword 'covariant'."
COVARIANT_MEMBER:
copyFromCfe: true
COVARIANT_TOP_LEVEL_DECLARATION:
- template: "Top-level declarations can't be declared to be covariant."
- tip: "Try removing the keyword 'covariant'."
+ problemMessage: "Top-level declarations can't be declared to be covariant."
+ correctionMessage: "Try removing the keyword 'covariant'."
DEFAULT_VALUE_IN_FUNCTION_TYPE:
- template: "Parameters in a function type can't have default values."
- tip: Try removing the default value.
+ problemMessage: "Parameters in a function type can't have default values."
+ correctionMessage: Try removing the default value.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -17433,8 +17469,8 @@
DUPLICATE_PREFIX:
copyFromCfe: true
EMPTY_ENUM_BODY:
- template: An enum must declare at least one constant name.
- tip: Try declaring a constant.
+ problemMessage: An enum must declare at least one constant name.
+ correctionMessage: Try declaring a constant.
ENUM_IN_CLASS:
copyFromCfe: true
EQUALITY_CANNOT_BE_EQUALITY_OPERAND:
@@ -17442,32 +17478,32 @@
EXPECTED_BODY:
copyFromCfe: true
EXPECTED_CASE_OR_DEFAULT:
- template: "Expected 'case' or 'default'."
- tip: Try placing this code inside a case clause.
+ problemMessage: "Expected 'case' or 'default'."
+ correctionMessage: Try placing this code inside a case clause.
EXPECTED_CLASS_MEMBER:
- template: Expected a class member.
- tip: Try placing this code inside a class member.
+ problemMessage: Expected a class member.
+ correctionMessage: Try placing this code inside a class member.
EXPECTED_ELSE_OR_COMMA:
copyFromCfe: true
EXPECTED_EXECUTABLE:
- template: Expected a method, getter, setter or operator declaration.
- tip: This appears to be incomplete code. Try removing it or completing it.
+ problemMessage: Expected a method, getter, setter or operator declaration.
+ correctionMessage: This appears to be incomplete code. Try removing it or completing it.
EXPECTED_IDENTIFIER_BUT_GOT_KEYWORD:
copyFromCfe: true
EXPECTED_INSTEAD:
copyFromCfe: true
EXPECTED_LIST_OR_MAP_LITERAL:
- template: Expected a list or map literal.
- tip: Try inserting a list or map literal, or remove the type arguments.
+ problemMessage: Expected a list or map literal.
+ correctionMessage: Try inserting a list or map literal, or remove the type arguments.
EXPECTED_STRING_LITERAL:
- template: Expected a string literal.
+ problemMessage: Expected a string literal.
EXPECTED_TOKEN:
- template: "Expected to find '{0}'."
+ problemMessage: "Expected to find '{0}'."
comment: |-
Parameters:
0: the token that was expected but not found
EXPECTED_TYPE_NAME:
- template: Expected a type name.
+ problemMessage: Expected a type name.
EXPERIMENT_NOT_ENABLED:
copyFromCfe: true
EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE:
@@ -17561,18 +17597,18 @@
EXTERNAL_FIELD:
copyFromCfe: true
EXTERNAL_GETTER_WITH_BODY:
- template: "External getters can't have a body."
- tip: "Try removing the body of the getter, or removing the keyword 'external'."
+ problemMessage: "External getters can't have a body."
+ correctionMessage: "Try removing the body of the getter, or removing the keyword 'external'."
EXTERNAL_LATE_FIELD:
copyFromCfe: true
EXTERNAL_METHOD_WITH_BODY:
copyFromCfe: true
EXTERNAL_OPERATOR_WITH_BODY:
- template: "External operators can't have a body."
- tip: "Try removing the body of the operator, or removing the keyword 'external'."
+ problemMessage: "External operators can't have a body."
+ correctionMessage: "Try removing the body of the operator, or removing the keyword 'external'."
EXTERNAL_SETTER_WITH_BODY:
- template: "External setters can't have a body."
- tip: "Try removing the body of the setter, or removing the keyword 'external'."
+ problemMessage: "External setters can't have a body."
+ correctionMessage: "Try removing the body of the setter, or removing the keyword 'external'."
EXTERNAL_TYPEDEF:
copyFromCfe: true
EXTRANEOUS_MODIFIER:
@@ -17580,11 +17616,11 @@
FACTORY_TOP_LEVEL_DECLARATION:
copyFromCfe: true
FACTORY_WITHOUT_BODY:
- template: "A non-redirecting 'factory' constructor must have a body."
- tip: Try adding a body to the constructor.
+ problemMessage: "A non-redirecting 'factory' constructor must have a body."
+ correctionMessage: Try adding a body to the constructor.
FACTORY_WITH_INITIALIZERS:
- template: "A 'factory' constructor can't have initializers."
- tip: "Try removing the 'factory' keyword to make this a generative constructor, or removing the initializers."
+ problemMessage: "A 'factory' constructor can't have initializers."
+ correctionMessage: "Try removing the 'factory' keyword to make this a generative constructor, or removing the initializers."
FIELD_INITIALIZED_OUTSIDE_DECLARING_CLASS:
copyFromCfe: true
FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR:
@@ -17596,31 +17632,31 @@
FINAL_AND_VAR:
copyFromCfe: true
FINAL_CLASS:
- template: "Classes can't be declared to be 'final'."
- tip: "Try removing the keyword 'final'."
+ problemMessage: "Classes can't be declared to be 'final'."
+ correctionMessage: "Try removing the keyword 'final'."
FINAL_CONSTRUCTOR:
- template: "A constructor can't be declared to be 'final'."
- tip: "Try removing the keyword 'final'."
+ problemMessage: "A constructor can't be declared to be 'final'."
+ correctionMessage: "Try removing the keyword 'final'."
FINAL_ENUM:
- template: "Enums can't be declared to be 'final'."
- tip: "Try removing the keyword 'final'."
+ problemMessage: "Enums can't be declared to be 'final'."
+ correctionMessage: "Try removing the keyword 'final'."
FINAL_METHOD:
- template: "Getters, setters and methods can't be declared to be 'final'."
- tip: "Try removing the keyword 'final'."
+ problemMessage: "Getters, setters and methods can't be declared to be 'final'."
+ correctionMessage: "Try removing the keyword 'final'."
FINAL_TYPEDEF:
- template: "Typedefs can't be declared to be 'final'."
- tip: "Try removing the keyword 'final'."
+ problemMessage: "Typedefs can't be declared to be 'final'."
+ correctionMessage: "Try removing the keyword 'final'."
FUNCTION_TYPED_PARAMETER_VAR:
- template: "Function-typed parameters can't specify 'const', 'final' or 'var' in place of a return type."
- tip: Try replacing the keyword with a return type.
+ problemMessage: "Function-typed parameters can't specify 'const', 'final' or 'var' in place of a return type."
+ correctionMessage: Try replacing the keyword with a return type.
GETTER_CONSTRUCTOR:
copyFromCfe: true
GETTER_IN_FUNCTION:
- template: "Getters can't be defined within methods or functions."
- tip: Try moving the getter outside the method or function, or converting the getter to a function.
+ problemMessage: "Getters can't be defined within methods or functions."
+ correctionMessage: Try moving the getter outside the method or function, or converting the getter to a function.
GETTER_WITH_PARAMETERS:
- template: Getters must be declared without a parameter list.
- tip: "Try removing the parameter list, or removing the keyword 'get' to define a method rather than a getter."
+ problemMessage: Getters must be declared without a parameter list.
+ correctionMessage: "Try removing the parameter list, or removing the keyword 'get' to define a method rather than a getter."
ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE:
copyFromCfe: true
IMPLEMENTS_BEFORE_EXTENDS:
@@ -17636,31 +17672,31 @@
INVALID_AWAIT_IN_FOR:
copyFromCfe: true
INVALID_CODE_POINT:
- template: "The escape sequence '{0}' isn't a valid code point."
+ problemMessage: "The escape sequence '{0}' isn't a valid code point."
comment: |-
Parameters:
0: the invalid escape sequence
INVALID_COMMENT_REFERENCE:
- template: "Comment references should contain a possibly prefixed identifier and can start with 'new', but shouldn't contain anything else."
+ problemMessage: "Comment references should contain a possibly prefixed identifier and can start with 'new', but shouldn't contain anything else."
INVALID_CONSTRUCTOR_NAME:
copyFromCfe: true
INVALID_GENERIC_FUNCTION_TYPE:
- template: Invalid generic function type.
- tip: "Try using a generic function type (returnType 'Function(' parameters ')')."
+ problemMessage: Invalid generic function type.
+ correctionMessage: "Try using a generic function type (returnType 'Function(' parameters ')')."
INVALID_HEX_ESCAPE:
copyFromCfe: true
INVALID_INITIALIZER:
copyFromCfe: true
INVALID_LITERAL_IN_CONFIGURATION:
- template: "The literal in a configuration can't contain interpolation."
- tip: Try removing the interpolation expressions.
+ problemMessage: "The literal in a configuration can't contain interpolation."
+ correctionMessage: Try removing the interpolation expressions.
INVALID_OPERATOR:
copyFromCfe: true
comment: |-
Parameters:
0: the operator that is invalid
INVALID_OPERATOR_FOR_SUPER:
- template: "The operator '{0}' can't be used with 'super'."
+ problemMessage: "The operator '{0}' can't be used with 'super'."
comment: |-
Parameters:
0: the operator being applied to 'super'
@@ -17670,13 +17706,13 @@
INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER:
copyFromCfe: true
INVALID_STAR_AFTER_ASYNC:
- template: "The modifier 'async*' isn't allowed for an expression function body."
- tip: Try converting the body to a block.
+ problemMessage: "The modifier 'async*' isn't allowed for an expression function body."
+ correctionMessage: Try converting the body to a block.
INVALID_SUPER_IN_INITIALIZER:
copyFromCfe: true
INVALID_SYNC:
- template: "The modifier 'sync' isn't allowed for an expression function body."
- tip: Try converting the body to a block.
+ problemMessage: "The modifier 'sync' isn't allowed for an expression function body."
+ correctionMessage: Try converting the body to a block.
INVALID_THIS_IN_INITIALIZER:
copyFromCfe: true
INVALID_UNICODE_ESCAPE:
@@ -17721,8 +17757,8 @@
LITERAL_WITH_NEW:
copyFromCfe: true
LOCAL_FUNCTION_DECLARATION_MODIFIER:
- template: "Local function declarations can't specify any modifiers."
- tip: Try removing the modifier.
+ problemMessage: "Local function declarations can't specify any modifiers."
+ correctionMessage: Try removing the modifier.
MEMBER_WITH_CLASS_NAME:
copyFromCfe: true
MISSING_ASSIGNABLE_SELECTOR:
@@ -17732,70 +17768,70 @@
MISSING_CATCH_OR_FINALLY:
copyFromCfe: true
MISSING_CLOSING_PARENTHESIS:
- template: The closing parenthesis is missing.
- tip: Try adding the closing parenthesis.
+ problemMessage: The closing parenthesis is missing.
+ correctionMessage: Try adding the closing parenthesis.
MISSING_CONST_FINAL_VAR_OR_TYPE:
copyFromCfe: true
MISSING_ENUM_BODY:
- template: An enum definition must have a body with at least one constant name.
- tip: Try adding a body and defining at least one constant.
+ problemMessage: An enum definition must have a body with at least one constant name.
+ correctionMessage: Try adding a body and defining at least one constant.
MISSING_EXPRESSION_IN_INITIALIZER:
- template: Expected an expression after the assignment operator.
- tip: Try adding the value to be assigned, or remove the assignment operator.
+ problemMessage: Expected an expression after the assignment operator.
+ correctionMessage: Try adding the value to be assigned, or remove the assignment operator.
MISSING_EXPRESSION_IN_THROW:
copyFromCfe: true
MISSING_FUNCTION_BODY:
- template: A function body must be provided.
- tip: Try adding a function body.
+ problemMessage: A function body must be provided.
+ correctionMessage: Try adding a function body.
MISSING_FUNCTION_KEYWORD:
- template: "Function types must have the keyword 'Function' before the parameter list."
- tip: "Try adding the keyword 'Function'."
+ problemMessage: "Function types must have the keyword 'Function' before the parameter list."
+ correctionMessage: "Try adding the keyword 'Function'."
MISSING_FUNCTION_PARAMETERS:
- template: Functions must have an explicit list of parameters.
- tip: Try adding a parameter list.
+ problemMessage: Functions must have an explicit list of parameters.
+ correctionMessage: Try adding a parameter list.
MISSING_GET:
- template: "Getters must have the keyword 'get' before the getter name."
- tip: "Try adding the keyword 'get'."
+ problemMessage: "Getters must have the keyword 'get' before the getter name."
+ correctionMessage: "Try adding the keyword 'get'."
MISSING_IDENTIFIER:
- template: Expected an identifier.
+ problemMessage: Expected an identifier.
MISSING_INITIALIZER:
copyFromCfe: true
MISSING_KEYWORD_OPERATOR:
copyFromCfe: true
MISSING_METHOD_PARAMETERS:
- template: Methods must have an explicit list of parameters.
- tip: Try adding a parameter list.
+ problemMessage: Methods must have an explicit list of parameters.
+ correctionMessage: Try adding a parameter list.
MISSING_NAME_FOR_NAMED_PARAMETER:
- template: Named parameters in a function type must have a name
- tip: Try providing a name for the parameter or removing the curly braces.
+ problemMessage: Named parameters in a function type must have a name
+ correctionMessage: Try providing a name for the parameter or removing the curly braces.
MISSING_NAME_IN_LIBRARY_DIRECTIVE:
- template: Library directives must include a library name.
- tip: "Try adding a library name after the keyword 'library', or remove the library directive if the library doesn't have any parts."
+ problemMessage: Library directives must include a library name.
+ correctionMessage: "Try adding a library name after the keyword 'library', or remove the library directive if the library doesn't have any parts."
MISSING_NAME_IN_PART_OF_DIRECTIVE:
- template: Part-of directives must include a library name.
- tip: "Try adding a library name after the 'of'."
+ problemMessage: Part-of directives must include a library name.
+ correctionMessage: "Try adding a library name after the 'of'."
MISSING_PREFIX_IN_DEFERRED_IMPORT:
copyFromCfe: true
MISSING_STAR_AFTER_SYNC:
- template: "The modifier 'sync' must be followed by a star ('*')."
- tip: Try removing the modifier, or add a star.
+ problemMessage: "The modifier 'sync' must be followed by a star ('*')."
+ correctionMessage: Try removing the modifier, or add a star.
MISSING_STATEMENT:
copyFromCfe: true
MISSING_TERMINATOR_FOR_PARAMETER_GROUP:
- template: "There is no '{0}' to close the parameter group."
- tip: "Try inserting a '{0}' at the end of the group."
+ problemMessage: "There is no '{0}' to close the parameter group."
+ correctionMessage: "Try inserting a '{0}' at the end of the group."
comment: |-
Parameters:
0: the terminator that is missing
MISSING_TYPEDEF_PARAMETERS:
- template: Typedefs must have an explicit list of parameters.
- tip: Try adding a parameter list.
+ problemMessage: Typedefs must have an explicit list of parameters.
+ correctionMessage: Try adding a parameter list.
MISSING_VARIABLE_IN_FOR_EACH:
- template: "A loop variable must be declared in a for-each loop before the 'in', but none was found."
- tip: Try declaring a loop variable.
+ problemMessage: "A loop variable must be declared in a for-each loop before the 'in', but none was found."
+ correctionMessage: Try declaring a loop variable.
MIXED_PARAMETER_GROUPS:
- template: "Can't have both positional and named parameters in a single parameter list."
- tip: Try choosing a single style of optional parameters.
+ problemMessage: "Can't have both positional and named parameters in a single parameter list."
+ correctionMessage: Try choosing a single style of optional parameters.
MIXIN_DECLARES_CONSTRUCTOR:
copyFromCfe: true
MODIFIER_OUT_OF_ORDER:
@@ -17803,23 +17839,23 @@
MULTIPLE_EXTENDS_CLAUSES:
copyFromCfe: true
MULTIPLE_IMPLEMENTS_CLAUSES:
- template: Each class or mixin definition can have at most one implements clause.
- tip: Try combining all of the implements clauses into a single clause.
+ problemMessage: Each class or mixin definition can have at most one implements clause.
+ correctionMessage: Try combining all of the implements clauses into a single clause.
MULTIPLE_LIBRARY_DIRECTIVES:
copyFromCfe: true
MULTIPLE_NAMED_PARAMETER_GROUPS:
- template: "Can't have multiple groups of named parameters in a single parameter list."
- tip: Try combining all of the groups into a single group.
+ problemMessage: "Can't have multiple groups of named parameters in a single parameter list."
+ correctionMessage: Try combining all of the groups into a single group.
MULTIPLE_ON_CLAUSES:
copyFromCfe: true
MULTIPLE_PART_OF_DIRECTIVES:
copyFromCfe: true
MULTIPLE_POSITIONAL_PARAMETER_GROUPS:
- template: "Can't have multiple groups of positional parameters in a single parameter list."
- tip: Try combining all of the groups into a single group.
+ problemMessage: "Can't have multiple groups of positional parameters in a single parameter list."
+ correctionMessage: Try combining all of the groups into a single group.
MULTIPLE_VARIABLES_IN_FOR_EACH:
- template: "A single loop variable must be declared in a for-each loop before the 'in', but {0} were found."
- tip: Try moving all but one of the declarations inside the loop body.
+ problemMessage: "A single loop variable must be declared in a for-each loop before the 'in', but {0} were found."
+ correctionMessage: Try moving all but one of the declarations inside the loop body.
comment: |-
Parameters:
0: the number of variables being declared
@@ -17828,50 +17864,50 @@
MULTIPLE_WITH_CLAUSES:
copyFromCfe: true
NAMED_FUNCTION_EXPRESSION:
- template: "Function expressions can't be named."
- tip: Try removing the name, or moving the function expression to a function declaration statement.
+ problemMessage: "Function expressions can't be named."
+ correctionMessage: Try removing the name, or moving the function expression to a function declaration statement.
NAMED_FUNCTION_TYPE:
- template: "Function types can't be named."
- tip: "Try replacing the name with the keyword 'Function'."
+ problemMessage: "Function types can't be named."
+ correctionMessage: "Try replacing the name with the keyword 'Function'."
NAMED_PARAMETER_OUTSIDE_GROUP:
- template: "Named parameters must be enclosed in curly braces ('{' and '}')."
- tip: Try surrounding the named parameters in curly braces.
+ problemMessage: "Named parameters must be enclosed in curly braces ('{' and '}')."
+ correctionMessage: Try surrounding the named parameters in curly braces.
NATIVE_CLAUSE_IN_NON_SDK_CODE:
- template: Native clause can only be used in the SDK and code that is loaded through native extensions.
- tip: Try removing the native clause.
+ problemMessage: Native clause can only be used in the SDK and code that is loaded through native extensions.
+ correctionMessage: Try removing the native clause.
NATIVE_CLAUSE_SHOULD_BE_ANNOTATION:
copyFromCfe: true
NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE:
- template: Native functions can only be declared in the SDK and code that is loaded through native extensions.
- tip: "Try removing the word 'native'."
+ problemMessage: Native functions can only be declared in the SDK and code that is loaded through native extensions.
+ correctionMessage: "Try removing the word 'native'."
NON_CONSTRUCTOR_FACTORY:
- template: Only a constructor can be declared to be a factory.
- tip: "Try removing the keyword 'factory'."
+ problemMessage: Only a constructor can be declared to be a factory.
+ correctionMessage: "Try removing the keyword 'factory'."
NON_IDENTIFIER_LIBRARY_NAME:
- template: The name of a library must be an identifier.
- tip: Try using an identifier as the name of the library.
+ problemMessage: The name of a library must be an identifier.
+ correctionMessage: Try using an identifier as the name of the library.
NON_PART_OF_DIRECTIVE_IN_PART:
- template: The part-of directive must be the only directive in a part.
- tip: Try removing the other directives, or moving them to the library for which this is a part.
+ problemMessage: The part-of directive must be the only directive in a part.
+ correctionMessage: Try removing the other directives, or moving them to the library for which this is a part.
NON_STRING_LITERAL_AS_URI:
- template: The URI must be a string literal.
- tip: Try enclosing the URI in either single or double quotes.
+ problemMessage: The URI must be a string literal.
+ correctionMessage: Try enclosing the URI in either single or double quotes.
NON_USER_DEFINABLE_OPERATOR:
- template: "The operator '{0}' isn't user definable."
+ problemMessage: "The operator '{0}' isn't user definable."
comment: |-
Parameters:
0: the operator that the user is trying to define
NORMAL_BEFORE_OPTIONAL_PARAMETERS:
- template: Normal parameters must occur before optional parameters.
- tip: Try moving all of the normal parameters before the optional parameters.
+ problemMessage: Normal parameters must occur before optional parameters.
+ correctionMessage: Try moving all of the normal parameters before the optional parameters.
NULL_AWARE_CASCADE_OUT_OF_ORDER:
copyFromCfe: true
POSITIONAL_AFTER_NAMED_ARGUMENT:
- template: Positional arguments must occur before named arguments.
- tip: Try moving all of the positional arguments before the named arguments.
+ problemMessage: Positional arguments must occur before named arguments.
+ correctionMessage: Try moving all of the positional arguments before the named arguments.
POSITIONAL_PARAMETER_OUTSIDE_GROUP:
- template: "Positional parameters must be enclosed in square brackets ('[' and ']')."
- tip: Try surrounding the positional parameters in square brackets.
+ problemMessage: "Positional parameters must be enclosed in square brackets ('[' and ']')."
+ correctionMessage: Try surrounding the positional parameters in square brackets.
PREFIX_AFTER_COMBINATOR:
copyFromCfe: true
REDIRECTING_CONSTRUCTOR_WITH_BODY:
@@ -17881,23 +17917,23 @@
SETTER_CONSTRUCTOR:
copyFromCfe: true
SETTER_IN_FUNCTION:
- template: "Setters can't be defined within methods or functions."
- tip: Try moving the setter outside the method or function.
+ problemMessage: "Setters can't be defined within methods or functions."
+ correctionMessage: Try moving the setter outside the method or function.
STACK_OVERFLOW:
copyFromCfe: true
STATIC_CONSTRUCTOR:
copyFromCfe: true
STATIC_GETTER_WITHOUT_BODY:
- template: "A 'static' getter must have a body."
- tip: "Try adding a body to the getter, or removing the keyword 'static'."
+ problemMessage: "A 'static' getter must have a body."
+ correctionMessage: "Try adding a body to the getter, or removing the keyword 'static'."
STATIC_OPERATOR:
copyFromCfe: true
STATIC_SETTER_WITHOUT_BODY:
- template: "A 'static' setter must have a body."
- tip: "Try adding a body to the setter, or removing the keyword 'static'."
+ problemMessage: "A 'static' setter must have a body."
+ correctionMessage: "Try adding a body to the setter, or removing the keyword 'static'."
STATIC_TOP_LEVEL_DECLARATION:
- template: "Top-level declarations can't be declared to be static."
- tip: "Try removing the keyword 'static'."
+ problemMessage: "Top-level declarations can't be declared to be static."
+ correctionMessage: "Try removing the keyword 'static'."
SWITCH_HAS_CASE_AFTER_DEFAULT_CASE:
copyFromCfe: true
SWITCH_HAS_MULTIPLE_DEFAULT_CASES:
@@ -17913,20 +17949,20 @@
TYPE_PARAMETER_ON_CONSTRUCTOR:
copyFromCfe: true
TYPE_PARAMETER_ON_OPERATOR:
- template: "Types parameters aren't allowed when defining an operator."
- tip: Try removing the type parameters.
+ problemMessage: "Types parameters aren't allowed when defining an operator."
+ correctionMessage: Try removing the type parameters.
comment: |-
7.1.1 Operators: Type parameters are not syntactically supported on an
operator.
UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP:
- template: "There is no '{0}' to open a parameter group."
- tip: "Try inserting the '{0}' at the appropriate location."
+ problemMessage: "There is no '{0}' to open a parameter group."
+ correctionMessage: "Try inserting the '{0}' at the appropriate location."
comment: |-
Parameters:
0: the starting character that was missing
UNEXPECTED_TOKEN:
- template: "Unexpected text '{0}'."
- tip: Try removing the text.
+ problemMessage: "Unexpected text '{0}'."
+ correctionMessage: Try removing the text.
comment: |-
Parameters:
0: the unexpected text that was found
@@ -17935,34 +17971,34 @@
VAR_AS_TYPE_NAME:
copyFromCfe: true
VAR_CLASS:
- template: "Classes can't be declared to be 'var'."
- tip: "Try removing the keyword 'var'."
+ problemMessage: "Classes can't be declared to be 'var'."
+ correctionMessage: "Try removing the keyword 'var'."
VAR_ENUM:
- template: "Enums can't be declared to be 'var'."
- tip: "Try removing the keyword 'var'."
+ problemMessage: "Enums can't be declared to be 'var'."
+ correctionMessage: "Try removing the keyword 'var'."
VAR_RETURN_TYPE:
copyFromCfe: true
VAR_TYPEDEF:
- template: "Typedefs can't be declared to be 'var'."
- tip: "Try removing the keyword 'var', or replacing it with the name of the return type."
+ problemMessage: "Typedefs can't be declared to be 'var'."
+ correctionMessage: "Try removing the keyword 'var', or replacing it with the name of the return type."
VOID_WITH_TYPE_ARGUMENTS:
copyFromCfe: true
WITH_BEFORE_EXTENDS:
copyFromCfe: true
WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER:
- template: "The default value of a positional parameter should be preceded by '='."
- tip: "Try replacing the ':' with '='."
+ problemMessage: "The default value of a positional parameter should be preceded by '='."
+ correctionMessage: "Try replacing the ':' with '='."
WRONG_TERMINATOR_FOR_PARAMETER_GROUP:
- template: "Expected '{0}' to close parameter group."
- tip: "Try replacing '{0}' with '{1}'."
+ problemMessage: "Expected '{0}' to close parameter group."
+ correctionMessage: "Try replacing '{0}' with '{1}'."
comment: |-
Parameters:
0: the terminator that was expected
1: the terminator that was found
PubspecWarningCode:
ASSET_DIRECTORY_DOES_NOT_EXIST:
- template: "The asset directory '{0}' doesn't exist."
- tip: Try creating the directory or fixing the path to the directory.
+ problemMessage: "The asset directory '{0}' doesn't exist."
+ correctionMessage: Try creating the directory or fixing the path to the directory.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -17994,8 +18030,8 @@
If the path isn't correct, then change the path to match the path of the
directory containing the assets.
ASSET_DOES_NOT_EXIST:
- template: "The asset file '{0}' doesn't exist."
- tip: Try creating the file or fixing the path to the file.
+ problemMessage: "The asset file '{0}' doesn't exist."
+ correctionMessage: Try creating the file or fixing the path to the file.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -18026,8 +18062,8 @@
If the path isn't correct, then change the path to match the path of the
file containing the asset.
ASSET_FIELD_NOT_LIST:
- template: "The value of the 'asset' field is expected to be a list of relative file paths."
- tip: Try converting the value to be a list of relative file paths.
+ problemMessage: "The value of the 'asset' field is expected to be a list of relative file paths."
+ correctionMessage: Try converting the value to be a list of relative file paths.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -18060,8 +18096,8 @@
- assets/
```
ASSET_NOT_STRING:
- template: Assets are required to be file paths (strings).
- tip: Try converting the value to be a string.
+ problemMessage: Assets are required to be file paths (strings).
+ correctionMessage: Try converting the value to be a string.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -18096,8 +18132,8 @@
- image.gif
```
DEPENDENCIES_FIELD_NOT_MAP:
- template: "The value of the '{0}' field is expected to be a map."
- tip: Try converting the value to be a map.
+ problemMessage: "The value of the '{0}' field is expected to be a map."
+ correctionMessage: Try converting the value to be a map.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -18129,8 +18165,8 @@
meta: ^1.0.2
```
DEPRECATED_FIELD:
- template: "The '{0}' field is no longer used and can be removed."
- tip: Try removing the field.
+ problemMessage: "The '{0}' field is no longer used and can be removed."
+ correctionMessage: Try removing the field.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -18160,8 +18196,8 @@
name: example
```
FLUTTER_FIELD_NOT_MAP:
- template: "The value of the 'flutter' field is expected to be a map."
- tip: Try converting the value to be a map.
+ problemMessage: "The value of the 'flutter' field is expected to be a map."
+ correctionMessage: Try converting the value to be a map.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -18201,8 +18237,8 @@
name: example
```
INVALID_DEPENDENCY:
- template: "Publishable packages can't have '{0}' dependencies."
- tip: "Try adding a 'publish_to: none' entry to mark the package as not for publishing or remove the {0} dependency."
+ problemMessage: "Publishable packages can't have '{0}' dependencies."
+ correctionMessage: "Try adding a 'publish_to: none' entry to mark the package as not for publishing or remove the {0} dependency."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -18254,8 +18290,8 @@
version: ^1.4.0
```
MISSING_NAME:
- template: "The 'name' field is required but missing."
- tip: "Try adding a field named 'name'."
+ problemMessage: "The 'name' field is required but missing."
+ correctionMessage: "Try adding a field named 'name'."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -18286,8 +18322,8 @@
meta: ^1.0.2
```
NAME_NOT_STRING:
- template: "The value of the 'name' field is required to be a string."
- tip: Try converting the value to be a string.
+ problemMessage: "The value of the 'name' field is required to be a string."
+ correctionMessage: Try converting the value to be a string.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -18316,8 +18352,8 @@
name: example
```
PATH_DOES_NOT_EXIST:
- template: "The path '{0}' doesn't exist."
- tip: Try creating the referenced path or using a path that exists.
+ problemMessage: "The path '{0}' doesn't exist."
+ correctionMessage: Try creating the referenced path or using a path that exists.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -18348,8 +18384,8 @@
If the path isn't correct, then change the path to match the path to the
root of the package.
PATH_NOT_POSIX:
- template: "The path '{0}' isn't a POSIX-style path."
- tip: Try converting the value to a POSIX-style path.
+ problemMessage: "The path '{0}' isn't a POSIX-style path."
+ correctionMessage: Try converting the value to a POSIX-style path.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -18377,8 +18413,8 @@
Convert the path to a POSIX path.
PATH_PUBSPEC_DOES_NOT_EXIST:
- template: "The directory '{0}' doesn't contain a pubspec."
- tip: Try creating a pubspec in the referenced directory or using a path that has a pubspec.
+ problemMessage: "The directory '{0}' doesn't contain a pubspec."
+ correctionMessage: Try creating a pubspec in the referenced directory or using a path that has a pubspec.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -18415,8 +18451,8 @@
If the path is wrong, then replace it with a the correct path.
UNNECESSARY_DEV_DEPENDENCY:
- template: "The dev dependency on {0} is unnecessary because there is also a normal dependency on that package."
- tip: Try removing the dev dependency.
+ problemMessage: "The dev dependency on {0} is unnecessary because there is also a normal dependency on that package."
+ correctionMessage: Try removing the dev dependency.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -18456,8 +18492,8 @@
```
StaticWarningCode:
DEAD_NULL_AWARE_EXPRESSION:
- template: "The left operand can't be null, so the right operand is never executed."
- tip: Try removing the operator and the right operand.
+ problemMessage: "The left operand can't be null, so the right operand is never executed."
+ correctionMessage: Try removing the operator and the right operand.
hasPublishedDocs: true
comment: No parameters.
documentation: |-
@@ -18535,8 +18571,8 @@
}
```
INVALID_NULL_AWARE_OPERATOR:
- template: "The receiver can't be null, so the null-aware operator '{0}' is unnecessary."
- tip: "Try replacing the operator '{0}' with '{1}'."
+ problemMessage: "The receiver can't be null, so the null-aware operator '{0}' is unnecessary."
+ correctionMessage: "Try replacing the operator '{0}' with '{1}'."
hasPublishedDocs: true
comment: |-
Parameters:
@@ -18613,16 +18649,16 @@
not be appropriate in some cases.)
INVALID_NULL_AWARE_OPERATOR_AFTER_SHORT_CIRCUIT:
sharedName: INVALID_NULL_AWARE_OPERATOR
- template: "The receiver can't be null because of short-circuiting, so the null-aware operator '{0}' can't be used."
- tip: "Try replacing the operator '{0}' with '{1}'."
+ problemMessage: "The receiver can't be null because of short-circuiting, so the null-aware operator '{0}' can't be used."
+ correctionMessage: "Try replacing the operator '{0}' with '{1}'."
hasPublishedDocs: true
comment: |-
Parameters:
0: the null-aware operator that is invalid
1: the non-null-aware operator that can replace the invalid operator
INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_NAMED:
- template: "Parameters can't override default values, this method overrides '{0}.{1}' where '{2}' has a different value."
- tip: Try using the same default value in both methods.
+ problemMessage: "Parameters can't override default values, this method overrides '{0}.{1}' where '{2}' has a different value."
+ correctionMessage: Try using the same default value in both methods.
comment: |-
7.1 Instance Methods: It is a static warning if an instance method
<i>m1</i> overrides an instance member <i>m2</i>, the signature of
@@ -18630,8 +18666,8 @@
<i>p</i> and the signature of <i>m1</i> specifies a different default value
for <i>p</i>.
INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_POSITIONAL:
- template: "Parameters can't override default values, this method overrides '{0}.{1}' where this positional parameter has a different value."
- tip: Try using the same default value in both methods.
+ problemMessage: "Parameters can't override default values, this method overrides '{0}.{1}' where this positional parameter has a different value."
+ correctionMessage: Try using the same default value in both methods.
comment: |-
7.1 Instance Methods: It is a static warning if an instance method
<i>m1</i> overrides an instance member <i>m2</i>, the signature of
@@ -18639,8 +18675,8 @@
<i>p</i> and the signature of <i>m1</i> specifies a different default value
for <i>p</i>.
MISSING_ENUM_CONSTANT_IN_SWITCH:
- template: "Missing case clause for '{0}'."
- tip: Try adding a case clause for the missing constant, or adding a default clause.
+ problemMessage: "Missing case clause for '{0}'."
+ correctionMessage: Try adding a case clause for the missing constant, or adding a default clause.
hasPublishedDocs: true
comment: |-
Parameters:
@@ -18706,8 +18742,8 @@
TODO(brianwilkerson) This documentation will need to be updated when NNBD
ships.
UNNECESSARY_NON_NULL_ASSERTION:
- template: "The '!' will have no effect because the receiver can't be null."
- tip: "Try removing the '!' operator."
+ problemMessage: "The '!' will have no effect because the receiver can't be null."
+ correctionMessage: "Try removing the '!' operator."
hasPublishedDocs: true
comment: No parameters.
documentation: |-
diff --git a/pkg/analyzer/pubspec.yaml b/pkg/analyzer/pubspec.yaml
index dd5d48d..8497bb1 100644
--- a/pkg/analyzer/pubspec.yaml
+++ b/pkg/analyzer/pubspec.yaml
@@ -1,5 +1,5 @@
name: analyzer
-version: 2.4.0-dev
+version: 2.4.0
description: This package provides a library that performs static analysis of Dart code.
homepage: https://github.com/dart-lang/sdk/tree/main/pkg/analyzer
@@ -7,7 +7,7 @@
sdk: '>=2.14.0 <3.0.0'
dependencies:
- _fe_analyzer_shared: ^26.0.0
+ _fe_analyzer_shared: ^27.0.0
cli_util: ^0.3.0
collection: ^1.15.0
convert: ^3.0.0
diff --git a/pkg/analyzer/tool/diagnostics/generate.dart b/pkg/analyzer/tool/diagnostics/generate.dart
index e431fb0..30b25bc 100644
--- a/pkg/analyzer/tool/diagnostics/generate.dart
+++ b/pkg/analyzer/tool/diagnostics/generate.dart
@@ -30,10 +30,17 @@
String packageRoot = pathContext.normalize(package_root.packageRoot);
String analyzerPath = pathContext.join(packageRoot, 'analyzer');
return CodePath.from([
- [analyzerPath, 'lib', 'src', 'dart', 'error', 'hint_codes.dart'],
- [analyzerPath, 'lib', 'src', 'dart', 'error', 'syntactic_errors.dart'],
- [analyzerPath, 'lib', 'src', 'error', 'codes.dart'],
- [analyzerPath, 'lib', 'src', 'pubspec', 'pubspec_warning_code.dart'],
+ [analyzerPath, 'lib', 'src', 'dart', 'error', 'hint_codes.g.dart'],
+ [
+ analyzerPath,
+ 'lib',
+ 'src',
+ 'dart',
+ 'error',
+ 'syntactic_errors.analyzer.g.dart'
+ ],
+ [analyzerPath, 'lib', 'src', 'error', 'codes.g.dart'],
+ [analyzerPath, 'lib', 'src', 'pubspec', 'pubspec_warning_code.g.dart'],
], [
null,
[analyzerPath, 'lib', 'src', 'dart', 'error', 'syntactic_errors.g.dart'],
diff --git a/pkg/analyzer/tool/messages/error_code_info.dart b/pkg/analyzer/tool/messages/error_code_info.dart
index 4a94bf8..bc63b2b 100644
--- a/pkg/analyzer/tool/messages/error_code_info.dart
+++ b/pkg/analyzer/tool/messages/error_code_info.dart
@@ -4,6 +4,23 @@
import 'dart:convert';
+/// Decodes a YAML object (obtained from `pkg/analyzer/messages.yaml`) into a
+/// two-level map of [ErrorCodeInfo], indexed first by class name and then by
+/// error name.
+Map<String, Map<String, ErrorCodeInfo>> decodeAnalyzerMessagesYaml(
+ Map<Object?, Object?> yaml) {
+ var result = <String, Map<String, ErrorCodeInfo>>{};
+ for (var classEntry in yaml.entries) {
+ var className = classEntry.key as String;
+ for (var errorEntry
+ in (classEntry.value as Map<Object?, Object?>).entries) {
+ (result[className] ??= {})[errorEntry.key as String] =
+ ErrorCodeInfo.fromYaml(errorEntry.value as Map<Object?, Object?>);
+ }
+ }
+ return result;
+}
+
/// Decodes a YAML object (obtained from `pkg/front_end/messages.yaml`) into a
/// map from error name to [ErrorCodeInfo].
Map<String, ErrorCodeInfo> decodeCfeMessagesYaml(Map<Object?, Object?> yaml) {
@@ -118,6 +135,10 @@
/// to the CFE's messages.yaml file so that this isn't necessary.
final bool copyFromCfe;
+ /// If the error code has an associated correctionMessage, the template for
+ /// it.
+ final String? correctionMessage;
+
/// If present, user-facing documentation for the error.
final String? documentation;
@@ -132,18 +153,15 @@
/// Indicates whether this error is caused by an unresolved identifier.
final bool isUnresolvedIdentifier;
+ /// The problemMessage for the error code, or `null` if [copyFromCfe] is
+ /// `true`.
+ final String? problemMessage;
+
/// If present, indicates that this error code has a special name for
/// presentation to the user, that is potentially shared with other error
/// codes.
final String? sharedName;
- /// The template for the error message, or `null` if [copyFromCfe] is `true`.
- final String? template;
-
- /// If the error code has an associated tip/correction message, the template
- /// for it.
- final String? tip;
-
ErrorCodeInfo(
{this.analyzerCode = const [],
this.comment,
@@ -153,15 +171,16 @@
this.index,
this.isUnresolvedIdentifier = false,
this.sharedName,
- this.template,
- this.tip}) {
+ this.problemMessage,
+ this.correctionMessage}) {
if (copyFromCfe) {
- if (template != null) {
- throw "Error codes marked `copyFromCfe: true` can't have a template.";
+ if (problemMessage != null) {
+ throw "Error codes marked `copyFromCfe: true` can't have a "
+ "problemMessage.";
}
} else {
- if (template == null) {
- throw 'Error codes must have a template unless they are marked '
+ if (problemMessage == null) {
+ throw 'Error codes must have a problemMessage unless they are marked '
'`copyFromCfe: true`.';
}
}
@@ -173,14 +192,14 @@
analyzerCode: _decodeAnalyzerCode(yaml['analyzerCode']),
comment: yaml['comment'] as String?,
copyFromCfe: yaml['copyFromCfe'] as bool? ?? false,
+ correctionMessage: yaml['correctionMessage'] as String?,
documentation: yaml['documentation'] as String?,
hasPublishedDocs: yaml['hasPublishedDocs'] as bool? ?? false,
index: yaml['index'] as int?,
isUnresolvedIdentifier:
yaml['isUnresolvedIdentifier'] as bool? ?? false,
- sharedName: yaml['sharedName'] as String?,
- template: yaml['template'] as String?,
- tip: yaml['tip'] as String?);
+ problemMessage: yaml['problemMessage'] as String?,
+ sharedName: yaml['sharedName'] as String?);
/// Generates a dart declaration for this error code, suitable for inclusion
/// in the error class [className]. [errorCode] is the name of the error code
@@ -188,30 +207,59 @@
String toAnalyzerCode(String className, String errorCode) {
var out = StringBuffer();
out.writeln('$className(');
- out.writeln("'$errorCode',");
+ out.writeln("'${sharedName ?? errorCode}',");
final placeholderToIndexMap = _computePlaceholderToIndexMap();
out.writeln(
- json.encode(_convertTemplate(placeholderToIndexMap, template!)));
- final tip = this.tip;
- if (tip is String) {
- out.write(',correction: ');
- out.writeln(json.encode(_convertTemplate(placeholderToIndexMap, tip)));
+ json.encode(_convertTemplate(placeholderToIndexMap, problemMessage!)) +
+ ',');
+ final correctionMessage = this.correctionMessage;
+ if (correctionMessage is String) {
+ out.write('correction: ');
+ out.writeln(json.encode(
+ _convertTemplate(placeholderToIndexMap, correctionMessage)) +
+ ',');
}
if (hasPublishedDocs) {
- out.writeln(',hasPublishedDocs:true');
+ out.writeln('hasPublishedDocs:true,');
+ }
+ if (isUnresolvedIdentifier) {
+ out.writeln('isUnresolvedIdentifier:true,');
+ }
+ if (sharedName != null) {
+ out.writeln("uniqueName: '$errorCode',");
}
out.write(');');
return out.toString();
}
+ /// Generates dart comments for this error code.
+ String toAnalyzerComments({String indent = ''}) {
+ var out = StringBuffer();
+ var comment = this.comment;
+ if (comment != null) {
+ out.writeln('$indent/**');
+ for (var line in comment.split('\n')) {
+ out.writeln('$indent *${line.isEmpty ? '' : ' '}$line');
+ }
+ out.writeln('$indent */');
+ }
+ var documentation = this.documentation;
+ if (documentation != null) {
+ for (var line in documentation.split('\n')) {
+ out.writeln('$indent//${line.isEmpty ? '' : ' '}$line');
+ }
+ }
+ return out.toString();
+ }
+
/// Encodes this object into a YAML representation.
Map<Object?, Object?> toYaml() => {
if (copyFromCfe) 'copyFromCfe': true,
if (sharedName != null) 'sharedName': sharedName,
if (analyzerCode.isNotEmpty)
'analyzerCode': _encodeAnalyzerCode(analyzerCode),
- if (template != null) 'template': template,
- if (tip != null) 'tip': tip,
+ if (problemMessage != null) 'problemMessage': problemMessage,
+ if (correctionMessage != null) 'correctionMessage': correctionMessage,
if (isUnresolvedIdentifier) 'isUnresolvedIdentifier': true,
if (hasPublishedDocs) 'hasPublishedDocs': true,
if (comment != null) 'comment': comment,
@@ -219,10 +267,10 @@
};
/// Given a messages.yaml entry, come up with a mapping from placeholder
- /// patterns in its message and tip strings to their corresponding indices.
+ /// patterns in its message strings to their corresponding indices.
Map<String, int> _computePlaceholderToIndexMap() {
var mapping = <String, int>{};
- for (var value in [template, tip]) {
+ for (var value in [problemMessage, correctionMessage]) {
if (value is! String) continue;
for (Match match in _placeholderPattern.allMatches(value)) {
// CFE supports a bunch of formatting options that we don't; make sure
diff --git a/pkg/analyzer/tool/messages/extract_errors_to_yaml.dart b/pkg/analyzer/tool/messages/extract_errors_to_yaml.dart
index f0c3790..4834120 100644
--- a/pkg/analyzer/tool/messages/extract_errors_to_yaml.dart
+++ b/pkg/analyzer/tool/messages/extract_errors_to_yaml.dart
@@ -252,8 +252,8 @@
} else {
errorCodeInfo = ErrorCodeInfo(
sharedName: uniqueNameSuffix == name ? null : name,
- template: code.message,
- tip: code.correction,
+ problemMessage: code.message,
+ correctionMessage: code.correction,
isUnresolvedIdentifier: code.isUnresolvedIdentifier,
hasPublishedDocs: code.hasPublishedDocs,
comment: documentationComment,
diff --git a/pkg/analyzer/tool/messages/generate.dart b/pkg/analyzer/tool/messages/generate.dart
index 7c44d8d..15c7f35 100644
--- a/pkg/analyzer/tool/messages/generate.dart
+++ b/pkg/analyzer/tool/messages/generate.dart
@@ -14,11 +14,10 @@
///
/// It is expected that 'pkg/front_end/tool/fasta generate-messages'
/// has already been successfully run.
+import 'dart:convert';
import 'dart:io';
import 'package:_fe_analyzer_shared/src/scanner/scanner.dart';
-import 'package:analyzer/error/error.dart';
-import 'package:analyzer/src/dart/error/syntactic_errors.dart';
import 'package:analyzer_utilities/package_root.dart' as pkg_root;
import 'package:analyzer_utilities/tools.dart';
import 'package:path/path.dart';
@@ -35,6 +34,72 @@
..printSummary();
}
+/// Information about all the classes derived from `ErrorCode` that should be
+/// generated.
+const List<_ErrorClassInfo> _errorClasses = [
+ _ErrorClassInfo(
+ filePath: 'lib/src/analysis_options/error/option_codes.g.dart',
+ name: 'AnalysisOptionsErrorCode',
+ type: 'COMPILE_TIME_ERROR',
+ severity: 'ERROR'),
+ _ErrorClassInfo(
+ filePath: 'lib/src/analysis_options/error/option_codes.g.dart',
+ name: 'AnalysisOptionsHintCode',
+ type: 'HINT',
+ severity: 'INFO'),
+ _ErrorClassInfo(
+ filePath: 'lib/src/analysis_options/error/option_codes.g.dart',
+ name: 'AnalysisOptionsWarningCode',
+ type: 'STATIC_WARNING',
+ severity: 'WARNING'),
+ _ErrorClassInfo(
+ filePath: 'lib/src/error/codes.g.dart',
+ name: 'CompileTimeErrorCode',
+ superclass: 'AnalyzerErrorCode',
+ type: 'COMPILE_TIME_ERROR',
+ extraImports: ['package:analyzer/src/error/analyzer_error_code.dart']),
+ _ErrorClassInfo(
+ filePath: 'lib/src/error/codes.g.dart',
+ name: 'LanguageCode',
+ type: 'COMPILE_TIME_ERROR'),
+ _ErrorClassInfo(
+ filePath: 'lib/src/error/codes.g.dart',
+ name: 'StaticWarningCode',
+ superclass: 'AnalyzerErrorCode',
+ type: 'STATIC_WARNING',
+ severity: 'WARNING',
+ extraImports: ['package:analyzer/src/error/analyzer_error_code.dart']),
+ _ErrorClassInfo(
+ filePath: 'lib/src/dart/error/ffi_code.g.dart',
+ name: 'FfiCode',
+ superclass: 'AnalyzerErrorCode',
+ type: 'COMPILE_TIME_ERROR',
+ extraImports: ['package:analyzer/src/error/analyzer_error_code.dart']),
+ _ErrorClassInfo(
+ filePath: 'lib/src/dart/error/hint_codes.g.dart',
+ name: 'HintCode',
+ superclass: 'AnalyzerErrorCode',
+ type: 'HINT',
+ extraImports: ['package:analyzer/src/error/analyzer_error_code.dart']),
+ _ErrorClassInfo(
+ // TODO(paulberry): merge with `syntactic_errors.g.dart`.
+ filePath: 'lib/src/dart/error/syntactic_errors.analyzer.g.dart',
+ name: 'ParserErrorCode',
+ type: 'SYNTACTIC_ERROR',
+ severity: 'ERROR',
+ includeCfeMessages: true),
+ _ErrorClassInfo(
+ filePath: 'lib/src/manifest/manifest_warning_code.g.dart',
+ name: 'ManifestWarningCode',
+ type: 'STATIC_WARNING',
+ severity: 'WARNING'),
+ _ErrorClassInfo(
+ filePath: 'lib/src/pubspec/pubspec_warning_code.g.dart',
+ name: 'PubspecWarningCode',
+ type: 'STATIC_WARNING',
+ severity: 'WARNING'),
+];
+
/// A list of all targets generated by this code generator.
final List<GeneratedContent> allTargets = <GeneratedContent>[
GeneratedFile('lib/src/dart/error/syntactic_errors.g.dart',
@@ -44,17 +109,172 @@
codeGenerator.generateFormatCode();
return codeGenerator.out.toString();
}),
+ ..._analyzerGeneratedFiles(),
];
/// The path to the `analyzer` package.
final String analyzerPkgPath =
normalize(join(pkg_root.packageRoot, 'analyzer'));
+/// The path to the `front_end` package.
+final String frontEndPkgPath =
+ normalize(join(pkg_root.packageRoot, 'front_end'));
+
+/// Decoded messages from the anlayzer's `messages.yaml` file.
+final Map<String, Map<String, ErrorCodeInfo>> _analyzerMessages =
+ _loadAnalyzerMessages();
+
+/// Generates a list of [GeneratedContent] objects describing all the analyzer
+/// files that need to be generated.
+List<GeneratedContent> _analyzerGeneratedFiles() {
+ var classesByFile = <String, List<_ErrorClassInfo>>{};
+ for (var errorClassInfo in _errorClasses) {
+ (classesByFile[errorClassInfo.filePath] ??= []).add(errorClassInfo);
+ }
+ return [
+ for (var entry in classesByFile.entries)
+ GeneratedFile(entry.key, (String pkgPath) async {
+ final codeGenerator = _AnalyzerErrorGenerator(entry.value);
+ codeGenerator.generate();
+ return codeGenerator.out.toString();
+ })
+ ];
+}
+
+/// Loads analyzer messages from the analyzer's `messages.yaml` file.
+Map<String, Map<String, ErrorCodeInfo>> _loadAnalyzerMessages() {
+ Map<dynamic, dynamic> messagesYaml =
+ loadYaml(File(join(analyzerPkgPath, 'messages.yaml')).readAsStringSync());
+ return decodeAnalyzerMessagesYaml(messagesYaml);
+}
+
+/// Code generator for analyzer error classes.
+class _AnalyzerErrorGenerator {
+ final List<_ErrorClassInfo> errorClasses;
+ final out = StringBuffer('''
+// 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.
+''');
+
+ _AnalyzerErrorGenerator(this.errorClasses);
+
+ void generate() {
+ var imports = {'package:analyzer/error/error.dart'};
+ var parts = <String>{};
+ for (var errorClass in errorClasses) {
+ imports.addAll(errorClass.extraImports);
+ if (errorClass.includeCfeMessages) {
+ parts.add('syntactic_errors.g.dart');
+ }
+ }
+ out.writeln();
+ for (var importPath in imports.toList()..sort()) {
+ out.writeln("import ${json.encode(importPath)};");
+ }
+ if (parts.isNotEmpty) {
+ out.writeln();
+ for (var partPath in parts.toList()..sort()) {
+ out.writeln("part ${json.encode(partPath)};");
+ }
+ }
+ out.writeln();
+ out.writeln("// It is hard to visually separate each code's _doc comment_ "
+ "from its published");
+ out.writeln('// _documentation comment_ when each is written as an '
+ 'end-of-line comment.');
+ out.writeln('// ignore_for_file: slash_for_doc_comments');
+ for (var errorClass in errorClasses.toList()
+ ..sort((a, b) => a.name.compareTo(b.name))) {
+ out.writeln();
+ out.write('class ${errorClass.name} extends ${errorClass.superclass} {');
+ for (var entry in _analyzerMessages[errorClass.name]!.entries.toList()
+ ..sort((a, b) => a.key.compareTo(b.key))) {
+ var errorName = entry.key;
+ var errorCodeInfo = entry.value;
+ out.writeln();
+ out.write(errorCodeInfo.toAnalyzerComments(indent: ' '));
+ out.writeln(' static const ${errorClass.name} $errorName =');
+ if (errorCodeInfo.copyFromCfe) {
+ out.writeln(' _$errorName;');
+ } else {
+ out.writeln(errorCodeInfo.toAnalyzerCode(errorClass.name, errorName));
+ }
+ }
+ out.writeln();
+ out.writeln('/// Initialize a newly created error code to have the given '
+ '[name].');
+ out.writeln('const ${errorClass.name}(String name, String message, {');
+ out.writeln('String? correction,');
+ out.writeln('bool hasPublishedDocs = false,');
+ out.writeln('bool isUnresolvedIdentifier = false,');
+ out.writeln('String? uniqueName,');
+ out.writeln('}) : super(');
+ out.writeln('correction: correction,');
+ out.writeln('hasPublishedDocs: hasPublishedDocs,');
+ out.writeln('isUnresolvedIdentifier: isUnresolvedIdentifier,');
+ out.writeln('message: message,');
+ out.writeln('name: name,');
+ out.writeln("uniqueName: '${errorClass.name}.\${uniqueName ?? name}',");
+ out.writeln(');');
+ out.writeln();
+ out.writeln('@override');
+ out.writeln('ErrorSeverity get errorSeverity => '
+ '${errorClass.severityCode};');
+ out.writeln();
+ out.writeln('@override');
+ out.writeln('ErrorType get type => ${errorClass.typeCode};');
+ out.writeln('}');
+ }
+ }
+}
+
+class _ErrorClassInfo {
+ final List<String> extraImports;
+
+ final String filePath;
+
+ final bool includeCfeMessages;
+
+ final String name;
+
+ final String? severity;
+
+ final String superclass;
+
+ final String type;
+
+ const _ErrorClassInfo(
+ {this.extraImports = const [],
+ required this.filePath,
+ this.includeCfeMessages = false,
+ required this.name,
+ this.severity,
+ this.superclass = 'ErrorCode',
+ required this.type});
+
+ String get severityCode {
+ var severity = this.severity;
+ if (severity == null) {
+ return '$typeCode.severity';
+ } else {
+ return 'ErrorSeverity.$severity';
+ }
+ }
+
+ String get typeCode => 'ErrorType.$type';
+}
+
class _SyntacticErrorGenerator {
- final Map<String, ErrorCodeInfo> messages;
+ final Map<String, ErrorCodeInfo> cfeMessages;
final CfeToAnalyzerErrorCodeTables tables;
+ final Map<String, Map<String, ErrorCodeInfo>> analyzerMessages;
final String errorConverterSource;
- final String syntacticErrorsSource;
final String parserSource;
final out = StringBuffer('''
//
@@ -63,7 +283,7 @@
// Instead modify 'pkg/front_end/messages.yaml' and run
// 'dart pkg/analyzer/tool/messages/generate.dart' to update.
-part of 'syntactic_errors.dart';
+part of 'syntactic_errors.analyzer.g.dart';
''');
@@ -72,25 +292,27 @@
String frontEndSharedPkgPath =
normalize(join(pkg_root.packageRoot, '_fe_analyzer_shared'));
- Map<dynamic, dynamic> messagesYaml = loadYaml(
+ Map<dynamic, dynamic> cfeMessagesYaml = loadYaml(
File(join(frontEndPkgPath, 'messages.yaml')).readAsStringSync());
+ Map<dynamic, dynamic> analyzerMessagesYaml = loadYaml(
+ File(join(analyzerPkgPath, 'messages.yaml')).readAsStringSync());
String errorConverterSource = File(join(analyzerPkgPath,
joinAll(posix.split('lib/src/fasta/error_converter.dart'))))
.readAsStringSync();
- String syntacticErrorsSource = File(join(analyzerPkgPath,
- joinAll(posix.split('lib/src/dart/error/syntactic_errors.dart'))))
- .readAsStringSync();
String parserSource = File(join(frontEndSharedPkgPath,
joinAll(posix.split('lib/src/parser/parser.dart'))))
.readAsStringSync();
- return _SyntacticErrorGenerator._(decodeCfeMessagesYaml(messagesYaml),
- errorConverterSource, syntacticErrorsSource, parserSource);
+ return _SyntacticErrorGenerator._(
+ decodeCfeMessagesYaml(cfeMessagesYaml),
+ decodeAnalyzerMessagesYaml(analyzerMessagesYaml),
+ errorConverterSource,
+ parserSource);
}
- _SyntacticErrorGenerator._(this.messages, this.errorConverterSource,
- this.syntacticErrorsSource, this.parserSource)
- : tables = CfeToAnalyzerErrorCodeTables(messages);
+ _SyntacticErrorGenerator._(this.cfeMessages, this.analyzerMessages,
+ this.errorConverterSource, this.parserSource)
+ : tables = CfeToAnalyzerErrorCodeTables(cfeMessages);
void checkForManualChanges() {
// Check for ParserErrorCodes that could be removed from
@@ -111,25 +333,9 @@
print(' $converterCount total');
}
- // Check that the public ParserErrorCodes have been updated
- // to reference the generated codes.
- int publicCount = 0;
- for (var errorCode in tables.infoToAnalyzerCode.values) {
- if (!syntacticErrorsSource.contains(' _$errorCode')) {
- if (publicCount == 0) {
- print('');
- print('The following ParserErrorCodes should be updated'
- ' in syntactic_errors.dart');
- print('to reference the associated generated error code:');
- }
- print(' static const ParserErrorCode $errorCode = _$errorCode;');
- ++publicCount;
- }
- }
-
// Fail if there are manual changes to be made, but do so
// in a fire and forget manner so that the files are still generated.
- if (converterCount > 0 || publicCount > 0) {
+ if (converterCount > 0) {
print('');
throw 'Error: missing manual code changes';
}
@@ -163,16 +369,16 @@
void printSummary() {
// Build a map of error message to ParserErrorCode
final messageToName = <String, String>{};
- for (ErrorCode errorCode in errorCodeValues) {
- if (errorCode is ParserErrorCode) {
- String message = errorCode.message.replaceAll(RegExp(r'\{\d+\}'), '');
- messageToName[message] = errorCode.name;
- }
+ for (var entry in analyzerMessages['ParserErrorCode']!.entries) {
+ if (entry.value.copyFromCfe) continue;
+ String message =
+ entry.value.problemMessage!.replaceAll(RegExp(r'\{\d+\}'), '');
+ messageToName[message] = entry.key;
}
String messageFromEntryTemplate(ErrorCodeInfo entry) {
- String template = entry.template!;
- String message = template.replaceAll(RegExp(r'#\w+'), '');
+ String problemMessage = entry.problemMessage!;
+ String message = problemMessage.replaceAll(RegExp(r'#\w+'), '');
return message;
}
@@ -188,7 +394,7 @@
// List the ParserErrorCodes that could easily be auto generated
// but have not been already.
final analyzerToFasta = <String, List<String>>{};
- messages.forEach((fastaName, entry) {
+ cfeMessages.forEach((fastaName, entry) {
final analyzerName = messageToName[messageFromEntryTemplate(entry)];
if (analyzerName != null) {
analyzerToFasta
@@ -241,17 +447,17 @@
final sorted = untranslatedFastaErrorCodes.toList()..sort();
for (String fastaErrorCode in sorted) {
String analyzerCode = '';
- String template = '';
- var entry = messages[fastaErrorCode];
+ String problemMessage = '';
+ var entry = cfeMessages[fastaErrorCode];
if (entry != null) {
// TODO(paulberry): handle multiple analyzer codes
if (entry.index == null && entry.analyzerCode.length == 1) {
analyzerCode = entry.analyzerCode.single;
- template = entry.template!;
+ problemMessage = entry.problemMessage!;
}
}
print(' ${fastaErrorCode.padRight(30)} --> $analyzerCode'
- '\n $template');
+ '\n $problemMessage');
}
}
}
diff --git a/pkg/dds/lib/dap.dart b/pkg/dds/lib/dap.dart
index cb598fe..792e9dd 100644
--- a/pkg/dds/lib/dap.dart
+++ b/pkg/dds/lib/dap.dart
@@ -2,4 +2,12 @@
// 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.
+export 'src/dap/adapters/dart.dart';
+export 'src/dap/adapters/mixins.dart';
+export 'src/dap/exceptions.dart';
+export 'src/dap/logging.dart';
+export 'src/dap/protocol_common.dart';
+export 'src/dap/protocol_generated.dart';
+export 'src/dap/protocol_stream.dart';
export 'src/dap/server.dart' show DapServer;
+export 'src/dap/stream_transformers.dart';
diff --git a/pkg/dds/lib/src/dap/adapters/dart.dart b/pkg/dds/lib/src/dap/adapters/dart.dart
index a66f36d..cc0e49a 100644
--- a/pkg/dds/lib/src/dap/adapters/dart.dart
+++ b/pkg/dds/lib/src/dap/adapters/dart.dart
@@ -361,6 +361,8 @@
this.enableAuthCodes = true,
this.logger,
}) : super(channel) {
+ channel.closed.then((_) => shutdown());
+
_isolateManager = IsolateManager(this);
_converter = ProtocolConverter(this);
}
diff --git a/pkg/dds/lib/src/dap/adapters/dart_cli_adapter.dart b/pkg/dds/lib/src/dap/adapters/dart_cli_adapter.dart
index a0d23d8..3dca392 100644
--- a/pkg/dds/lib/src/dap/adapters/dart_cli_adapter.dart
+++ b/pkg/dds/lib/src/dap/adapters/dart_cli_adapter.dart
@@ -40,9 +40,7 @@
enableDds: enableDds,
enableAuthCodes: enableAuthCodes,
logger: logger,
- ) {
- channel.closed.then((_) => shutdown());
- }
+ );
/// Whether the VM Service closing should be used as a signal to terminate the
/// debug session.
diff --git a/pkg/dds/lib/src/dap/adapters/dart_test_adapter.dart b/pkg/dds/lib/src/dap/adapters/dart_test_adapter.dart
index 0417245..9e517da 100644
--- a/pkg/dds/lib/src/dap/adapters/dart_test_adapter.dart
+++ b/pkg/dds/lib/src/dap/adapters/dart_test_adapter.dart
@@ -11,7 +11,6 @@
import 'package:vm_service/vm_service.dart' as vm;
import '../logging.dart';
-import '../protocol_common.dart';
import '../protocol_stream.dart';
import '../stream_transformers.dart';
import 'dart.dart';
@@ -20,7 +19,7 @@
/// A DAP Debug Adapter for running and debugging Dart test scripts.
class DartTestDebugAdapter extends DartDebugAdapter<DartLaunchRequestArguments,
DartAttachRequestArguments>
- with PidTracker, VmServiceInfoFileUtils, PackageConfigUtils {
+ with PidTracker, VmServiceInfoFileUtils, PackageConfigUtils, TestAdapter {
Process? _process;
@override
@@ -41,9 +40,7 @@
enableDds: enableDds,
enableAuthCodes: enableAuthCodes,
logger: logger,
- ) {
- channel.closed.then((_) => shutdown());
- }
+ );
/// Whether the VM Service closing should be used as a signal to terminate the
/// debug session.
@@ -180,7 +177,7 @@
// package:test to have captured output and sent it in "print" events).
try {
final payload = jsonDecode(data);
- sendEvent(RawEventBody(payload), eventType: 'dart.testNotification');
+ sendTestEvents(payload);
} catch (e) {
sendOutput('stdout', data);
}
diff --git a/pkg/dds/lib/src/dap/adapters/mixins.dart b/pkg/dds/lib/src/dap/adapters/mixins.dart
index 8c73716..3b9991a 100644
--- a/pkg/dds/lib/src/dap/adapters/mixins.dart
+++ b/pkg/dds/lib/src/dap/adapters/mixins.dart
@@ -10,6 +10,7 @@
import 'package:pedantic/pedantic.dart';
import '../logging.dart';
+import '../protocol_common.dart';
/// A mixin providing some utility functions for locating/working with
/// package_config.json files.
@@ -66,6 +67,90 @@
}
}
+/// A mixin providing some utility functions for adapters that run tests and
+/// provides some basic test reporting since otherwise nothing is printed when
+/// using the JSON test reporter.
+mixin TestAdapter {
+ static const _tick = "✓";
+ static const _cross = "✖";
+
+ /// Test names by testID.
+ ///
+ /// Stored in testStart so that they can be looked up in testDone.
+ Map<int, String> _testNames = {};
+
+ void sendEvent(EventBody body, {String? eventType});
+ void sendOutput(String category, String message);
+
+ void sendTestEvents(Object testNotification) {
+ // Send the JSON package as a raw notification so the client can interpret
+ // the results (for example to populate a test tree).
+ sendEvent(RawEventBody(testNotification),
+ eventType: 'dart.testNotification');
+
+ // Additionally, send a textual output so that the user also has visible
+ // output in the Debug Console.
+ if (testNotification is Map<String, Object?>) {
+ sendTestTextOutput(testNotification);
+ }
+ }
+
+ /// Sends textual output for tests, including pass/fail and test output.
+ ///
+ /// This is sent so that clients that do not handle the package:test JSON
+ /// events still get some useful textual output in their Debug Consoles.
+ void sendTestTextOutput(Map<String, Object?> testNotification) {
+ switch (testNotification['type']) {
+ case 'testStart':
+ // When a test starts, capture its name by ID so we can get it back when
+ // testDone comes.
+ final test = testNotification['test'] as Map<String, Object?>?;
+ if (test != null) {
+ final testID = test['id'] as int?;
+ final testName = test['name'] as String?;
+ if (testID != null && testName != null) {
+ _testNames[testID] = testName;
+ }
+ }
+ break;
+
+ case 'testDone':
+ // Print the status of completed tests with a tick/cross.
+ if (testNotification['hidden'] == true) {
+ break;
+ }
+ final testID = testNotification['testID'] as int?;
+ if (testID != null) {
+ final testName = _testNames[testID];
+ if (testName != null) {
+ final symbol =
+ testNotification['result'] == "success" ? _tick : _cross;
+ sendOutput('console', '$symbol $testName\n');
+ }
+ }
+ break;
+
+ case 'print':
+ final message = testNotification['message'] as String?;
+ if (message != null) {
+ sendOutput('stdout', '${message.trimRight()}\n');
+ }
+ break;
+
+ case 'error':
+ final error = testNotification['error'] as String?;
+ final stack = testNotification['stackTrace'] as String?;
+ if (error != null) {
+ sendOutput('stderr', '${error.trimRight()}\n');
+ }
+ if (stack != null) {
+ sendOutput('stderr', '${stack.trimRight()}\n');
+ }
+ break;
+ }
+ }
+}
+
/// A mixin providing some utility functions for working with vm-service-info
/// files such as ensuring a temp folder exists to create them in, and waiting
/// for the file to become valid parsable JSON.
diff --git a/pkg/dds/test/dap/integration/dart_test_test.dart b/pkg/dds/test/dap/integration/dart_test_test.dart
index 02e980e..de25a7e 100644
--- a/pkg/dds/test/dap/integration/dart_test_test.dart
+++ b/pkg/dds/test/dap/integration/dart_test_test.dart
@@ -43,7 +43,6 @@
'testDone',
'testStart',
'error',
- 'print',
'testDone',
]),
);
@@ -59,15 +58,14 @@
testFile.path,
noDebug: true,
cwd: dap.testAppDir.path,
+ args: ['--chain-stack-traces'], // to suppress warnings in the output
),
);
// Check the printed output shows that the run finished, and it's exit
// code (which is 1 due to the failing test).
final output = outputEvents.output.map((e) => e.output).join();
- expectLines(output, [
- 'Exited (1).',
- ]);
+ expectLines(output, simpleTestProgramExpectedOutput);
expectStandardSimpleTestResults(outputEvents);
});
@@ -86,7 +84,7 @@
// if it wants to run a subset of tests.
args: [
'--plain-name',
- 'passing',
+ 'passing test',
],
),
);
@@ -96,8 +94,8 @@
.map((e) => (e['test'] as Map<String, Object?>)['name'])
.toList();
- expect(testsNames, contains('group passing'));
- expect(testsNames, isNot(contains('group failing')));
+ expect(testsNames, contains('group 1 passing test'));
+ expect(testsNames, isNot(contains('group 1 failing test')));
});
test('can hit and resume from a breakpoint', () async {
@@ -108,13 +106,12 @@
// Collect output and test events while running the script.
final outputEvents = await client.collectTestOutput(
// When launching, hit a breakpoint and resume.
- start: () => client
- .hitBreakpoint(
- testFile,
- breakpointLine,
- cwd: dap.testAppDir.path,
- )
- .then((stop) => client.continue_(stop.threadId!)),
+ start: () => client.hitBreakpoint(
+ testFile,
+ breakpointLine,
+ cwd: dap.testAppDir.path,
+ args: ['--chain-stack-traces'], // to suppress warnings in the output
+ ).then((stop) => client.continue_(stop.threadId!)),
);
// Check the usual output and test events to ensure breaking/resuming did
@@ -123,7 +120,7 @@
.map((e) => e.output)
.skipWhile(dapVmServiceBannerPattern.hasMatch)
.join();
- expectLines(output, ['Exited (1).']);
+ expectLines(output, simpleTestProgramExpectedOutput);
expectStandardSimpleTestResults(outputEvents);
});
diff --git a/pkg/dds/test/dap/integration/test_client.dart b/pkg/dds/test/dap/integration/test_client.dart
index e4e5010..78b145d 100644
--- a/pkg/dds/test/dap/integration/test_client.dart
+++ b/pkg/dds/test/dap/integration/test_client.dart
@@ -484,6 +484,7 @@
int line, {
String? condition,
String? cwd,
+ List<String>? args,
Future<Response> Function()? launch,
}) async {
final stop = expectStop('breakpoint', file: file, line: line);
@@ -496,7 +497,7 @@
breakpoints: [SourceBreakpoint(line: line, condition: condition)],
),
),
- launch?.call() ?? this.launch(file.path, cwd: cwd),
+ launch?.call() ?? this.launch(file.path, cwd: cwd, args: args),
], eagerError: true);
return stop;
diff --git a/pkg/dds/test/dap/integration/test_scripts.dart b/pkg/dds/test/dap/integration/test_scripts.dart
index a382781..2b24727 100644
--- a/pkg/dds/test/dap/integration/test_scripts.dart
+++ b/pkg/dds/test/dap/integration/test_scripts.dart
@@ -2,6 +2,8 @@
// 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.
+import 'package:test/test.dart';
+
/// A marker used in some test scripts/tests for where to set breakpoints.
const breakpointMarker = '// BREAKPOINT';
@@ -106,17 +108,33 @@
import 'package:test/test.dart';
void main() {
- group('group', () {
- test('passing', () {
+ group('group 1', () {
+ test('passing test', () {
expect(1, equals(1)); $breakpointMarker
});
- test('failing', () {
+ test('failing test', () {
expect(1, equals(2));
});
});
}
''';
+/// Matches for the expected output of [simpleTestProgram].
+final simpleTestProgramExpectedOutput = [
+ // First test
+ '✓ group 1 passing test',
+ // Second test
+ 'Expected: <2>',
+ ' Actual: <1>',
+ // These lines contain paths, so just check the non-path parts.
+ allOf(startsWith('package:test_api'), endsWith('expect')),
+ endsWith('main.<fn>.<fn>'),
+ '✖ group 1 failing test',
+ // Exit
+ '',
+ 'Exited (1).',
+];
+
/// A simple Dart script that throws in user code.
const simpleThrowingProgram = r'''
void main(List<String> args) async {
diff --git a/pkg/dds/test/dap/integration/test_support.dart b/pkg/dds/test/dap/integration/test_support.dart
index 4215bd3..9201798 100644
--- a/pkg/dds/test/dap/integration/test_support.dart
+++ b/pkg/dds/test/dap/integration/test_support.dart
@@ -43,12 +43,12 @@
/// by the VM when not using --write-service-info.
final vmServiceBannerPattern = RegExp(r'Observatory listening on ([^\s]+)\s');
-/// Expects [actual] to equal the lines [expected], ignoring differences in line
-/// endings and trailing whitespace.
-void expectLines(String actual, List<String> expected) {
+/// Expects the lines in [actual] to match the relevant matcher in [expected],
+/// ignoring differences in line endings and trailing whitespace.
+void expectLines(String actual, List<Object> expected) {
expect(
- actual.replaceAll('\r\n', '\n').trim(),
- equals(expected.join('\n').trim()),
+ actual.replaceAll('\r\n', '\n').trim().split('\n'),
+ equals(expected),
);
}
diff --git a/pkg/front_end/messages.yaml b/pkg/front_end/messages.yaml
index 49d1fa6..d3859ab 100644
--- a/pkg/front_end/messages.yaml
+++ b/pkg/front_end/messages.yaml
@@ -5,9 +5,9 @@
# Each entry in this map corresponds to a diagnostic message. Ideally, each
# entry contains three parts:
#
-# 1. A message template (template).
+# 1. A message template (problemMessage).
#
-# 2. A suggestion for how to correct the problem (tip).
+# 2. A suggestion for how to correct the problem (correctionMessage).
#
# 3. Examples that produce the message (one of expression, statement,
# declaration, member, script, bytes or external). Note that 'external'
@@ -53,11 +53,11 @@
# In some cases a message is internal to the frontend, and no meaningful
# analyzer code can be provided. In such cases set `frontendInternal: true`.
#
-# ## Parameter Substitution in Template and Tip
+# ## Parameter Substitution in problemMessage and correctionMessage
#
-# The fields `template` and `tip` are subject to parameter substitution. When
-# the compiler reports a problem, it may also specify a map with the following
-# keys to be substituted into the message:
+# The fields `problemMessage` and `correctionMessage` are subject to parameter
+# substitution. When the compiler reports a problem, it may also specify a map
+# with the following keys to be substituted into the message:
#
# `#character` a Unicode character.
#
@@ -99,155 +99,155 @@
# width N and with M fraction digits.
AsciiControlCharacter:
- template: "The control character #unicode can only be used in strings and comments."
+ problemMessage: "The control character #unicode can only be used in strings and comments."
analyzerCode: ILLEGAL_CHARACTER
expression: "\x1b 1"
ConstEvalStartingPoint:
- template: "Constant evaluation error:"
+ problemMessage: "Constant evaluation error:"
ConstEvalContext:
- template: "While analyzing:"
+ problemMessage: "While analyzing:"
ConstEvalDuplicateElement:
- template: "The element '#constant' conflicts with another existing element in the set."
+ problemMessage: "The element '#constant' conflicts with another existing element in the set."
analyzerCode: EQUAL_ELEMENTS_IN_CONST_SET
ConstEvalDuplicateKey:
- template: "The key '#constant' conflicts with another existing key in the map."
+ problemMessage: "The key '#constant' conflicts with another existing key in the map."
analyzerCode: EQUAL_KEYS_IN_CONST_MAP
ConstEvalElementImplementsEqual:
- template: "The element '#constant' does not have a primitive operator '=='."
+ problemMessage: "The element '#constant' does not have a primitive operator '=='."
analyzerCode: CONST_SET_ELEMENT_TYPE_IMPLEMENTS_EQUALS
ConstEvalKeyImplementsEqual:
- template: "The key '#constant' does not have a primitive operator '=='."
+ problemMessage: "The key '#constant' does not have a primitive operator '=='."
analyzerCode: CONST_MAP_KEY_EXPRESSION_TYPE_IMPLEMENTS_EQUALS
ConstEvalCaseImplementsEqual:
- template: "Case expression '#constant' does not have a primitive operator '=='."
+ problemMessage: "Case expression '#constant' does not have a primitive operator '=='."
ConstEvalInvalidType:
- template: "Expected constant '#constant' to be of type '#type', but was of type '#type2'."
+ problemMessage: "Expected constant '#constant' to be of type '#type', but was of type '#type2'."
ConstEvalInvalidBinaryOperandType:
- template: "Binary operator '#stringOKEmpty' on '#constant' requires operand of type '#type', but was of type '#type2'."
+ problemMessage: "Binary operator '#stringOKEmpty' on '#constant' requires operand of type '#type', but was of type '#type2'."
ConstEvalInvalidEqualsOperandType:
- template: "Binary operator '==' requires receiver constant '#constant' of type 'Null', 'bool', 'int', 'double', or 'String', but was of type '#type'."
+ problemMessage: "Binary operator '==' requires receiver constant '#constant' of type 'Null', 'bool', 'int', 'double', or 'String', but was of type '#type'."
ConstEvalZeroDivisor:
- template: "Binary operator '#string' on '#string2' requires non-zero divisor, but divisor was '0'."
+ problemMessage: "Binary operator '#string' on '#string2' requires non-zero divisor, but divisor was '0'."
analyzerCode: CONST_EVAL_THROWS_IDBZE
ConstEvalNegativeShift:
- template: "Binary operator '#string' on '#string2' requires non-negative operand, but was '#string3'."
+ problemMessage: "Binary operator '#string' on '#string2' requires non-negative operand, but was '#string3'."
ConstEvalTruncateError:
- template: "Binary operator '#string ~/ #string2' results is Infinity or NaN."
+ problemMessage: "Binary operator '#string ~/ #string2' results is Infinity or NaN."
ConstEvalNonNull:
- template: "Constant expression must be non-null."
+ problemMessage: "Constant expression must be non-null."
ConstEvalGetterNotFound:
- template: "Variable get not found: '#nameOKEmpty'"
+ problemMessage: "Variable get not found: '#nameOKEmpty'"
ConstEvalInvalidMethodInvocation:
- template: "The method '#stringOKEmpty' can't be invoked on '#constant' in a constant expression."
+ problemMessage: "The method '#stringOKEmpty' can't be invoked on '#constant' in a constant expression."
analyzerCode: UNDEFINED_OPERATOR
ConstEvalInvalidPropertyGet:
- template: "The property '#stringOKEmpty' can't be accessed on '#constant' in a constant expression."
+ problemMessage: "The property '#stringOKEmpty' can't be accessed on '#constant' in a constant expression."
analyzerCode: CONST_EVAL_THROWS_EXCEPTION
ConstEvalInvalidStringInterpolationOperand:
- template: |
+ problemMessage: |
The constant value '#constant' can't be used as part of a string interpolation in a constant expression.
Only values of type 'null', 'bool', 'int', 'double', or 'String' can be used.
analyzerCode: CONST_EVAL_TYPE_BOOL_NUM_STRING
ConstEvalInvalidStaticInvocation:
- template: "The invocation of '#nameOKEmpty' is not allowed in a constant expression."
+ problemMessage: "The invocation of '#nameOKEmpty' is not allowed in a constant expression."
analyzerCode: CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
ConstEvalInvalidSymbolName:
- template: "The symbol name must be a valid public Dart member name, public constructor name, or library name, optionally qualified, but was '#constant'."
+ problemMessage: "The symbol name must be a valid public Dart member name, public constructor name, or library name, optionally qualified, but was '#constant'."
analyzerCode: CONST_EVAL_THROWS_EXCEPTION
ConstEvalFailedAssertion:
- template: "This assertion failed."
+ problemMessage: "This assertion failed."
analyzerCode: CONST_EVAL_THROWS_EXCEPTION
ConstEvalFailedAssertionWithMessage:
- template: "This assertion failed with message: #stringOKEmpty"
+ problemMessage: "This assertion failed with message: #stringOKEmpty"
analyzerCode: CONST_EVAL_THROWS_EXCEPTION
ConstEvalNonConstantVariableGet:
- template: "The variable '#nameOKEmpty' is not a constant, only constant expressions are allowed."
+ problemMessage: "The variable '#nameOKEmpty' is not a constant, only constant expressions are allowed."
analyzerCode: NON_CONSTANT_VALUE_IN_INITIALIZER
ConstEvalDeferredLibrary:
- template: >
+ problemMessage: >
'#nameOKEmpty' can't be used in a constant expression because it's marked as
'deferred' which means it isn't available until loaded.
- tip: >
+ correctionMessage: >
Try moving the constant from the deferred library, or removing 'deferred'
from the import.
analyzerCode: INVALID_ANNOTATION_CONSTANT_VALUE_FROM_DEFERRED_LIBRARY
ConstEvalFreeTypeParameter:
- template: "The type '#type' is not a constant because it depends on a type parameter, only instantiated types are allowed."
+ problemMessage: "The type '#type' is not a constant because it depends on a type parameter, only instantiated types are allowed."
ConstEvalCircularity:
- template: "Constant expression depends on itself."
+ problemMessage: "Constant expression depends on itself."
analyzerCode: RECURSIVE_COMPILE_TIME_CONSTANT
ConstEvalNullValue:
- template: "Null value during constant evaluation."
+ problemMessage: "Null value during constant evaluation."
analyzerCode: CONST_EVAL_THROWS_EXCEPTION
ConstEvalNotListOrSetInSpread:
- template: "Only lists and sets can be used in spreads in constant lists and sets."
+ problemMessage: "Only lists and sets can be used in spreads in constant lists and sets."
analyzerCode: CONST_SPREAD_EXPECTED_LIST_OR_SET
ConstEvalNotMapInSpread:
- template: "Only maps can be used in spreads in constant maps."
+ problemMessage: "Only maps can be used in spreads in constant maps."
analyzerCode: CONST_SPREAD_EXPECTED_MAP
ConstEvalExtension:
- template: "Extension operations can't be used in constant expressions."
+ problemMessage: "Extension operations can't be used in constant expressions."
analyzerCode: NOT_CONSTANT_EXPRESSION
ConstEvalExternalConstructor:
- template: "External constructors can't be evaluated in constant expressions."
+ problemMessage: "External constructors can't be evaluated in constant expressions."
ConstEvalExternalFactory:
- template: "External factory constructors can't be evaluated in constant expressions."
+ problemMessage: "External factory constructors can't be evaluated in constant expressions."
ConstEvalUnevaluated:
- template: "Couldn't evaluate constant expression."
+ problemMessage: "Couldn't evaluate constant expression."
ConstEvalError:
- template: "Error evaluating constant expression: #string"
+ problemMessage: "Error evaluating constant expression: #string"
ConstEvalUnhandledCoreException:
- template: "Unhandled core exception: #stringOKEmpty"
+ problemMessage: "Unhandled core exception: #stringOKEmpty"
ConstEvalUnhandledException:
- template: "Unhandled exception: #constant"
+ problemMessage: "Unhandled exception: #constant"
NotConstantExpression:
- template: "#string is not a constant expression."
+ problemMessage: "#string is not a constant expression."
analyzerCode: NOT_CONSTANT_EXPRESSION
NotAConstantExpression:
- template: "Not a constant expression."
+ problemMessage: "Not a constant expression."
analyzerCode: NOT_CONSTANT_EXPRESSION
MissingExplicitConst:
- template: "Constant expression expected."
- tip: "Try inserting 'const'."
+ problemMessage: "Constant expression expected."
+ correctionMessage: "Try inserting 'const'."
analyzerCode: NOT_CONSTANT_EXPRESSION
script: >
class A {
@@ -256,48 +256,48 @@
}
NonAsciiIdentifier:
- template: "The non-ASCII character '#character' (#unicode) can't be used in identifiers, only in strings and comments."
- tip: "Try using an US-ASCII letter, a digit, '_' (an underscore), or '$' (a dollar sign)."
+ problemMessage: "The non-ASCII character '#character' (#unicode) can't be used in identifiers, only in strings and comments."
+ correctionMessage: "Try using an US-ASCII letter, a digit, '_' (an underscore), or '$' (a dollar sign)."
analyzerCode: ILLEGAL_CHARACTER
expression: "å"
NonAsciiWhitespace:
- template: "The non-ASCII space character #unicode can only be used in strings and comments."
+ problemMessage: "The non-ASCII space character #unicode can only be used in strings and comments."
analyzerCode: ILLEGAL_CHARACTER
expression: "\u2028 1"
Encoding:
- template: "Unable to decode bytes as UTF-8."
+ problemMessage: "Unable to decode bytes as UTF-8."
bytes: [255]
ExperimentNotEnabled:
index: 48
- template: "This requires the '#string' language feature to be enabled."
- tip: "Try updating your pubspec.yaml to set the minimum SDK constraint to #string2 or higher, and running 'pub get'."
+ problemMessage: "This requires the '#string' language feature to be enabled."
+ correctionMessage: "Try updating your pubspec.yaml to set the minimum SDK constraint to #string2 or higher, and running 'pub get'."
analyzerCode: ParserErrorCode.EXPERIMENT_NOT_ENABLED
ExperimentNotEnabledNoFlag:
- template: "This requires the null safety language feature, which is experimental."
- tip: "You can enable the experiment using the '--enable-experiment=non-nullable' command line option."
+ problemMessage: "This requires the null safety language feature, which is experimental."
+ correctionMessage: "You can enable the experiment using the '--enable-experiment=non-nullable' command line option."
analyzerCode: ParserErrorCode.EXPERIMENT_NOT_ENABLED
ExperimentNotEnabledNoFlagInvalidLanguageVersion:
- template: "This requires the null safety language feature, which is experimental and requires language version of #string2 or higher."
- tip: "You can enable the experiment using the '--enable-experiment=non-nullable' command line option."
+ problemMessage: "This requires the null safety language feature, which is experimental and requires language version of #string2 or higher."
+ correctionMessage: "You can enable the experiment using the '--enable-experiment=non-nullable' command line option."
analyzerCode: ParserErrorCode.EXPERIMENT_NOT_ENABLED
ExperimentDisabled:
- template: "This requires the '#string' language feature to be enabled."
- tip: "The feature is on by default but is currently disabled, maybe because the '--enable-experiment=no-#string' command line option is passed."
+ problemMessage: "This requires the '#string' language feature to be enabled."
+ correctionMessage: "The feature is on by default but is currently disabled, maybe because the '--enable-experiment=no-#string' command line option is passed."
analyzerCode: ParserErrorCode.EXPERIMENT_NOT_ENABLED
ExperimentDisabledInvalidLanguageVersion:
- template: "This requires the null safety language feature, which requires language version of #string2 or higher."
+ problemMessage: "This requires the null safety language feature, which requires language version of #string2 or higher."
analyzerCode: ParserErrorCode.EXPERIMENT_NOT_ENABLED
EmptyNamedParameterList:
- template: "Named parameter lists cannot be empty."
- tip: "Try adding a named parameter to the list."
+ problemMessage: "Named parameter lists cannot be empty."
+ correctionMessage: "Try adding a named parameter to the list."
analyzerCode: "MISSING_IDENTIFIER"
script: >
foo({}) {}
@@ -307,8 +307,8 @@
}
EmptyOptionalParameterList:
- template: "Optional parameter lists cannot be empty."
- tip: "Try adding an optional parameter to the list."
+ problemMessage: "Optional parameter lists cannot be empty."
+ correctionMessage: "Try adding an optional parameter to the list."
analyzerCode: "MISSING_IDENTIFIER"
script: >
foo([]) {}
@@ -319,38 +319,38 @@
ExpectedElseOrComma:
index: 46
- template: "Expected 'else' or comma."
+ problemMessage: "Expected 'else' or comma."
analyzerCode: ParserErrorCode.EXPECTED_ELSE_OR_COMMA
ExpectedBlock:
- template: "Expected a block."
- tip: "Try adding {}."
+ problemMessage: "Expected a block."
+ correctionMessage: "Try adding {}."
analyzerCode: EXPECTED_TOKEN
script: "try finally {}"
ExpectedBlockToSkip:
- template: "Expected a function body or '=>'."
+ problemMessage: "Expected a function body or '=>'."
# TODO(ahe): In some scenarios, we can suggest removing the 'static' keyword.
- tip: "Try adding {}."
+ correctionMessage: "Try adding {}."
analyzerCode: MISSING_FUNCTION_BODY
script: "main();"
ExpectedBody:
- template: "Expected a function body or '=>'."
+ problemMessage: "Expected a function body or '=>'."
# TODO(ahe): In some scenarios, we can suggest removing the 'static' keyword.
- tip: "Try adding {}."
+ correctionMessage: "Try adding {}."
analyzerCode: MISSING_FUNCTION_BODY
script: "main();"
ExpectedStatement:
index: 29
- template: "Expected a statement."
+ problemMessage: "Expected a statement."
analyzerCode: ParserErrorCode.MISSING_STATEMENT
statement: "void;"
ExpectedButGot:
# Also see ExpectedAfterButGot and ExpectedInstead
- template: "Expected '#string' before this."
+ problemMessage: "Expected '#string' before this."
# Consider the second example below: the parser expects a ')' before 'y', but
# a ',' would also have worked. We don't have enough information to give a
# good suggestion.
@@ -361,7 +361,7 @@
ExpectedAfterButGot:
# Also see ExpectedButGot and ExpectedInstead
- template: "Expected '#string' after this."
+ problemMessage: "Expected '#string' after this."
# This is an alternative to ExpectedButGot when it's better for the error to be
# associated with the last consumed token rather than the token being parsed.
# Doing so can make it cognitively easier for the user to understand and fix.
@@ -387,7 +387,7 @@
ExpectedInstead:
# Also see ExpectedButGot and ExpectedAfterButGot
index: 41
- template: "Expected '#string' instead of this."
+ problemMessage: "Expected '#string' instead of this."
# This is an alternative to ExpectedButGot when the last consumed token
# should be replaced with a different token.
#
@@ -409,14 +409,14 @@
MultipleLibraryDirectives:
index: 27
- template: "Only one library directive may be declared in a file."
- tip: "Try removing all but one of the library directives."
+ problemMessage: "Only one library directive may be declared in a file."
+ correctionMessage: "Try removing all but one of the library directives."
analyzerCode: ParserErrorCode.MULTIPLE_LIBRARY_DIRECTIVES
MultipleExtends:
index: 28
- template: "Each class definition can have at most one extends clause."
- tip: "Try choosing one superclass and define your class to implement (or mix in) the others."
+ problemMessage: "Each class definition can have at most one extends clause."
+ correctionMessage: "Try choosing one superclass and define your class to implement (or mix in) the others."
analyzerCode: ParserErrorCode.MULTIPLE_EXTENDS_CLAUSES
script:
- "class B{} class C{} class A extends B extends C {}"
@@ -424,43 +424,43 @@
MultipleWith:
index: 24
- template: "Each class definition can have at most one with clause."
- tip: "Try combining all of the with clauses into a single clause."
+ problemMessage: "Each class definition can have at most one with clause."
+ correctionMessage: "Try combining all of the with clauses into a single clause."
analyzerCode: ParserErrorCode.MULTIPLE_WITH_CLAUSES
script: "class A extends B with C, D with E {}"
WithBeforeExtends:
index: 11
- template: "The extends clause must be before the with clause."
- tip: "Try moving the extends clause before the with clause."
+ problemMessage: "The extends clause must be before the with clause."
+ correctionMessage: "Try moving the extends clause before the with clause."
analyzerCode: ParserErrorCode.WITH_BEFORE_EXTENDS
script: "class B {} class C {} class A with B extends C {}"
ImplementsBeforeExtends:
index: 44
- template: "The extends clause must be before the implements clause."
- tip: "Try moving the extends clause before the implements clause."
+ problemMessage: "The extends clause must be before the implements clause."
+ correctionMessage: "Try moving the extends clause before the implements clause."
analyzerCode: ParserErrorCode.IMPLEMENTS_BEFORE_EXTENDS
script: "class A implements B extends C {}"
ImplementsBeforeOn:
index: 43
- template: "The on clause must be before the implements clause."
- tip: "Try moving the on clause before the implements clause."
+ problemMessage: "The on clause must be before the implements clause."
+ correctionMessage: "Try moving the on clause before the implements clause."
analyzerCode: ParserErrorCode.IMPLEMENTS_BEFORE_ON
script: "mixin A implements B on C {}"
ImplementsBeforeWith:
index: 42
- template: "The with clause must be before the implements clause."
- tip: "Try moving the with clause before the implements clause."
+ problemMessage: "The with clause must be before the implements clause."
+ correctionMessage: "Try moving the with clause before the implements clause."
analyzerCode: ParserErrorCode.IMPLEMENTS_BEFORE_WITH
script: "class A extends B implements C with D {}"
ImplementsRepeated:
- template: "'#name' can only be implemented once."
+ problemMessage: "'#name' can only be implemented once."
analyzerCode: IMPLEMENTS_REPEATED
- tip: "Try removing #count of the occurrences."
+ correctionMessage: "Try removing #count of the occurrences."
script:
- >-
abstract class I {}
@@ -468,65 +468,65 @@
class K implements I, J, I {}
ImplementsSuperClass:
- template: "'#name' can't be used in both 'extends' and 'implements' clauses."
+ problemMessage: "'#name' can't be used in both 'extends' and 'implements' clauses."
analyzerCode: IMPLEMENTS_SUPER_CLASS
- tip: "Try removing one of the occurrences."
+ correctionMessage: "Try removing one of the occurrences."
script:
- >-
abstract class A {}
class C extends A implements A {}
MultipleImplements:
- template: "Each class definition can have at most one implements clause."
- tip: "Try combining all of the implements clauses into a single clause."
+ problemMessage: "Each class definition can have at most one implements clause."
+ correctionMessage: "Try combining all of the implements clauses into a single clause."
analyzerCode: MULTIPLE_IMPLEMENTS_CLAUSES
script: "class A implements B implements C, D {}"
MultipleOnClauses:
index: 26
- template: "Each mixin definition can have at most one on clause."
- tip: "Try combining all of the on clauses into a single clause."
+ problemMessage: "Each mixin definition can have at most one on clause."
+ correctionMessage: "Try combining all of the on clauses into a single clause."
analyzerCode: ParserErrorCode.MULTIPLE_ON_CLAUSES
script: "mixin A on B on C, D {}"
ExtendsFutureOr:
- template: "The type 'FutureOr' can't be used in an 'extends' clause."
+ problemMessage: "The type 'FutureOr' can't be used in an 'extends' clause."
ImplementsFutureOr:
- template: "The type 'FutureOr' can't be used in an 'implements' clause."
+ problemMessage: "The type 'FutureOr' can't be used in an 'implements' clause."
ExtendsNever:
- template: "The type 'Never' can't be used in an 'extends' clause."
+ problemMessage: "The type 'Never' can't be used in an 'extends' clause."
ImplementsNever:
- template: "The type 'Never' can't be used in an 'implements' clause."
+ problemMessage: "The type 'Never' can't be used in an 'implements' clause."
ExtendsVoid:
- template: "The type 'void' can't be used in an 'extends' clause."
+ problemMessage: "The type 'void' can't be used in an 'extends' clause."
ImplementsVoid:
- template: "The type 'void' can't be used in an 'implements' clause."
+ problemMessage: "The type 'void' can't be used in an 'implements' clause."
ExpectedClassOrMixinBody:
index: 8
- template: "A #string must have a body, even if it is empty."
- tip: "Try adding an empty body."
+ problemMessage: "A #string must have a body, even if it is empty."
+ correctionMessage: "Try adding an empty body."
analyzerCode: ParserErrorCode.EXPECTED_BODY
ExpectedDeclaration:
- template: "Expected a declaration, but got '#lexeme'."
+ problemMessage: "Expected a declaration, but got '#lexeme'."
analyzerCode: EXPECTED_EXECUTABLE
ExpectedClassMember:
- template: "Expected a class member, but got '#lexeme'."
+ problemMessage: "Expected a class member, but got '#lexeme'."
analyzerCode: EXPECTED_CLASS_MEMBER
ExpectedFunctionBody:
- template: "Expected a function body, but got '#lexeme'."
+ problemMessage: "Expected a function body, but got '#lexeme'."
analyzerCode: MISSING_FUNCTION_BODY
ExpectedHexDigit:
- template: "A hex digit (0-9 or A-F) must follow '0x'."
+ problemMessage: "A hex digit (0-9 or A-F) must follow '0x'."
# No tip, seems obvious from the error message.
analyzerCode: MISSING_HEX_DIGIT
script: >
@@ -535,68 +535,68 @@
}
ExpectedIdentifier:
- template: "Expected an identifier, but got '#lexeme'."
- tip: "Try inserting an identifier before '#lexeme'."
+ problemMessage: "Expected an identifier, but got '#lexeme'."
+ correctionMessage: "Try inserting an identifier before '#lexeme'."
analyzerCode: MISSING_IDENTIFIER
script: "var = 42;"
ExpectedIdentifierButGotKeyword:
- template: "'#lexeme' can't be used as an identifier because it's a keyword."
- tip: "Try renaming this to be an identifier that isn't a keyword."
+ problemMessage: "'#lexeme' can't be used as an identifier because it's a keyword."
+ correctionMessage: "Try renaming this to be an identifier that isn't a keyword."
index: 113
analyzerCode: ParserErrorCode.EXPECTED_IDENTIFIER_BUT_GOT_KEYWORD
script: "var default = 42;"
EqualityCannotBeEqualityOperand:
index: 1
- template: "A comparison expression can't be an operand of another comparison expression."
- tip: "Try putting parentheses around one of the comparisons."
+ problemMessage: "A comparison expression can't be an operand of another comparison expression."
+ correctionMessage: "Try putting parentheses around one of the comparisons."
analyzerCode: ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND
script:
- "main() { var b = a < b < c; }"
- "main() { var b = a == b != c; }"
ExpectedOpenParens:
- template: "Expected '('."
+ problemMessage: "Expected '('."
ExpectedString:
- template: "Expected a String, but got '#lexeme'."
+ problemMessage: "Expected a String, but got '#lexeme'."
analyzerCode: EXPECTED_STRING_LITERAL
ExpectedToken:
- template: "Expected to find '#string'."
+ problemMessage: "Expected to find '#string'."
analyzerCode: EXPECTED_TOKEN
ExpectedType:
- template: "Expected a type, but got '#lexeme'."
+ problemMessage: "Expected a type, but got '#lexeme'."
analyzerCode: EXPECTED_TYPE_NAME
VarAsTypeName:
index: 61
- template: "The keyword 'var' can't be used as a type name."
+ problemMessage: "The keyword 'var' can't be used as a type name."
analyzerCode: ParserErrorCode.VAR_AS_TYPE_NAME
script:
- "class A { Map<String, var> m; }"
MissingExpressionInThrow:
index: 32
- template: "Missing expression after 'throw'."
- tip: "Add an expression after 'throw' or use 'rethrow' to throw a caught exception"
+ problemMessage: "Missing expression after 'throw'."
+ correctionMessage: "Add an expression after 'throw' or use 'rethrow' to throw a caught exception"
analyzerCode: ParserErrorCode.MISSING_EXPRESSION_IN_THROW
statement:
- "throw;"
MissingConstFinalVarOrType:
index: 33
- template: "Variables must be declared using the keywords 'const', 'final', 'var' or a type name."
- tip: "Try adding the name of the type of the variable or the keyword 'var'."
+ problemMessage: "Variables must be declared using the keywords 'const', 'final', 'var' or a type name."
+ correctionMessage: "Try adding the name of the type of the variable or the keyword 'var'."
analyzerCode: ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE
script:
- "class C { static f; }"
FunctionTypedParameterVar:
- template: "Function-typed parameters can't specify 'const', 'final' or 'var' in place of a return type."
- tip: "Try replacing the keyword with a return type."
+ problemMessage: "Function-typed parameters can't specify 'const', 'final' or 'var' in place of a return type."
+ correctionMessage: "Try replacing the keyword with a return type."
analyzerCode: FUNCTION_TYPED_PARAMETER_VAR
script:
- "void f(const x()) {}"
@@ -605,8 +605,8 @@
AbstractClassMember:
index: 51
- template: "Members of classes can't be declared to be 'abstract'."
- tip: "Try removing the 'abstract' keyword. You can add the 'abstract' keyword before the class declaration."
+ problemMessage: "Members of classes can't be declared to be 'abstract'."
+ correctionMessage: "Try removing the 'abstract' keyword. You can add the 'abstract' keyword before the class declaration."
analyzerCode: ParserErrorCode.ABSTRACT_CLASS_MEMBER
script:
- |
@@ -626,9 +626,9 @@
AbstractExternalField:
index: 110
- template: "Fields can't be declared both 'abstract' and 'external'."
+ problemMessage: "Fields can't be declared both 'abstract' and 'external'."
analyzerCode: ParserErrorCode.ABSTRACT_EXTERNAL_FIELD
- tip: "Try removing the 'abstract' or 'external' keyword."
+ correctionMessage: "Try removing the 'abstract' or 'external' keyword."
configuration: nnbd-strong
script:
- "abstract class C {abstract external var f;}"
@@ -636,31 +636,31 @@
AbstractStaticField:
index: 107
- template: "Static fields can't be declared 'abstract'."
+ problemMessage: "Static fields can't be declared 'abstract'."
analyzerCode: ParserErrorCode.ABSTRACT_STATIC_FIELD
- tip: "Try removing the 'abstract' or 'static' keyword."
+ correctionMessage: "Try removing the 'abstract' or 'static' keyword."
configuration: nnbd-strong
script:
- "abstract class C {abstract static var f;}"
AbstractExtensionField:
- template: "Extension fields can't be declared 'abstract'."
- tip: "Try removing the 'abstract' keyword."
+ problemMessage: "Extension fields can't be declared 'abstract'."
+ correctionMessage: "Try removing the 'abstract' keyword."
# Separate class and extension field handling to to support this.
# configuration: nnbd-strong
# script:
# - "extension C on int {abstract static var f;}"
AbstractFieldInitializer:
- template: "Abstract fields cannot have initializers."
- tip: "Try removing the initializer or the 'abstract' keyword."
+ problemMessage: "Abstract fields cannot have initializers."
+ correctionMessage: "Try removing the initializer or the 'abstract' keyword."
configuration: nnbd-strong
script:
- "abstract class C {abstract var f = 0;}"
AbstractFieldConstructorInitializer:
- template: "Abstract fields cannot have initializers."
- tip: "Try removing the field initializer or the 'abstract' keyword from the field declaration."
+ problemMessage: "Abstract fields cannot have initializers."
+ correctionMessage: "Try removing the field initializer or the 'abstract' keyword from the field declaration."
configuration: nnbd-strong
script:
- "abstract class C {abstract var f; C(this.f);}"
@@ -668,41 +668,41 @@
AbstractLateField:
index: 108
- template: "Abstract fields cannot be late."
+ problemMessage: "Abstract fields cannot be late."
analyzerCode: ParserErrorCode.ABSTRACT_LATE_FIELD
- tip: "Try removing the 'abstract' or 'late' keyword."
+ correctionMessage: "Try removing the 'abstract' or 'late' keyword."
configuration: nnbd-strong
script:
- "abstract class C {abstract late var f;}"
ClassInClass:
index: 53
- template: "Classes can't be declared inside other classes."
- tip: "Try moving the class to the top-level."
+ problemMessage: "Classes can't be declared inside other classes."
+ correctionMessage: "Try moving the class to the top-level."
analyzerCode: ParserErrorCode.CLASS_IN_CLASS
script:
- "class C { class B {} }"
EnumInClass:
index: 74
- template: "Enums can't be declared inside classes."
- tip: "Try moving the enum to the top-level."
+ problemMessage: "Enums can't be declared inside classes."
+ correctionMessage: "Try moving the enum to the top-level."
analyzerCode: ParserErrorCode.ENUM_IN_CLASS
script:
- "class Foo { enum Bar { Bar1, Bar2, Bar3 } }"
TypedefInClass:
index: 7
- template: "Typedefs can't be declared inside classes."
- tip: "Try moving the typedef to the top-level."
+ problemMessage: "Typedefs can't be declared inside classes."
+ correctionMessage: "Try moving the typedef to the top-level."
analyzerCode: ParserErrorCode.TYPEDEF_IN_CLASS
script:
- "abstract class C { typedef int F(int x); }"
CovariantMember:
index: 67
- template: "Getters, setters and methods can't be declared to be 'covariant'."
- tip: "Try removing the 'covariant' keyword."
+ problemMessage: "Getters, setters and methods can't be declared to be 'covariant'."
+ correctionMessage: "Try removing the 'covariant' keyword."
analyzerCode: ParserErrorCode.COVARIANT_MEMBER
script:
- "static covariant get x => 0;"
@@ -710,8 +710,8 @@
VarReturnType:
index: 12
- template: "The return type can't be 'var'."
- tip: "Try removing the keyword 'var', or replacing it with the name of the return type."
+ problemMessage: "The return type can't be 'var'."
+ correctionMessage: "Try removing the keyword 'var', or replacing it with the name of the return type."
analyzerCode: ParserErrorCode.VAR_RETURN_TYPE
script:
- "class C { var m() {} }"
@@ -719,15 +719,15 @@
ConstClass:
index: 60
- template: "Classes can't be declared to be 'const'."
- tip: "Try removing the 'const' keyword. If you're trying to indicate that instances of the class can be constants, place the 'const' keyword on the class' constructor(s)."
+ problemMessage: "Classes can't be declared to be 'const'."
+ correctionMessage: "Try removing the 'const' keyword. If you're trying to indicate that instances of the class can be constants, place the 'const' keyword on the class' constructor(s)."
analyzerCode: ParserErrorCode.CONST_CLASS
script: "const class C {}"
ConstAndFinal:
index: 58
- template: "Members can't be declared to be both 'const' and 'final'."
- tip: "Try removing either the 'const' or 'final' keyword."
+ problemMessage: "Members can't be declared to be both 'const' and 'final'."
+ correctionMessage: "Try removing either the 'const' or 'final' keyword."
analyzerCode: ParserErrorCode.CONST_AND_FINAL
declaration:
- "class C { static const final int x = 5; }"
@@ -737,8 +737,8 @@
ConflictingModifiers:
index: 59
- template: "Members can't be declared to be both '#string' and '#string2'."
- tip: "Try removing one of the keywords."
+ problemMessage: "Members can't be declared to be both '#string' and '#string2'."
+ correctionMessage: "Try removing one of the keywords."
analyzerCode: ParserErrorCode.CONFLICTING_MODIFIERS
script:
- "class C { const var x; }"
@@ -746,8 +746,8 @@
ConstFactory:
index: 62
- template: "Only redirecting factory constructors can be declared to be 'const'."
- tip: "Try removing the 'const' keyword, or replacing the body with '=' followed by a valid target."
+ problemMessage: "Only redirecting factory constructors can be declared to be 'const'."
+ correctionMessage: "Try removing the 'const' keyword, or replacing the body with '=' followed by a valid target."
analyzerCode: ParserErrorCode.CONST_FACTORY
script: |
class C {
@@ -756,8 +756,8 @@
}
ConstFactoryRedirectionToNonConst:
- template: "Constant factory constructor can't delegate to a non-constant constructor."
- tip: "Try redirecting to a different constructor or marking the target constructor 'const'."
+ problemMessage: "Constant factory constructor can't delegate to a non-constant constructor."
+ correctionMessage: "Try redirecting to a different constructor or marking the target constructor 'const'."
analyzerCode: REDIRECT_TO_NON_CONST_CONSTRUCTOR
script:
- >-
@@ -767,19 +767,19 @@
}
NonConstFactory:
- template: "Cannot invoke a non-'const' factory where a const expression is expected."
- tip: "Try using a constructor or factory that is 'const'."
+ problemMessage: "Cannot invoke a non-'const' factory where a const expression is expected."
+ correctionMessage: "Try using a constructor or factory that is 'const'."
analyzerCode: NOT_CONSTANT_EXPRESSION
NonConstConstructor:
- template: "Cannot invoke a non-'const' constructor where a const expression is expected."
- tip: "Try using a constructor or factory that is 'const'."
+ problemMessage: "Cannot invoke a non-'const' constructor where a const expression is expected."
+ correctionMessage: "Try using a constructor or factory that is 'const'."
analyzerCode: NOT_CONSTANT_EXPRESSION
ModifierOutOfOrder:
index: 56
- template: "The modifier '#string' should be before the modifier '#string2'."
- tip: "Try re-ordering the modifiers."
+ problemMessage: "The modifier '#string' should be before the modifier '#string2'."
+ correctionMessage: "Try re-ordering the modifiers."
analyzerCode: ParserErrorCode.MODIFIER_OUT_OF_ORDER
script:
- "class C { factory const C() = prefix.B.foo; }"
@@ -791,8 +791,8 @@
TypeBeforeFactory:
index: 57
- template: "Factory constructors cannot have a return type."
- tip: "Try removing the type appearing before 'factory'."
+ problemMessage: "Factory constructors cannot have a return type."
+ correctionMessage: "Try removing the type appearing before 'factory'."
analyzerCode: ParserErrorCode.TYPE_BEFORE_FACTORY
script: |
class C {
@@ -801,24 +801,24 @@
}
ConstConstructorWithBody:
- template: "A const constructor can't have a body."
- tip: "Try removing either the 'const' keyword or the body."
+ problemMessage: "A const constructor can't have a body."
+ correctionMessage: "Try removing either the 'const' keyword or the body."
analyzerCode: CONST_CONSTRUCTOR_WITH_BODY
script:
- "class C { const C() {} }"
ConstMethod:
index: 63
- template: "Getters, setters and methods can't be declared to be 'const'."
- tip: "Try removing the 'const' keyword."
+ problemMessage: "Getters, setters and methods can't be declared to be 'const'."
+ correctionMessage: "Try removing the 'const' keyword."
analyzerCode: ParserErrorCode.CONST_METHOD
script:
- "class C { const m() {} }"
CovariantAndStatic:
index: 66
- template: "Members can't be declared to be both 'covariant' and 'static'."
- tip: "Try removing either the 'covariant' or 'static' keyword."
+ problemMessage: "Members can't be declared to be both 'covariant' and 'static'."
+ correctionMessage: "Try removing either the 'covariant' or 'static' keyword."
analyzerCode: ParserErrorCode.COVARIANT_AND_STATIC
script:
- "class C { covariant static A f; }"
@@ -826,8 +826,8 @@
DuplicatedModifier:
index: 70
- template: "The modifier '#lexeme' was already specified."
- tip: "Try removing all but one occurrence of the modifier."
+ problemMessage: "The modifier '#lexeme' was already specified."
+ correctionMessage: "Try removing all but one occurrence of the modifier."
analyzerCode: ParserErrorCode.DUPLICATED_MODIFIER
script:
- "class C { const const m; }"
@@ -838,29 +838,29 @@
ExternalConstructorWithBody:
index: 87
- template: "External constructors can't have a body."
- tip: "Try removing the body of the constructor, or removing the keyword 'external'."
+ problemMessage: "External constructors can't have a body."
+ correctionMessage: "Try removing the body of the constructor, or removing the keyword 'external'."
analyzerCode: ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY
script:
- "class C { external C() {} }"
ExternalConstructorWithFieldInitializers:
- template: "An external constructor can't initialize fields."
- tip: "Try removing the field initializers, or removing the keyword 'external'."
+ problemMessage: "An external constructor can't initialize fields."
+ correctionMessage: "Try removing the field initializers, or removing the keyword 'external'."
analyzerCode: EXTERNAL_CONSTRUCTOR_WITH_FIELD_INITIALIZERS
ExternalFactoryWithBody:
index: 86
- template: "External factories can't have a body."
- tip: "Try removing the body of the factory, or removing the keyword 'external'."
+ problemMessage: "External factories can't have a body."
+ correctionMessage: "Try removing the body of the factory, or removing the keyword 'external'."
analyzerCode: ParserErrorCode.EXTERNAL_FACTORY_WITH_BODY
script:
- "class C { external factory C() {} }"
ExternalField:
index: 50
- template: "Fields can't be declared to be 'external'."
- tip: "Try removing the keyword 'external', or replacing the field by an external getter and/or setter."
+ problemMessage: "Fields can't be declared to be 'external'."
+ correctionMessage: "Try removing the keyword 'external', or replacing the field by an external getter and/or setter."
analyzerCode: ParserErrorCode.EXTERNAL_FIELD
script:
- |
@@ -869,16 +869,16 @@
ExternalFieldInitializer:
- template: "External fields cannot have initializers."
- tip: "Try removing the initializer or the 'external' keyword."
+ problemMessage: "External fields cannot have initializers."
+ correctionMessage: "Try removing the initializer or the 'external' keyword."
configuration: nnbd-strong
script:
- "external var f = 0;"
- "abstract class C {external var f = 0;}"
ExternalFieldConstructorInitializer:
- template: "External fields cannot have initializers."
- tip: "Try removing the field initializer or the 'external' keyword from the field declaration."
+ problemMessage: "External fields cannot have initializers."
+ correctionMessage: "Try removing the field initializer or the 'external' keyword from the field declaration."
configuration: nnbd-strong
script:
- "abstract class C {external var f; C(this.f);}"
@@ -886,39 +886,39 @@
ExternalLateField:
index: 109
- template: "External fields cannot be late."
+ problemMessage: "External fields cannot be late."
analyzerCode: ParserErrorCode.EXTERNAL_LATE_FIELD
- tip: "Try removing the 'external' or 'late' keyword."
+ correctionMessage: "Try removing the 'external' or 'late' keyword."
configuration: nnbd-strong
script:
- "external late var f;"
- "abstract class C {external late var f;}"
InitializerForStaticField:
- template: "'#name' isn't an instance field of this class."
+ problemMessage: "'#name' isn't an instance field of this class."
analyzerCode: INITIALIZER_FOR_STATIC_FIELD
MoreThanOneSuperInitializer:
- template: "Can't have more than one 'super' initializer."
+ problemMessage: "Can't have more than one 'super' initializer."
analyzerCode: MULTIPLE_SUPER_INITIALIZERS
script:
- "class C { C.bad() : super(), super(); }"
RedirectingConstructorWithSuperInitializer:
- template: "A redirecting constructor can't have a 'super' initializer."
+ problemMessage: "A redirecting constructor can't have a 'super' initializer."
analyzerCode: SUPER_IN_REDIRECTING_CONSTRUCTOR
script:
- "class C { C(); C.bad() : super(), this(); }"
- "class C { C(); C.bad() : this(), super(); }"
RedirectingConstructorWithMultipleRedirectInitializers:
- template: "A redirecting constructor can't have more than one redirection."
+ problemMessage: "A redirecting constructor can't have more than one redirection."
analyzerCode: MULTIPLE_REDIRECTING_CONSTRUCTOR_INVOCATIONS
script:
- "class C { C(); C.bad() : this(), this(); }"
RedirectingConstructorWithAnotherInitializer:
- template: "A redirecting constructor can't have other initializers."
+ problemMessage: "A redirecting constructor can't have other initializers."
# also ASSERT_IN_REDIRECTING_CONSTRUCTOR
analyzerCode: FIELD_INITIALIZER_REDIRECTING_CONSTRUCTOR
script:
@@ -928,15 +928,15 @@
- "class C { int? x; C(); C.bad() : this(), assert(true); }"
SuperInitializerNotLast:
- template: "Can't have initializers after 'super'."
+ problemMessage: "Can't have initializers after 'super'."
analyzerCode: INVALID_SUPER_INVOCATION
script:
- "class C { int x; C.bad() : super(), x = 5; }"
ExtraneousModifier:
index: 77
- template: "Can't have modifier '#lexeme' here."
- tip: "Try removing '#lexeme'."
+ problemMessage: "Can't have modifier '#lexeme' here."
+ correctionMessage: "Try removing '#lexeme'."
analyzerCode: ParserErrorCode.EXTRANEOUS_MODIFIER
script:
- "var String foo; main(){}"
@@ -968,8 +968,8 @@
ExtraneousModifierInExtension:
index: 98
- template: "Can't have modifier '#lexeme' in an extension."
- tip: "Try removing '#lexeme'."
+ problemMessage: "Can't have modifier '#lexeme' in an extension."
+ correctionMessage: "Try removing '#lexeme'."
analyzerCode: ParserErrorCode.INVALID_USE_OF_COVARIANT_IN_EXTENSION
hasPublishedDocs: true
script:
@@ -977,8 +977,8 @@
FinalAndCovariant:
index: 80
- template: "Members can't be declared to be both 'final' and 'covariant'."
- tip: "Try removing either the 'final' or 'covariant' keyword."
+ problemMessage: "Members can't be declared to be both 'final' and 'covariant'."
+ correctionMessage: "Try removing either the 'final' or 'covariant' keyword."
analyzerCode: ParserErrorCode.FINAL_AND_COVARIANT
script:
- "class C { covariant final f = 5; }"
@@ -986,8 +986,8 @@
FinalAndCovariantLateWithInitializer:
index: 101
- template: "Members marked 'late' with an initializer can't be declared to be both 'final' and 'covariant'."
- tip: "Try removing either the 'final' or 'covariant' keyword, or removing the initializer."
+ problemMessage: "Members marked 'late' with an initializer can't be declared to be both 'final' and 'covariant'."
+ correctionMessage: "Try removing either the 'final' or 'covariant' keyword, or removing the initializer."
analyzerCode: ParserErrorCode.FINAL_AND_COVARIANT_LATE_WITH_INITIALIZER
# Weak and strong doesn't matter in this instance.
configuration: nnbd-strong
@@ -996,8 +996,8 @@
FinalAndVar:
index: 81
- template: "Members can't be declared to be both 'final' and 'var'."
- tip: "Try removing the keyword 'var'."
+ problemMessage: "Members can't be declared to be both 'final' and 'var'."
+ correctionMessage: "Try removing the keyword 'var'."
analyzerCode: ParserErrorCode.FINAL_AND_VAR
script:
- "class C { final var x = 5; }"
@@ -1005,8 +1005,8 @@
StaticConstructor:
index: 4
- template: "Constructors can't be static."
- tip: "Try removing the keyword 'static'."
+ problemMessage: "Constructors can't be static."
+ correctionMessage: "Try removing the keyword 'static'."
analyzerCode: ParserErrorCode.STATIC_CONSTRUCTOR
script:
- "class C { static C() {} }"
@@ -1014,41 +1014,41 @@
GetterConstructor:
index: 103
- template: "Constructors can't be a getter."
- tip: "Try removing 'get'."
+ problemMessage: "Constructors can't be a getter."
+ correctionMessage: "Try removing 'get'."
analyzerCode: ParserErrorCode.GETTER_CONSTRUCTOR
script:
- "class C { get C.m() {} }"
SetterConstructor:
index: 104
- template: "Constructors can't be a setter."
- tip: "Try removing 'set'."
+ problemMessage: "Constructors can't be a setter."
+ correctionMessage: "Try removing 'set'."
analyzerCode: ParserErrorCode.SETTER_CONSTRUCTOR
script:
- "class C { set C.m(x) {} }"
StaticOperator:
index: 17
- template: "Operators can't be static."
- tip: "Try removing the keyword 'static'."
+ problemMessage: "Operators can't be static."
+ correctionMessage: "Try removing the keyword 'static'."
analyzerCode: ParserErrorCode.STATIC_OPERATOR
script:
- "class C { static operator +(int x) => x + 1; }"
BreakOutsideOfLoop:
index: 52
- template: "A break statement can't be used outside of a loop or switch statement."
- tip: "Try removing the break statement."
+ problemMessage: "A break statement can't be used outside of a loop or switch statement."
+ correctionMessage: "Try removing the break statement."
analyzerCode: ParserErrorCode.BREAK_OUTSIDE_OF_LOOP
script:
- "main() { break; }"
InvalidBreakTarget:
- template: "Can't break to '#name'."
+ problemMessage: "Can't break to '#name'."
BreakTargetOutsideFunction:
- template: "Can't break to '#name' in a different function."
+ problemMessage: "Can't break to '#name' in a different function."
analyzerCode: LABEL_IN_OUTER_SCOPE
statement: |
label: while (true) {
@@ -1060,7 +1060,7 @@
}
AnonymousBreakTargetOutsideFunction:
- template: "Can't break to a target in a different function."
+ problemMessage: "Can't break to a target in a different function."
analyzerCode: LABEL_IN_OUTER_SCOPE
statement: |
while (true) {
@@ -1071,17 +1071,17 @@
ContinueOutsideOfLoop:
index: 2
- template: "A continue statement can't be used outside of a loop or switch statement."
- tip: "Try removing the continue statement."
+ problemMessage: "A continue statement can't be used outside of a loop or switch statement."
+ correctionMessage: "Try removing the continue statement."
analyzerCode: ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP
script:
- "main() { continue; }"
InvalidContinueTarget:
- template: "Can't continue at '#name'."
+ problemMessage: "Can't continue at '#name'."
ContinueTargetOutsideFunction:
- template: "Can't continue at '#name' in a different function."
+ problemMessage: "Can't continue at '#name' in a different function."
analyzerCode: LABEL_IN_OUTER_SCOPE
statement: |
label: while (true) {
@@ -1093,7 +1093,7 @@
}
AnonymousContinueTargetOutsideFunction:
- template: "Can't continue at a target in a different function."
+ problemMessage: "Can't continue at a target in a different function."
analyzerCode: LABEL_IN_OUTER_SCOPE
statement: |
while (true) {
@@ -1103,65 +1103,65 @@
}
ContinueLabelNotTarget:
- template: "Target of continue must be a label."
+ problemMessage: "Target of continue must be a label."
analyzerCode: LABEL_UNDEFINED
ContinueWithoutLabelInCase:
index: 64
- template: "A continue statement in a switch statement must have a label as a target."
- tip: "Try adding a label associated with one of the case clauses to the continue statement."
+ problemMessage: "A continue statement in a switch statement must have a label as a target."
+ correctionMessage: "Try adding a label associated with one of the case clauses to the continue statement."
analyzerCode: ParserErrorCode.CONTINUE_WITHOUT_LABEL_IN_CASE
script:
- "main() { switch (x) {case 1: continue;} }"
DuplicateLabelInSwitchStatement:
index: 72
- template: "The label '#name' was already used in this switch statement."
- tip: "Try choosing a different name for this label."
+ problemMessage: "The label '#name' was already used in this switch statement."
+ correctionMessage: "Try choosing a different name for this label."
analyzerCode: ParserErrorCode.DUPLICATE_LABEL_IN_SWITCH_STATEMENT
statement:
- "switch (0) {l1: case 0: break; l1: case 1: break;}"
LabelNotFound:
- template: "Can't find label '#name'."
- tip: "Try defining the label, or correcting the name to match an existing label."
+ problemMessage: "Can't find label '#name'."
+ correctionMessage: "Try defining the label, or correcting the name to match an existing label."
analyzerCode: LABEL_UNDEFINED
statement:
- "switch (0) {case 0: continue L;}"
InitializedVariableInForEach:
index: 82
- template: "The loop variable in a for-each loop can't be initialized."
- tip: "Try removing the initializer, or using a different kind of loop."
+ problemMessage: "The loop variable in a for-each loop can't be initialized."
+ correctionMessage: "Try removing the initializer, or using a different kind of loop."
analyzerCode: ParserErrorCode.INITIALIZED_VARIABLE_IN_FOR_EACH
statement:
- "for (int a = 0 in <int>[10]) {}"
InvalidAwaitFor:
index: 9
- template: "The keyword 'await' isn't allowed for a normal 'for' statement."
- tip: "Try removing the keyword, or use a for-each statement."
+ problemMessage: "The keyword 'await' isn't allowed for a normal 'for' statement."
+ correctionMessage: "Try removing the keyword, or use a for-each statement."
analyzerCode: ParserErrorCode.INVALID_AWAIT_IN_FOR
script:
- "f() async {await for (int i = 0; i < 5; i++) {}}"
InvalidSyncModifier:
- template: "Invalid modifier 'sync'."
- tip: "Try replacing 'sync' with 'sync*'."
+ problemMessage: "Invalid modifier 'sync'."
+ correctionMessage: "Try replacing 'sync' with 'sync*'."
analyzerCode: MISSING_STAR_AFTER_SYNC
script: "main() sync {}"
InvalidVoid:
- template: "Type 'void' can't be used here."
- tip: "Try removing 'void' keyword or replace it with 'var', 'final', or a type."
+ problemMessage: "Type 'void' can't be used here."
+ correctionMessage: "Try removing 'void' keyword or replace it with 'var', 'final', or a type."
analyzerCode: EXPECTED_TYPE_NAME
script:
- "void x; main() {}"
- "foo(void x) {} main() { foo(null); }"
VoidWithTypeArguments:
- template: "Type 'void' can't have type arguments."
- tip: "Try removing the type arguments."
+ problemMessage: "Type 'void' can't have type arguments."
+ correctionMessage: "Try removing the type arguments."
index: 100
analyzerCode: ParserErrorCode.VOID_WITH_TYPE_ARGUMENTS
script:
@@ -1171,21 +1171,21 @@
# FieldInitializedOutsideDeclaringClass instead of this in some situations.
InvalidInitializer:
index: 90
- template: "Not a valid initializer."
- tip: "To initialize a field, use the syntax 'name = value'."
+ problemMessage: "Not a valid initializer."
+ correctionMessage: "To initialize a field, use the syntax 'name = value'."
analyzerCode: ParserErrorCode.INVALID_INITIALIZER
FieldInitializedOutsideDeclaringClass:
index: 88
- template: "A field can only be initialized in its declaring class"
- tip: "Try passing a value into the superclass constructor, or moving the initialization into the constructor body."
+ problemMessage: "A field can only be initialized in its declaring class"
+ correctionMessage: "Try passing a value into the superclass constructor, or moving the initialization into the constructor body."
analyzerCode: ParserErrorCode.FIELD_INITIALIZED_OUTSIDE_DECLARING_CLASS
script:
- "class A { int a; } class C extends A { C() : super.a = 42; }"
FinalFieldNotInitialized:
- template: "Final field '#name' is not initialized."
- tip: "Try to initialize the field in the declaration or in every constructor."
+ problemMessage: "Final field '#name' is not initialized."
+ correctionMessage: "Try to initialize the field in the declaration or in every constructor."
analyzerCode: FINAL_NOT_INITIALIZED
script: >
class C {
@@ -1193,8 +1193,8 @@
}
FinalFieldNotInitializedByConstructor:
- template: "Final field '#name' is not initialized by this constructor."
- tip: "Try to initialize the field using an initializing formal or a field initializer."
+ problemMessage: "Final field '#name' is not initialized by this constructor."
+ correctionMessage: "Try to initialize the field using an initializing formal or a field initializer."
analyzerCode: FINAL_NOT_INITIALIZED_CONSTRUCTOR_1
script: >
class C {
@@ -1204,8 +1204,8 @@
}
MissingExponent:
- template: "Numbers in exponential notation should always contain an exponent (an integer number with an optional sign)."
- tip: "Make sure there is an exponent, and remove any whitespace before it."
+ problemMessage: "Numbers in exponential notation should always contain an exponent (an integer number with an optional sign)."
+ correctionMessage: "Make sure there is an exponent, and remove any whitespace before it."
analyzerCode: MISSING_DIGIT
script: >
main() {
@@ -1213,8 +1213,8 @@
}
PositionalParameterWithEquals:
- template: "Positional optional parameters can't use ':' to specify a default value."
- tip: "Try replacing ':' with '='."
+ problemMessage: "Positional optional parameters can't use ':' to specify a default value."
+ correctionMessage: "Try replacing ':' with '='."
analyzerCode: WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER
script: >
main() {
@@ -1223,8 +1223,8 @@
}
RequiredParameterWithDefault:
- template: "Non-optional parameters can't have a default value."
- tip: "Try removing the default value or making the parameter optional."
+ problemMessage: "Non-optional parameters can't have a default value."
+ correctionMessage: "Try removing the default value or making the parameter optional."
analyzerCode: NAMED_PARAMETER_OUTSIDE_GROUP
script:
- >
@@ -1240,19 +1240,19 @@
StackOverflow:
index: 19
- template: "The file has too many nested expressions or statements."
- tip: "Try simplifying the code."
+ problemMessage: "The file has too many nested expressions or statements."
+ correctionMessage: "Try simplifying the code."
analyzerCode: ParserErrorCode.STACK_OVERFLOW
InvalidCodePoint:
- template: "The escape sequence starting with '\\u' isn't a valid code point."
+ problemMessage: "The escape sequence starting with '\\u' isn't a valid code point."
analyzerCode: INVALID_CODE_POINT
expression:
- "'\\u{110000}'"
InvalidHexEscape:
index: 40
- template: "An escape sequence starting with '\\x' must be followed by 2 hexadecimal digits."
+ problemMessage: "An escape sequence starting with '\\x' must be followed by 2 hexadecimal digits."
analyzerCode: ParserErrorCode.INVALID_HEX_ESCAPE
expression:
- "'\\x0'"
@@ -1260,7 +1260,7 @@
InvalidUnicodeEscape:
index: 38
- template: "An escape sequence starting with '\\u' must be followed by 4 hexadecimal digits or from 1 to 6 digits between '{' and '}'."
+ problemMessage: "An escape sequence starting with '\\u' must be followed by 4 hexadecimal digits or from 1 to 6 digits between '{' and '}'."
analyzerCode: ParserErrorCode.INVALID_UNICODE_ESCAPE
expression:
- "'\\u'"
@@ -1270,8 +1270,8 @@
- "'\\u{0Z}'"
UnexpectedDollarInString:
- template: "A '$' has special meaning inside a string, and must be followed by an identifier or an expression in curly braces ({})."
- tip: "Try adding a backslash (\\) to escape the '$'."
+ problemMessage: "A '$' has special meaning inside a string, and must be followed by an identifier or an expression in curly braces ({})."
+ correctionMessage: "Try adding a backslash (\\) to escape the '$'."
analyzerCode: UNEXPECTED_DOLLAR_IN_STRING
expression:
- "'$'"
@@ -1280,14 +1280,14 @@
- '"""$"""'
UnexpectedToken:
- template: "Unexpected token '#lexeme'."
+ problemMessage: "Unexpected token '#lexeme'."
analyzerCode: UNEXPECTED_TOKEN
script:
- "import 'b.dart' d as b;"
LiteralWithClassAndNew:
- template: "A #string literal can't be prefixed by 'new #lexeme'."
- tip: "Try removing 'new' and '#lexeme'"
+ problemMessage: "A #string literal can't be prefixed by 'new #lexeme'."
+ correctionMessage: "Try removing 'new' and '#lexeme'"
analyzerCode: ParserErrorCode.LITERAL_WITH_CLASS_AND_NEW
index: 115
script:
@@ -1299,8 +1299,8 @@
- "var x = new List[1];"
LiteralWithClass:
- template: "A #string literal can't be prefixed by '#lexeme'."
- tip: "Try removing '#lexeme'"
+ problemMessage: "A #string literal can't be prefixed by '#lexeme'."
+ correctionMessage: "Try removing '#lexeme'"
analyzerCode: ParserErrorCode.LITERAL_WITH_CLASS
index: 116
script:
@@ -1318,8 +1318,8 @@
- "var x = const List[1];"
LiteralWithNew:
- template: "A literal can't be prefixed by 'new'."
- tip: "Try removing 'new'"
+ problemMessage: "A literal can't be prefixed by 'new'."
+ correctionMessage: "Try removing 'new'"
analyzerCode: ParserErrorCode.LITERAL_WITH_NEW
index: 117
script:
@@ -1334,7 +1334,7 @@
- "var x = new ['a'];"
UnmatchedToken:
- template: "Can't find '#string' to match '#lexeme'."
+ problemMessage: "Can't find '#string' to match '#lexeme'."
analyzerCode: EXPECTED_TOKEN
script:
- "main("
@@ -1342,20 +1342,20 @@
- "main(){[}"
UnsupportedOperator:
- template: "The '#lexeme' operator is not supported."
+ problemMessage: "The '#lexeme' operator is not supported."
analyzerCode: UNSUPPORTED_OPERATOR
script:
- "class C { void operator ===(x) {} }"
- "class C { void operator !==(x) {} }"
UnsupportedPrefixPlus:
- template: "'+' is not a prefix operator."
- tip: "Try removing '+'."
+ problemMessage: "'+' is not a prefix operator."
+ correctionMessage: "Try removing '+'."
analyzerCode: MISSING_IDENTIFIER
expression: "+2" # No longer a valid way to write '2'
UnterminatedComment:
- template: "Comment starting with '/*' must end with '*/'."
+ problemMessage: "Comment starting with '/*' must end with '*/'."
analyzerCode: UNTERMINATED_MULTI_LINE_COMMENT
script:
main() {
@@ -1363,7 +1363,7 @@
/*
UnterminatedString:
- template: "String starting with #string must end with #string2."
+ problemMessage: "String starting with #string must end with #string2."
analyzerCode: UNTERMINATED_STRING_LITERAL
script:
- >
@@ -1397,19 +1397,19 @@
UnterminatedToken:
# This is a fall-back message that shouldn't happen.
- template: "Incomplete token."
+ problemMessage: "Incomplete token."
# Note: avoid using this template, it should only be used for debugging and
# prototyping, see [diagnostics.md](
# lib/src/fasta/diagnostics.md#avoid-composing-messages-programmatically).
Unspecified:
- template: "#string"
+ problemMessage: "#string"
StrongModeNNBDButOptOut:
- template: "A library can't opt out of null safety by default, when using sound null safety."
+ problemMessage: "A library can't opt out of null safety by default, when using sound null safety."
StrongModeNNBDPackageOptOut:
- template: |
+ problemMessage: |
Cannot run with sound null safety, because the following dependencies
don't support null safety:
@@ -1418,43 +1418,43 @@
For solutions, see https://dart.dev/go/unsound-null-safety
WeakWithStrongDillLibrary:
- template: "Loaded library is compiled with sound null safety and cannot be used in compilation for unsound null safety."
+ problemMessage: "Loaded library is compiled with sound null safety and cannot be used in compilation for unsound null safety."
StrongWithWeakDillLibrary:
- template: "Loaded library is compiled with unsound null safety and cannot be used in compilation for sound null safety."
+ problemMessage: "Loaded library is compiled with unsound null safety and cannot be used in compilation for sound null safety."
AgnosticWithStrongDillLibrary:
- template: "Loaded library is compiled with sound null safety and cannot be used in compilation for agnostic null safety."
+ problemMessage: "Loaded library is compiled with sound null safety and cannot be used in compilation for agnostic null safety."
AgnosticWithWeakDillLibrary:
- template: "Loaded library is compiled with unsound null safety and cannot be used in compilation for agnostic null safety."
+ problemMessage: "Loaded library is compiled with unsound null safety and cannot be used in compilation for agnostic null safety."
InvalidNnbdDillLibrary:
- template: "Trying to use library with invalid null safety."
+ problemMessage: "Trying to use library with invalid null safety."
AbstractNotSync:
- template: "Abstract methods can't use 'async', 'async*', or 'sync*'."
+ problemMessage: "Abstract methods can't use 'async', 'async*', or 'sync*'."
analyzerCode: NON_SYNC_ABSTRACT_METHOD
AwaitAsIdentifier:
- template: "'await' can't be used as an identifier in 'async', 'async*', or 'sync*' methods."
+ problemMessage: "'await' can't be used as an identifier in 'async', 'async*', or 'sync*' methods."
analyzerCode: ASYNC_KEYWORD_USED_AS_IDENTIFIER
AwaitNotAsync:
- template: "'await' can only be used in 'async' or 'async*' methods."
+ problemMessage: "'await' can only be used in 'async' or 'async*' methods."
analyzerCode: AWAIT_IN_WRONG_CONTEXT
BuiltInIdentifierAsType:
- template: "The built-in identifier '#lexeme' can't be used as a type."
+ problemMessage: "The built-in identifier '#lexeme' can't be used as a type."
analyzerCode: BUILT_IN_IDENTIFIER_AS_TYPE
BuiltInIdentifierInDeclaration:
- template: "Can't use '#lexeme' as a name here."
+ problemMessage: "Can't use '#lexeme' as a name here."
analyzerCode: BUILT_IN_IDENTIFIER_IN_DECLARATION
AwaitForNotAsync:
- template: "The asynchronous for-in can only be used in functions marked with 'async' or 'async*'."
- tip: "Try marking the function body with either 'async' or 'async*', or removing the 'await' before the for loop."
+ problemMessage: "The asynchronous for-in can only be used in functions marked with 'async' or 'async*'."
+ correctionMessage: "Try marking the function body with either 'async' or 'async*', or removing the 'await' before the for loop."
analyzerCode: ASYNC_FOR_IN_WRONG_CONTEXT
script: >
main(o) sync* {
@@ -1462,89 +1462,89 @@
}
ConstructorNotSync:
- template: "Constructor bodies can't use 'async', 'async*', or 'sync*'."
+ problemMessage: "Constructor bodies can't use 'async', 'async*', or 'sync*'."
analyzerCode: NON_SYNC_CONSTRUCTOR
FactoryNotSync:
- template: "Factory bodies can't use 'async', 'async*', or 'sync*'."
+ problemMessage: "Factory bodies can't use 'async', 'async*', or 'sync*'."
analyzerCode: NON_SYNC_FACTORY
GeneratorReturnsValue:
- template: "'sync*' and 'async*' can't return a value."
+ problemMessage: "'sync*' and 'async*' can't return a value."
analyzerCode: RETURN_IN_GENERATOR
InvalidInlineFunctionType:
- template: "Inline function types cannot be used for parameters in a generic function type."
- tip: "Try changing the inline function type (as in 'int f()') to a prefixed function type using the `Function` keyword (as in 'int Function() f')."
+ problemMessage: "Inline function types cannot be used for parameters in a generic function type."
+ correctionMessage: "Try changing the inline function type (as in 'int f()') to a prefixed function type using the `Function` keyword (as in 'int Function() f')."
analyzerCode: INVALID_INLINE_FUNCTION_TYPE
declaration: "typedef F = Function(int f(String x));"
SetterNotSync:
- template: "Setters can't use 'async', 'async*', or 'sync*'."
+ problemMessage: "Setters can't use 'async', 'async*', or 'sync*'."
analyzerCode: INVALID_MODIFIER_ON_SETTER
YieldAsIdentifier:
- template: "'yield' can't be used as an identifier in 'async', 'async*', or 'sync*' methods."
+ problemMessage: "'yield' can't be used as an identifier in 'async', 'async*', or 'sync*' methods."
analyzerCode: ASYNC_KEYWORD_USED_AS_IDENTIFIER
YieldNotGenerator:
- template: "'yield' can only be used in 'sync*' or 'async*' methods."
+ problemMessage: "'yield' can only be used in 'sync*' or 'async*' methods."
analyzerCode: YIELD_IN_NON_GENERATOR
OnlyTry:
index: 20
- template: "A try block must be followed by an 'on', 'catch', or 'finally' clause."
- tip: "Try adding either a catch or finally clause, or remove the try statement."
+ problemMessage: "A try block must be followed by an 'on', 'catch', or 'finally' clause."
+ correctionMessage: "Try adding either a catch or finally clause, or remove the try statement."
analyzerCode: ParserErrorCode.MISSING_CATCH_OR_FINALLY
statement: "try {}"
TypeAfterVar:
index: 89
- template: "Variables can't be declared using both 'var' and a type name."
- tip: "Try removing 'var.'"
+ problemMessage: "Variables can't be declared using both 'var' and a type name."
+ correctionMessage: "Try removing 'var.'"
analyzerCode: ParserErrorCode.VAR_AND_TYPE
AssertExtraneousArgument:
- template: "`assert` can't have more than two arguments."
+ problemMessage: "`assert` can't have more than two arguments."
PositionalAfterNamedArgument:
- template: "Place positional arguments before named arguments."
- tip: "Try moving the positional argument before the named arguments, or add a name to the argument."
+ problemMessage: "Place positional arguments before named arguments."
+ correctionMessage: "Try moving the positional argument before the named arguments, or add a name to the argument."
analyzerCode: POSITIONAL_AFTER_NAMED_ARGUMENT
ExpectedNamedArgument:
- template: "Expected named argument."
+ problemMessage: "Expected named argument."
analyzerCode: EXTRA_POSITIONAL_ARGUMENTS
AssertAsExpression:
- template: "`assert` can't be used as an expression."
+ problemMessage: "`assert` can't be used as an expression."
FunctionTypeDefaultValue:
- template: "Can't have a default value in a function type."
+ problemMessage: "Can't have a default value in a function type."
analyzerCode: DEFAULT_VALUE_IN_FUNCTION_TYPE
PrivateNamedParameter:
- template: "An optional named parameter can't start with '_'."
+ problemMessage: "An optional named parameter can't start with '_'."
analyzerCode: PRIVATE_OPTIONAL_PARAMETER
NoFormals:
- template: "A function should have formal parameters."
- tip: "Try adding '()' after '#lexeme', or add 'get' before '#lexeme' to declare a getter."
+ problemMessage: "A function should have formal parameters."
+ correctionMessage: "Try adding '()' after '#lexeme', or add 'get' before '#lexeme' to declare a getter."
analyzerCode: MISSING_FUNCTION_PARAMETERS
GetterWithFormals:
- template: "A getter can't have formal parameters."
- tip: "Try removing '(...)'."
+ problemMessage: "A getter can't have formal parameters."
+ correctionMessage: "Try removing '(...)'."
analyzerCode: GETTER_WITH_PARAMETERS
SetterWithWrongNumberOfFormals:
- template: "A setter should have exactly one formal parameter."
+ problemMessage: "A setter should have exactly one formal parameter."
analyzerCode: WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER
CatchSyntax:
index: 84
- template: "'catch' must be followed by '(identifier)' or '(identifier, identifier)'."
- tip: "No types are needed, the first is given by 'on', the second is always 'StackTrace'."
+ problemMessage: "'catch' must be followed by '(identifier)' or '(identifier, identifier)'."
+ correctionMessage: "No types are needed, the first is given by 'on', the second is always 'StackTrace'."
analyzerCode: ParserErrorCode.CATCH_SYNTAX
statement:
- "try {} catch {}"
@@ -1553,54 +1553,54 @@
CatchSyntaxExtraParameters:
index: 83
- template: "'catch' must be followed by '(identifier)' or '(identifier, identifier)'."
- tip: "No types are needed, the first is given by 'on', the second is always 'StackTrace'."
+ problemMessage: "'catch' must be followed by '(identifier)' or '(identifier, identifier)'."
+ correctionMessage: "No types are needed, the first is given by 'on', the second is always 'StackTrace'."
analyzerCode: ParserErrorCode.CATCH_SYNTAX_EXTRA_PARAMETERS
statement:
- "try {} catch (e, s, x) {}"
SuperNullAware:
index: 18
- template: "The operator '?.' cannot be used with 'super' because 'super' cannot be null."
- tip: "Try replacing '?.' with '.'"
+ problemMessage: "The operator '?.' cannot be used with 'super' because 'super' cannot be null."
+ correctionMessage: "Try replacing '?.' with '.'"
analyzerCode: ParserErrorCode.INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER
NullAwareCascadeOutOfOrder:
index: 96
- template: "The '?..' cascade operator must be first in the cascade sequence."
- tip: "Try moving the '?..' operator to be the first cascade operator in the sequence."
+ problemMessage: "The '?..' cascade operator must be first in the cascade sequence."
+ correctionMessage: "Try moving the '?..' operator to be the first cascade operator in the sequence."
analyzerCode: ParserErrorCode.NULL_AWARE_CASCADE_OUT_OF_ORDER
ConstFieldWithoutInitializer:
- template: "The const variable '#name' must be initialized."
- tip: "Try adding an initializer ('= expression') to the declaration."
+ problemMessage: "The const variable '#name' must be initialized."
+ correctionMessage: "Try adding an initializer ('= expression') to the declaration."
analyzerCode: CONST_NOT_INITIALIZED
FinalFieldWithoutInitializer:
- template: "The final variable '#name' must be initialized."
- tip: "Try adding an initializer ('= expression') to the declaration."
+ problemMessage: "The final variable '#name' must be initialized."
+ correctionMessage: "Try adding an initializer ('= expression') to the declaration."
analyzerCode: FINAL_NOT_INITIALIZED
MetadataTypeArguments:
index: 91
- template: "An annotation can't use type arguments."
+ problemMessage: "An annotation can't use type arguments."
analyzerCode: ParserErrorCode.ANNOTATION_WITH_TYPE_ARGUMENTS
MetadataTypeArgumentsUninstantiated:
index: 114
- template: "An annotation with type arguments must be followed by an argument list."
+ problemMessage: "An annotation with type arguments must be followed by an argument list."
analyzerCode: ParserErrorCode.ANNOTATION_WITH_TYPE_ARGUMENTS_UNINSTANTIATED
script:
- "@deprecated<int> class C {}"
ConstructorNotFound:
- template: "Couldn't find constructor '#name'."
+ problemMessage: "Couldn't find constructor '#name'."
analyzerCode: CONSTRUCTOR_NOT_FOUND
ConstructorWithReturnType:
index: 55
- template: "Constructors can't have a return type."
- tip: "Try removing the return type."
+ problemMessage: "Constructors can't have a return type."
+ correctionMessage: "Try removing the return type."
analyzerCode: ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE
script:
- "class C { int C() {} }"
@@ -1608,9 +1608,9 @@
ConstructorWithTypeParameters:
index: 99
- template: "Constructors can't have type parameters."
+ problemMessage: "Constructors can't have type parameters."
analyzerCode: ParserErrorCode.TYPE_PARAMETER_ON_CONSTRUCTOR
- tip: "Try removing the type parameters."
+ correctionMessage: "Try removing the type parameters."
script:
- >-
class C { C<T>() {} }
@@ -1628,8 +1628,8 @@
}
ConstructorWithTypeArguments:
- template: "A constructor invocation can't have type arguments after the constructor name."
- tip: "Try removing the type arguments or placing them after the class name."
+ problemMessage: "A constructor invocation can't have type arguments after the constructor name."
+ correctionMessage: "Try removing the type arguments or placing them after the class name."
analyzerCode: ParserErrorCode.CONSTRUCTOR_WITH_TYPE_ARGUMENTS
index: 118
script:
@@ -1637,7 +1637,7 @@
- "class C<X> { C.foo(); } bar() { C.foo<int>(); }"
ConstructorWithWrongName:
- template: "The name of a constructor must match the name of the enclosing class."
+ problemMessage: "The name of a constructor must match the name of the enclosing class."
analyzerCode: ParserErrorCode.INVALID_CONSTRUCTOR_NAME
index: 102
script:
@@ -1655,101 +1655,101 @@
}
ConstructorWithWrongNameContext:
- template: "The name of the enclosing class is '#name'."
+ problemMessage: "The name of the enclosing class is '#name'."
severity: CONTEXT
ConstructorCyclic:
- template: "Redirecting constructors can't be cyclic."
- tip: "Try to have all constructors eventually redirect to a non-redirecting constructor."
+ problemMessage: "Redirecting constructors can't be cyclic."
+ correctionMessage: "Try to have all constructors eventually redirect to a non-redirecting constructor."
analyzerCode: RECURSIVE_CONSTRUCTOR_REDIRECT
script:
- "class C { C.foo() : this.bar(); C.bar() : this.foo(); }"
FieldInitializerOutsideConstructor:
index: 79
- template: "Field formal parameters can only be used in a constructor."
- tip: "Try removing 'this.'."
+ problemMessage: "Field formal parameters can only be used in a constructor."
+ correctionMessage: "Try removing 'this.'."
analyzerCode: ParserErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR
script:
- "class C { void m(this.x); }"
RedirectionTargetNotFound:
- template: "Redirection constructor target not found: '#name'"
+ problemMessage: "Redirection constructor target not found: '#name'"
analyzerCode: REDIRECT_TO_MISSING_CONSTRUCTOR
CyclicTypedef:
- template: "The typedef '#name' has a reference to itself."
+ problemMessage: "The typedef '#name' has a reference to itself."
analyzerCode: TYPE_ALIAS_CANNOT_REFERENCE_ITSELF
TypeNotFound:
- template: "Type '#name' not found."
+ problemMessage: "Type '#name' not found."
analyzerCode: UNDEFINED_CLASS
NonInstanceTypeVariableUse:
- template: "Can only use type variables in instance methods."
+ problemMessage: "Can only use type variables in instance methods."
analyzerCode: TYPE_PARAMETER_REFERENCED_BY_STATIC
NameNotFound:
- template: "Undefined name '#name'."
+ problemMessage: "Undefined name '#name'."
analyzerCode: UNDEFINED_NAME
MemberNotFound:
- template: "Member not found: '#name'."
+ problemMessage: "Member not found: '#name'."
analyzerCode: UNDEFINED_GETTER
GetterNotFound:
- template: "Getter not found: '#name'."
+ problemMessage: "Getter not found: '#name'."
analyzerCode: UNDEFINED_GETTER
SetterNotFound:
- template: "Setter not found: '#name'."
+ problemMessage: "Setter not found: '#name'."
analyzerCode: UNDEFINED_SETTER
MethodNotFound:
- template: "Method not found: '#name'."
+ problemMessage: "Method not found: '#name'."
analyzerCode: UNDEFINED_METHOD
CandidateFound:
- template: "Found this candidate, but the arguments don't match."
+ problemMessage: "Found this candidate, but the arguments don't match."
severity: CONTEXT
CandidateFoundIsDefaultConstructor:
- template: "The class '#name' has a constructor that takes no arguments."
+ problemMessage: "The class '#name' has a constructor that takes no arguments."
severity: CONTEXT
MissingArgumentList:
- template: "Constructor invocations must have an argument list."
+ problemMessage: "Constructor invocations must have an argument list."
TooFewArguments:
- template: "Too few positional arguments: #count required, #count2 given."
+ problemMessage: "Too few positional arguments: #count required, #count2 given."
analyzerCode: NOT_ENOUGH_REQUIRED_ARGUMENTS
TooManyArguments:
- template: "Too many positional arguments: #count allowed, but #count2 found."
- tip: "Try removing the extra positional arguments."
+ problemMessage: "Too many positional arguments: #count allowed, but #count2 found."
+ correctionMessage: "Try removing the extra positional arguments."
analyzerCode: EXTRA_POSITIONAL_ARGUMENTS
NoSuchNamedParameter:
- template: "No named parameter with the name '#name'."
+ problemMessage: "No named parameter with the name '#name'."
analyzerCode: UNDEFINED_NAMED_PARAMETER
AbstractClassInstantiation:
- template: "The class '#name' is abstract and can't be instantiated."
+ problemMessage: "The class '#name' is abstract and can't be instantiated."
analyzerCode: NEW_WITH_ABSTRACT_CLASS
EnumInstantiation:
- template: "Enums can't be instantiated."
+ problemMessage: "Enums can't be instantiated."
analyzerCode: INSTANTIATE_ENUM
AbstractRedirectedClassInstantiation:
- template: "Factory redirects to class '#name', which is abstract and can't be instantiated."
+ problemMessage: "Factory redirects to class '#name', which is abstract and can't be instantiated."
analyzerCode: FACTORY_REDIRECTS_TO_ABSTRACT_CLASS
MissingImplementationNotAbstract:
- template: |
+ problemMessage: |
The non-abstract class '#name' is missing implementations for these members:
#names
- tip: |
+ correctionMessage: |
Try to either
- provide an implementation,
- inherit an implementation from a superclass or mixin,
@@ -1760,50 +1760,50 @@
- "class C {foo();}"
MissingImplementationCause:
- template: "'#name' is defined here."
+ problemMessage: "'#name' is defined here."
severity: CONTEXT
InterfaceCheck:
- template: "The implementation of '#name' in the non-abstract class '#name2' does not conform to its interface."
+ problemMessage: "The implementation of '#name' in the non-abstract class '#name2' does not conform to its interface."
NamedMixinOverride:
- template: "The mixin application class '#name' introduces an erroneous override of '#name2'."
+ problemMessage: "The mixin application class '#name' introduces an erroneous override of '#name2'."
ImplicitMixinOverride:
- template: "Applying the mixin '#name' to '#name2' introduces an erroneous override of '#name3'."
+ problemMessage: "Applying the mixin '#name' to '#name2' introduces an erroneous override of '#name3'."
ListLiteralTooManyTypeArguments:
- template: "List literal requires exactly one type argument."
+ problemMessage: "List literal requires exactly one type argument."
analyzerCode: EXPECTED_ONE_LIST_TYPE_ARGUMENTS
SetLiteralTooManyTypeArguments:
- template: "A set literal requires exactly one type argument."
+ problemMessage: "A set literal requires exactly one type argument."
MapLiteralTypeArgumentMismatch:
- template: "A map literal requires exactly two type arguments."
+ problemMessage: "A map literal requires exactly two type arguments."
analyzerCode: EXPECTED_TWO_MAP_TYPE_ARGUMENTS
SetOrMapLiteralTooManyTypeArguments:
- template: "A set or map literal requires exactly one or two type arguments, respectively."
+ problemMessage: "A set or map literal requires exactly one or two type arguments, respectively."
LoadLibraryTakesNoArguments:
- template: "'loadLibrary' takes no arguments."
+ problemMessage: "'loadLibrary' takes no arguments."
analyzerCode: LOAD_LIBRARY_TAKES_NO_ARGUMENTS
TypeArgumentMismatch:
- template: "Expected #count type arguments."
+ problemMessage: "Expected #count type arguments."
analyzerCode: WRONG_NUMBER_OF_TYPE_ARGUMENTS
NotAType:
- template: "'#name' isn't a type."
+ problemMessage: "'#name' isn't a type."
analyzerCode: NOT_A_TYPE
NotATypeContext:
- template: "This isn't a type."
+ problemMessage: "This isn't a type."
severity: CONTEXT
NotAPrefixInTypeAnnotation:
- template: "'#name.#name2' can't be used as a type because '#name' doesn't refer to an import prefix."
+ problemMessage: "'#name.#name2' can't be used as a type because '#name' doesn't refer to an import prefix."
analyzerCode: NOT_A_TYPE
declaration:
- |
@@ -1816,26 +1816,26 @@
}
FunctionUsedAsDec:
- template: "'Function' is a built-in identifier, could not used as a #name name."
+ problemMessage: "'Function' is a built-in identifier, could not used as a #name name."
script:
- class Function {}
- extension Function on int {}
- mixin Function {}
FunctionAsTypeParameter:
- template: "'Function' is a built-in identifier, could not used as a type identifier."
+ problemMessage: "'Function' is a built-in identifier, could not used as a type identifier."
script:
- class C<Function> {}
- mixin A<Function> {}
- extension A<Function> on List<Function> {}
UnresolvedPrefixInTypeAnnotation:
- template: "'#name.#name2' can't be used as a type because '#name' isn't defined."
+ problemMessage: "'#name.#name2' can't be used as a type because '#name' isn't defined."
analyzerCode: NOT_A_TYPE
statement: "T.String x;"
FastaUsageShort:
- template: |
+ problemMessage: |
Frequently used options:
-o <file> Generate the output into <file>.
@@ -1843,7 +1843,7 @@
FastaUsageLong:
# TODO(ahe): Consider if the reference to platform.dill needs to change below?
- template: |
+ problemMessage: |
Supported options:
-o <file>, --output=<file>
@@ -1931,163 +1931,163 @@
Multiple experiments can be separated by commas.
FastaCLIArgumentRequired:
- template: "Expected value after '#name'."
+ problemMessage: "Expected value after '#name'."
NamedFunctionExpression:
- template: "A function expression can't have a name."
+ problemMessage: "A function expression can't have a name."
analyzerCode: NAMED_FUNCTION_EXPRESSION
NativeClauseShouldBeAnnotation:
index: 23
- template: "Native clause in this form is deprecated."
- tip: "Try removing this native clause and adding @native() or @native('native-name') before the declaration."
+ problemMessage: "Native clause in this form is deprecated."
+ correctionMessage: "Try removing this native clause and adding @native() or @native('native-name') before the declaration."
analyzerCode: ParserErrorCode.NATIVE_CLAUSE_SHOULD_BE_ANNOTATION
ReturnTypeFunctionExpression:
- template: "A function expression can't have a return type."
+ problemMessage: "A function expression can't have a return type."
InternalProblemUnhandled:
- template: "Unhandled #string in #string2."
+ problemMessage: "Unhandled #string in #string2."
severity: INTERNAL_PROBLEM
InternalProblemUnimplemented:
- template: "Unimplemented #string."
+ problemMessage: "Unimplemented #string."
severity: INTERNAL_PROBLEM
InternalProblemUnexpected:
- template: "Expected '#string', but got '#string2'."
+ problemMessage: "Expected '#string', but got '#string2'."
severity: INTERNAL_PROBLEM
InternalProblemUnsupported:
- template: "Unsupported operation: '#name'."
+ problemMessage: "Unsupported operation: '#name'."
severity: INTERNAL_PROBLEM
InternalProblemNotFound:
- template: "Couldn't find '#name'."
+ problemMessage: "Couldn't find '#name'."
severity: INTERNAL_PROBLEM
InternalProblemNotFoundIn:
- template: "Couldn't find '#name' in '#name2'."
+ problemMessage: "Couldn't find '#name' in '#name2'."
severity: INTERNAL_PROBLEM
InternalProblemPrivateConstructorAccess:
- template: "Can't access private constructor '#name'."
+ problemMessage: "Can't access private constructor '#name'."
severity: INTERNAL_PROBLEM
InternalProblemConstructorNotFound:
- template: "No constructor named '#name' in '#uri'."
+ problemMessage: "No constructor named '#name' in '#uri'."
severity: INTERNAL_PROBLEM
InternalProblemExtendingUnmodifiableScope:
- template: "Can't extend an unmodifiable scope."
+ problemMessage: "Can't extend an unmodifiable scope."
severity: INTERNAL_PROBLEM
InternalProblemPreviousTokenNotFound:
- template: "Couldn't find previous token."
+ problemMessage: "Couldn't find previous token."
severity: INTERNAL_PROBLEM
InternalProblemStackNotEmpty:
- template: "#name.stack isn't empty:\n #string"
+ problemMessage: "#name.stack isn't empty:\n #string"
severity: INTERNAL_PROBLEM
InternalProblemAlreadyInitialized:
- template: "Attempt to set initializer on field without initializer."
+ problemMessage: "Attempt to set initializer on field without initializer."
severity: INTERNAL_PROBLEM
InternalProblemBodyOnAbstractMethod:
- template: "Attempting to set body on abstract method."
+ problemMessage: "Attempting to set body on abstract method."
severity: INTERNAL_PROBLEM
InternalProblemMissingContext:
- template: "Compiler cannot run without a compiler context."
- tip: "Are calls to the compiler wrapped in CompilerContext.runInContext?"
+ problemMessage: "Compiler cannot run without a compiler context."
+ correctionMessage: "Are calls to the compiler wrapped in CompilerContext.runInContext?"
severity: INTERNAL_PROBLEM
InternalProblemProvidedBothCompileSdkAndSdkSummary:
- template: "The compileSdk and sdkSummary options are mutually exclusive"
+ problemMessage: "The compileSdk and sdkSummary options are mutually exclusive"
severity: INTERNAL_PROBLEM
InternalProblemUriMissingScheme:
- template: "The URI '#uri' has no scheme."
+ problemMessage: "The URI '#uri' has no scheme."
severity: INTERNAL_PROBLEM
InternalProblemContextSeverity:
- template: "Non-context message has context severity: #string"
+ problemMessage: "Non-context message has context severity: #string"
severity: INTERNAL_PROBLEM
InternalProblemVerificationError:
- template: |
+ problemMessage: |
Verification of the generated program failed:
#string
severity: INTERNAL_PROBLEM
VerificationErrorOriginContext:
- template: "The node most likely is taken from here by a transformer."
+ problemMessage: "The node most likely is taken from here by a transformer."
severity: CONTEXT
InternalProblemDebugAbort:
- template: "Compilation aborted due to fatal '#name' at:\n#string"
+ problemMessage: "Compilation aborted due to fatal '#name' at:\n#string"
severity: INTERNAL_PROBLEM
InternalProblemLabelUsageInVariablesDeclaration:
- template: "Unexpected usage of label inside declaration of variables."
+ problemMessage: "Unexpected usage of label inside declaration of variables."
severity: INTERNAL_PROBLEM
InternalProblemUnfinishedTypeVariable:
- template: "Unfinished type variable '#name' found in non-source library '#uri'."
+ problemMessage: "Unfinished type variable '#name' found in non-source library '#uri'."
severity: INTERNAL_PROBLEM
InternalProblemUnsupportedNullability:
- template: "Unsupported nullability value '#string' on type '#type'."
+ problemMessage: "Unsupported nullability value '#string' on type '#type'."
severity: INTERNAL_PROBLEM
IncrementalCompilerIllegalParameter:
- template: "Illegal parameter name '#string' found during expression compilation."
+ problemMessage: "Illegal parameter name '#string' found during expression compilation."
IncrementalCompilerIllegalTypeParameter:
- template: "Illegal type parameter name '#string' found during expression compilation."
+ problemMessage: "Illegal type parameter name '#string' found during expression compilation."
DebugTrace:
- template: "Fatal '#name' at:\n#string"
+ problemMessage: "Fatal '#name' at:\n#string"
severity: IGNORED
MissingPrefixInDeferredImport:
index: 30
- template: "Deferred imports should have a prefix."
- tip: "Try adding a prefix to the import by adding an 'as' clause."
+ problemMessage: "Deferred imports should have a prefix."
+ correctionMessage: "Try adding a prefix to the import by adding an 'as' clause."
analyzerCode: ParserErrorCode.MISSING_PREFIX_IN_DEFERRED_IMPORT
DeferredAfterPrefix:
index: 68
- template: "The deferred keyword should come immediately before the prefix ('as' clause)."
- tip: "Try moving the deferred keyword before the prefix."
+ problemMessage: "The deferred keyword should come immediately before the prefix ('as' clause)."
+ correctionMessage: "Try moving the deferred keyword before the prefix."
analyzerCode: ParserErrorCode.DEFERRED_AFTER_PREFIX
DuplicateDeferred:
index: 71
- template: "An import directive can only have one 'deferred' keyword."
- tip: "Try removing all but one 'deferred' keyword."
+ problemMessage: "An import directive can only have one 'deferred' keyword."
+ correctionMessage: "Try removing all but one 'deferred' keyword."
analyzerCode: ParserErrorCode.DUPLICATE_DEFERRED
DeferredTypeAnnotation:
- template: "The type '#type' is deferred loaded via prefix '#name' and can't be used as a type annotation."
- tip: "Try removing 'deferred' from the import of '#name' or use a supertype of '#type' that isn't deferred."
+ problemMessage: "The type '#type' is deferred loaded via prefix '#name' and can't be used as a type annotation."
+ correctionMessage: "Try removing 'deferred' from the import of '#name' or use a supertype of '#type' that isn't deferred."
analyzerCode: TYPE_ANNOTATION_DEFERRED_CLASS
DuplicatePrefix:
index: 73
- template: "An import directive can only have one prefix ('as' clause)."
- tip: "Try removing all but one prefix."
+ problemMessage: "An import directive can only have one prefix ('as' clause)."
+ correctionMessage: "Try removing all but one prefix."
analyzerCode: ParserErrorCode.DUPLICATE_PREFIX
PrefixAfterCombinator:
index: 6
- template: "The prefix ('as' clause) should come before any show/hide combinators."
- tip: "Try moving the prefix before the combinators."
+ problemMessage: "The prefix ('as' clause) should come before any show/hide combinators."
+ correctionMessage: "Try moving the prefix before the combinators."
analyzerCode: ParserErrorCode.PREFIX_AFTER_COMBINATOR
DuplicatedExport:
- template: "'#name' is exported from both '#uri' and '#uri2'."
+ problemMessage: "'#name' is exported from both '#uri' and '#uri2'."
analyzerCode: AMBIGUOUS_EXPORT
script:
lib1.dart: "class A {}"
@@ -2095,10 +2095,10 @@
main.dart: "export 'lib1.dart'; export 'lib2.dart';"
DuplicatedExportInType:
- template: "'#name' is exported from both '#uri' and '#uri2'."
+ problemMessage: "'#name' is exported from both '#uri' and '#uri2'."
DuplicatedImportInType:
- template: "'#name' is imported from both '#uri' and '#uri2'."
+ problemMessage: "'#name' is imported from both '#uri' and '#uri2'."
analyzerCode: AMBIGUOUS_IMPORT
script:
lib1.dart: "class A {}"
@@ -2106,7 +2106,7 @@
main.dart: "import 'lib1.dart'; import 'lib2.dart'; A a;"
CyclicClassHierarchy:
- template: "'#name' is a supertype of itself."
+ problemMessage: "'#name' is a supertype of itself."
analyzerCode: RECURSIVE_INTERFACE_INHERITANCE
script:
- |
@@ -2120,18 +2120,18 @@
- "class C implements C {}"
ExtendingEnum:
- template: "'#name' is an enum and can't be extended or implemented."
+ problemMessage: "'#name' is an enum and can't be extended or implemented."
analyzerCode: EXTENDS_ENUM
ExtendingRestricted:
- template: "'#name' is restricted and can't be extended or implemented."
+ problemMessage: "'#name' is restricted and can't be extended or implemented."
analyzerCode: EXTENDS_DISALLOWED_CLASS
NoUnnamedConstructorInObject:
- template: "'Object' has no unnamed constructor."
+ problemMessage: "'Object' has no unnamed constructor."
IllegalAsyncGeneratorReturnType:
- template: "Functions marked 'async*' must have a return type assignable to 'Stream'."
+ problemMessage: "Functions marked 'async*' must have a return type assignable to 'Stream'."
analyzerCode: ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE
script:
- >-
@@ -2140,14 +2140,14 @@
}
IllegalAsyncGeneratorVoidReturnType:
- template: "Functions marked 'async*' can't have return type 'void'."
+ problemMessage: "Functions marked 'async*' can't have return type 'void'."
script:
- >-
void g() async* {
}
IllegalAsyncReturnType:
- template: "Functions marked 'async' must have a return type assignable to 'Future'."
+ problemMessage: "Functions marked 'async' must have a return type assignable to 'Future'."
analyzerCode: ILLEGAL_ASYNC_RETURN_TYPE
script:
- >-
@@ -2156,7 +2156,7 @@
}
IllegalSyncGeneratorReturnType:
- template: "Functions marked 'sync*' must have a return type assignable to 'Iterable'."
+ problemMessage: "Functions marked 'sync*' must have a return type assignable to 'Iterable'."
analyzerCode: ILLEGAL_SYNC_GENERATOR_RETURN_TYPE
script:
- >-
@@ -2165,7 +2165,7 @@
}
IllegalSyncGeneratorVoidReturnType:
- template: "Functions marked 'sync*' can't have return type 'void'."
+ problemMessage: "Functions marked 'sync*' can't have return type 'void'."
script:
- >-
void g() sync* {
@@ -2173,76 +2173,76 @@
IllegalMixinDueToConstructors:
# a class with a constructor is used as a mixin
- template: "Can't use '#name' as a mixin because it has constructors."
+ problemMessage: "Can't use '#name' as a mixin because it has constructors."
analyzerCode: MIXIN_DECLARES_CONSTRUCTOR # CompileTimeErrorCode
MixinDeclaresConstructor:
# a mixin declaration contains a constructor declaration
index: 95
- template: "Mixins can't declare constructors."
+ problemMessage: "Mixins can't declare constructors."
analyzerCode: ParserErrorCode.MIXIN_DECLARES_CONSTRUCTOR
IllegalMixinDueToConstructorsCause:
- template: "This constructor prevents using '#name' as a mixin."
+ problemMessage: "This constructor prevents using '#name' as a mixin."
severity: CONTEXT
ExtensionDeclaresAbstractMember:
index: 94
- template: "Extensions can't declare abstract members."
- tip: "Try providing an implementation for the member."
+ problemMessage: "Extensions can't declare abstract members."
+ correctionMessage: "Try providing an implementation for the member."
analyzerCode: ParserErrorCode.EXTENSION_DECLARES_ABSTRACT_MEMBER
hasPublishedDocs: true
ExtensionDeclaresConstructor:
index: 92
- template: "Extensions can't declare constructors."
- tip: "Try removing the constructor declaration."
+ problemMessage: "Extensions can't declare constructors."
+ correctionMessage: "Try removing the constructor declaration."
analyzerCode: ParserErrorCode.EXTENSION_DECLARES_CONSTRUCTOR
hasPublishedDocs: true
ExtensionDeclaresInstanceField:
index: 93
- template: "Extensions can't declare instance fields"
- tip: "Try removing the field declaration or making it a static field"
+ problemMessage: "Extensions can't declare instance fields"
+ correctionMessage: "Try removing the field declaration or making it a static field"
analyzerCode: ParserErrorCode.EXTENSION_DECLARES_INSTANCE_FIELD
hasPublishedDocs: true
ConflictsWithConstructor:
- template: "Conflicts with constructor '#name'."
+ problemMessage: "Conflicts with constructor '#name'."
analyzerCode: CONFLICTS_WITH_CONSTRUCTOR
ConflictsWithFactory:
- template: "Conflicts with factory '#name'."
+ problemMessage: "Conflicts with factory '#name'."
ConflictsWithMember:
- template: "Conflicts with member '#name'."
+ problemMessage: "Conflicts with member '#name'."
analyzerCode: CONFLICTS_WITH_MEMBER
ConflictsWithImplicitSetter:
- template: "Conflicts with the implicit setter of the field '#name'."
+ problemMessage: "Conflicts with the implicit setter of the field '#name'."
analyzerCode: CONFLICTS_WITH_MEMBER
ConflictsWithSetter:
- template: "Conflicts with setter '#name'."
+ problemMessage: "Conflicts with setter '#name'."
analyzerCode: CONFLICTS_WITH_MEMBER
ConflictsWithTypeVariable:
- template: "Conflicts with type variable '#name'."
+ problemMessage: "Conflicts with type variable '#name'."
analyzerCode: CONFLICTING_TYPE_VARIABLE_AND_MEMBER
ConflictsWithTypeVariableCause:
- template: "This is the type variable."
+ problemMessage: "This is the type variable."
severity: CONTEXT
ExtensionMemberConflictsWithObjectMember:
- template: "This extension member conflicts with Object member '#name'."
+ problemMessage: "This extension member conflicts with Object member '#name'."
script:
extension Extension on String {
int get noSuchMethod => 42;
}
DeclaredMemberConflictsWithInheritedMember:
- template: "Can't declare a member that conflicts with an inherited one."
+ problemMessage: "Can't declare a member that conflicts with an inherited one."
analyzerCode: DECLARED_MEMBER_CONFLICTS_WITH_INHERITED
script:
- >-
@@ -2275,15 +2275,15 @@
}
DeclaredMemberConflictsWithInheritedMemberCause:
- template: "This is the inherited member."
+ problemMessage: "This is the inherited member."
severity: CONTEXT
DeclaredMemberConflictsWithOverriddenMembersCause:
- template: "This is one of the overridden members."
+ problemMessage: "This is one of the overridden members."
severity: CONTEXT
InheritedMembersConflict:
- template: "Can't inherit members that conflict with each other."
+ problemMessage: "Can't inherit members that conflict with each other."
analyzerCode: CONFLICTS_WITH_INHERITED_MEMBER
script:
- >-
@@ -2312,60 +2312,60 @@
abstract class C extends A implements B {}
InheritedMembersConflictCause1:
- template: "This is one inherited member."
+ problemMessage: "This is one inherited member."
severity: CONTEXT
InheritedMembersConflictCause2:
- template: "This is the other inherited member."
+ problemMessage: "This is the other inherited member."
severity: CONTEXT
IllegalMixin:
- template: "The type '#name' can't be mixed in."
+ problemMessage: "The type '#name' can't be mixed in."
analyzerCode: ILLEGAL_MIXIN
OverrideTypeVariablesMismatch:
- template: "Declared type variables of '#name' doesn't match those on overridden method '#name2'."
+ problemMessage: "Declared type variables of '#name' doesn't match those on overridden method '#name2'."
analyzerCode: INVALID_METHOD_OVERRIDE_TYPE_PARAMETERS
OverrideTypeVariablesBoundMismatch:
- template: "Declared bound '#type' of type variable '#name' of '#name2' doesn't match the bound '#type2' on overridden method '#name3'."
+ problemMessage: "Declared bound '#type' of type variable '#name' of '#name2' doesn't match the bound '#type2' on overridden method '#name3'."
OverriddenMethodCause:
- template: "This is the overridden method ('#name')."
+ problemMessage: "This is the overridden method ('#name')."
severity: CONTEXT
OverrideMismatchNamedParameter:
- template: "The method '#name' doesn't have the named parameter '#name2' of overridden method '#name3'."
+ problemMessage: "The method '#name' doesn't have the named parameter '#name2' of overridden method '#name3'."
analyzerCode: INVALID_OVERRIDE_NAMED
OverrideFewerNamedArguments:
- template: "The method '#name' has fewer named arguments than those of overridden method '#name2'."
+ problemMessage: "The method '#name' has fewer named arguments than those of overridden method '#name2'."
analyzerCode: INVALID_OVERRIDE_NAMED
OverrideFewerPositionalArguments:
- template: "The method '#name' has fewer positional arguments than those of overridden method '#name2'."
+ problemMessage: "The method '#name' has fewer positional arguments than those of overridden method '#name2'."
analyzerCode: INVALID_OVERRIDE_POSITIONAL
OverrideMoreRequiredArguments:
- template: "The method '#name' has more required arguments than those of overridden method '#name2'."
+ problemMessage: "The method '#name' has more required arguments than those of overridden method '#name2'."
analyzerCode: INVALID_OVERRIDE_REQUIRED
OverrideTypeMismatchParameter:
- template: "The parameter '#name' of the method '#name2' has type '#type', which does not match the corresponding type, '#type2', in the overridden method, '#name3'."
- tip: "Change to a supertype of '#type2', or, for a covariant parameter, a subtype."
+ problemMessage: "The parameter '#name' of the method '#name2' has type '#type', which does not match the corresponding type, '#type2', in the overridden method, '#name3'."
+ correctionMessage: "Change to a supertype of '#type2', or, for a covariant parameter, a subtype."
analyzerCode: INVALID_METHOD_OVERRIDE
OverrideTypeMismatchReturnType:
- template: "The return type of the method '#name' is '#type', which does not match the return type, '#type2', of the overridden method, '#name2'."
- tip: "Change to a subtype of '#type2'."
+ problemMessage: "The return type of the method '#name' is '#type', which does not match the return type, '#type2', of the overridden method, '#name2'."
+ correctionMessage: "Change to a subtype of '#type2'."
analyzerCode: INVALID_METHOD_OVERRIDE
OverrideTypeMismatchSetter:
- template: "The field '#name' has type '#type', which does not match the corresponding type, '#type2', in the overridden setter, '#name2'."
+ problemMessage: "The field '#name' has type '#type', which does not match the corresponding type, '#type2', in the overridden setter, '#name2'."
analyzerCode: INVALID_METHOD_OVERRIDE
OverrideMismatchRequiredNamedParameter:
- template: "The required named parameter '#name' in method '#name2' is not required in overridden method '#name3'."
+ problemMessage: "The required named parameter '#name' in method '#name2' is not required in overridden method '#name3'."
configuration: nnbd-strong
script: |
abstract class A {
@@ -2376,7 +2376,7 @@
}
InvalidGetterSetterType:
- template: "The type '#type' of the getter '#name' is not a subtype of the type '#type2' of the setter '#name2'."
+ problemMessage: "The type '#type' of the getter '#name' is not a subtype of the type '#type2' of the setter '#name2'."
configuration: nnbd-strong
script: |
abstract class A {
@@ -2385,7 +2385,7 @@
}
InvalidGetterSetterTypeGetterInherited:
- template: "The type '#type' of the inherited getter '#name' is not a subtype of the type '#type2' of the setter '#name2'."
+ problemMessage: "The type '#type' of the inherited getter '#name' is not a subtype of the type '#type2' of the setter '#name2'."
configuration: nnbd-strong
script: |
abstract class A {
@@ -2396,7 +2396,7 @@
}
InvalidGetterSetterTypeFieldInherited:
- template: "The type '#type' of the inherited field '#name' is not a subtype of the type '#type2' of the setter '#name2'."
+ problemMessage: "The type '#type' of the inherited field '#name' is not a subtype of the type '#type2' of the setter '#name2'."
configuration: nnbd-strong
script: |
abstract class A {
@@ -2408,7 +2408,7 @@
}
InvalidGetterSetterTypeSetterInheritedGetter:
- template: "The type '#type' of the getter '#name' is not a subtype of the type '#type2' of the inherited setter '#name2'."
+ problemMessage: "The type '#type' of the getter '#name' is not a subtype of the type '#type2' of the inherited setter '#name2'."
configuration: nnbd-strong
script: |
abstract class A {
@@ -2419,7 +2419,7 @@
}
InvalidGetterSetterTypeSetterInheritedField:
- template: "The type '#type' of the field '#name' is not a subtype of the type '#type2' of the inherited setter '#name2'."
+ problemMessage: "The type '#type' of the field '#name' is not a subtype of the type '#type2' of the inherited setter '#name2'."
configuration: nnbd-strong
script: |
abstract class A {
@@ -2431,7 +2431,7 @@
}
InvalidGetterSetterTypeBothInheritedField:
- template: "The type '#type' of the inherited field '#name' is not a subtype of the type '#type2' of the inherited setter '#name2'."
+ problemMessage: "The type '#type' of the inherited field '#name' is not a subtype of the type '#type2' of the inherited setter '#name2'."
configuration: nnbd-strong
script: |
abstract class A {
@@ -2444,7 +2444,7 @@
abstract class C implements A, B {}
InvalidGetterSetterTypeBothInheritedGetter:
- template: "The type '#type' of the inherited getter '#name' is not a subtype of the type '#type2' of the inherited setter '#name2'."
+ problemMessage: "The type '#type' of the inherited getter '#name' is not a subtype of the type '#type2' of the inherited setter '#name2'."
configuration: nnbd-strong
script: |
abstract class A {
@@ -2456,7 +2456,7 @@
abstract class C implements A, B {}
InvalidGetterSetterTypeLegacy:
- template: "The type '#type' of the getter '#name' is not assignable to the type '#type2' of the setter '#name2'."
+ problemMessage: "The type '#type' of the getter '#name' is not assignable to the type '#type2' of the setter '#name2'."
script: |
// @dart=2.9
abstract class A {
@@ -2465,7 +2465,7 @@
}
InvalidGetterSetterTypeGetterInheritedLegacy:
- template: "The type '#type' of the inherited getter '#name' is not assignable to the type '#type2' of the setter '#name2'."
+ problemMessage: "The type '#type' of the inherited getter '#name' is not assignable to the type '#type2' of the setter '#name2'."
script: |
// @dart=2.9
abstract class A {
@@ -2476,7 +2476,7 @@
}
InvalidGetterSetterTypeFieldInheritedLegacy:
- template: "The type '#type' of the inherited field '#name' is not assignable to the type '#type2' of the setter '#name2'."
+ problemMessage: "The type '#type' of the inherited field '#name' is not assignable to the type '#type2' of the setter '#name2'."
script: |
// @dart=2.9
abstract class A {
@@ -2488,7 +2488,7 @@
}
InvalidGetterSetterTypeSetterInheritedGetterLegacy:
- template: "The type '#type' of the getter '#name' is not assignable to the type '#type2' of the inherited setter '#name2'."
+ problemMessage: "The type '#type' of the getter '#name' is not assignable to the type '#type2' of the inherited setter '#name2'."
script: |
// @dart=2.9
abstract class A {
@@ -2499,7 +2499,7 @@
}
InvalidGetterSetterTypeSetterInheritedFieldLegacy:
- template: "The type '#type' of the field '#name' is not assignable to the type '#type2' of the inherited setter '#name2'."
+ problemMessage: "The type '#type' of the field '#name' is not assignable to the type '#type2' of the inherited setter '#name2'."
script: |
// @dart=2.9
abstract class A {
@@ -2511,7 +2511,7 @@
}
InvalidGetterSetterTypeBothInheritedFieldLegacy:
- template: "The type '#type' of the inherited field '#name' is not assignable to the type '#type2' of the inherited setter '#name2'."
+ problemMessage: "The type '#type' of the inherited field '#name' is not assignable to the type '#type2' of the inherited setter '#name2'."
script: |
// @dart=2.9
abstract class A {
@@ -2524,7 +2524,7 @@
abstract class C implements A, B {}
InvalidGetterSetterTypeBothInheritedGetterLegacy:
- template: "The type '#type' of the inherited getter '#name' is not assignable to the type '#type2' of the inherited setter '#name2'."
+ problemMessage: "The type '#type' of the inherited getter '#name' is not assignable to the type '#type2' of the inherited setter '#name2'."
script: |
// @dart=2.9
abstract class A {
@@ -2536,73 +2536,73 @@
abstract class C implements A, B {}
InvalidGetterSetterTypeFieldContext:
- template: "This is the declaration of the field '#name'."
+ problemMessage: "This is the declaration of the field '#name'."
severity: CONTEXT
InvalidGetterSetterTypeGetterContext:
- template: "This is the declaration of the getter '#name'."
+ problemMessage: "This is the declaration of the getter '#name'."
severity: CONTEXT
InvalidGetterSetterTypeSetterContext:
- template: "This is the declaration of the setter '#name'."
+ problemMessage: "This is the declaration of the setter '#name'."
severity: CONTEXT
PartOfSelf:
- template: "A file can't be a part of itself."
+ problemMessage: "A file can't be a part of itself."
analyzerCode: PART_OF_NON_PART
script:
main.dart: "part 'main.dart';"
TypeVariableDuplicatedName:
- template: "A type variable can't have the same name as another."
+ problemMessage: "A type variable can't have the same name as another."
analyzerCode: DUPLICATE_DEFINITION
TypeVariableDuplicatedNameCause:
- template: "The other type variable named '#name'."
+ problemMessage: "The other type variable named '#name'."
severity: CONTEXT
TypeVariableSameNameAsEnclosing:
- template: "A type variable can't have the same name as its enclosing declaration."
+ problemMessage: "A type variable can't have the same name as its enclosing declaration."
analyzerCode: CONFLICTING_TYPE_VARIABLE_AND_CLASS
AnnotationOnTypeArgument:
- template: "Type arguments can't have annotations because they aren't declarations."
+ problemMessage: "Type arguments can't have annotations because they aren't declarations."
analyzerCode: ParserErrorCode.ANNOTATION_ON_TYPE_ARGUMENT
index: 111
script:
- "class A<E> {} class C { m() => new A<@Object() C>(); }"
AnnotationOnFunctionTypeTypeVariable:
- template: "A type variable on a function type can't have annotations."
+ problemMessage: "A type variable on a function type can't have annotations."
script: |
// @dart=2.13
main() { Function<@Object() T>() x; }
ExpectedEnumBody:
- template: "Expected a enum body, but got '#lexeme'."
- tip: "An enum definition must have a body with at least one constant name."
+ problemMessage: "Expected a enum body, but got '#lexeme'."
+ correctionMessage: "An enum definition must have a body with at least one constant name."
analyzerCode: MISSING_ENUM_BODY
script:
- "enum E"
EnumDeclarationEmpty:
- template: "An enum declaration can't be empty."
+ problemMessage: "An enum declaration can't be empty."
analyzerCode: EMPTY_ENUM_BODY
script:
- "enum E {}"
ExternalClass:
index: 3
- template: "Classes can't be declared to be 'external'."
- tip: "Try removing the keyword 'external'."
+ problemMessage: "Classes can't be declared to be 'external'."
+ correctionMessage: "Try removing the keyword 'external'."
analyzerCode: ParserErrorCode.EXTERNAL_CLASS
script:
- "external class C {}"
ExternalEnum:
index: 5
- template: "Enums can't be declared to be 'external'."
- tip: "Try removing the keyword 'external'."
+ problemMessage: "Enums can't be declared to be 'external'."
+ correctionMessage: "Try removing the keyword 'external'."
analyzerCode: ParserErrorCode.EXTERNAL_ENUM
script:
- "external enum E {ONE}"
@@ -2610,7 +2610,7 @@
ExternalMethodWithBody:
# TODO(danrubel): remove reference to `native` once support has been removed
index: 49
- template: "An external or native method can't have a body."
+ problemMessage: "An external or native method can't have a body."
analyzerCode: ParserErrorCode.EXTERNAL_METHOD_WITH_BODY
script:
- "class C {external foo() {}}"
@@ -2619,7 +2619,7 @@
ExternalConstructorWithInitializer:
index: 106
- template: "An external constructor can't have any initializers."
+ problemMessage: "An external constructor can't have any initializers."
analyzerCode: ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_INITIALIZER
script:
- "class C { int? x; external C() : x = 1; }"
@@ -2627,60 +2627,60 @@
ExternalTypedef:
index: 76
- template: "Typedefs can't be declared to be 'external'."
- tip: "Try removing the keyword 'external'."
+ problemMessage: "Typedefs can't be declared to be 'external'."
+ correctionMessage: "Try removing the keyword 'external'."
analyzerCode: ParserErrorCode.EXTERNAL_TYPEDEF
script:
- "external typedef F();"
OperatorWithOptionalFormals:
- template: "An operator can't have optional parameters."
+ problemMessage: "An operator can't have optional parameters."
OperatorWithTypeParameters:
- template: "Types parameters aren't allowed when defining an operator."
- tip: "Try removing the type parameters."
+ problemMessage: "Types parameters aren't allowed when defining an operator."
+ correctionMessage: "Try removing the type parameters."
analyzerCode: TYPE_PARAMETER_ON_OPERATOR
script:
- "class C { operator []<T>(T t) => null; }"
PlatformPrivateLibraryAccess:
- template: "Can't access platform private library."
+ problemMessage: "Can't access platform private library."
analyzerCode: IMPORT_INTERNAL_LIBRARY
TypedefNotFunction:
- template: "Can't create typedef from non-function type."
+ problemMessage: "Can't create typedef from non-function type."
analyzerCode: INVALID_GENERIC_FUNCTION_TYPE
TypedefNotType:
- template: "Can't create typedef from non-type."
+ problemMessage: "Can't create typedef from non-type."
analyzerCode: INVALID_TYPE_IN_TYPEDEF
TypedefTypeVariableNotConstructor:
- template: "Can't use a typedef denoting a type variable as a constructor, nor for a static member access."
+ problemMessage: "Can't use a typedef denoting a type variable as a constructor, nor for a static member access."
TypedefTypeVariableNotConstructorCause:
- template: "This is the type variable ultimately denoted."
+ problemMessage: "This is the type variable ultimately denoted."
severity: CONTEXT
TypedefNullableType:
- template: "Can't create typedef from nullable type."
+ problemMessage: "Can't create typedef from nullable type."
configuration: nnbd-strong
script: |
// @dart=2.12
typedef F = void Function()?;
TypedefUnaliasedTypeCause:
- template: "This is the type denoted by the type alias."
+ problemMessage: "This is the type denoted by the type alias."
severity: CONTEXT
TypedefCause:
- template: "The issue arises via this type alias."
+ problemMessage: "The issue arises via this type alias."
severity: CONTEXT
LibraryDirectiveNotFirst:
index: 37
- template: "The library directive must appear before all other directives."
- tip: "Try moving the library directive before any other directives."
+ problemMessage: "The library directive must appear before all other directives."
+ correctionMessage: "Try moving the library directive before any other directives."
analyzerCode: ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST
script:
- "class Foo{} library l;"
@@ -2689,40 +2689,40 @@
ImportAfterPart:
index: 10
- template: "Import directives must precede part directives."
- tip: "Try moving the import directives before the part directives."
+ problemMessage: "Import directives must precede part directives."
+ correctionMessage: "Try moving the import directives before the part directives."
analyzerCode: ParserErrorCode.IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE
script:
- "part 'foo.dart'; import 'bar.dart';"
ExportAfterPart:
index: 75
- template: "Export directives must precede part directives."
- tip: "Try moving the export directives before the part directives."
+ problemMessage: "Export directives must precede part directives."
+ correctionMessage: "Try moving the export directives before the part directives."
analyzerCode: ParserErrorCode.EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE
script:
- "part 'foo.dart'; export 'bar.dart';"
DirectiveAfterDeclaration:
index: 69
- template: "Directives must appear before any declarations."
- tip: "Try moving the directive before any declarations."
+ problemMessage: "Directives must appear before any declarations."
+ correctionMessage: "Try moving the directive before any declarations."
analyzerCode: ParserErrorCode.DIRECTIVE_AFTER_DECLARATION
script:
- "class foo { } import 'bar.dart';"
- "class foo { } export 'bar.dart';"
NonPartOfDirectiveInPart:
- template: "The part-of directive must be the only directive in a part."
- tip: "Try removing the other directives, or moving them to the library for which this is a part."
+ problemMessage: "The part-of directive must be the only directive in a part."
+ correctionMessage: "Try removing the other directives, or moving them to the library for which this is a part."
analyzerCode: NON_PART_OF_DIRECTIVE_IN_PART
script:
- "part of l; part 'f.dart';"
PartOfTwice:
index: 25
- template: "Only one part-of directive may be declared in a file."
- tip: "Try removing all but one of the part-of directives."
+ problemMessage: "Only one part-of directive may be declared in a file."
+ correctionMessage: "Try removing all but one of the part-of directives."
analyzerCode: ParserErrorCode.MULTIPLE_PART_OF_DIRECTIVES
script:
- main.dart: |
@@ -2745,15 +2745,15 @@
part of "main.dart";
PartTwice:
- template: "Can't use '#uri' as a part more than once."
+ problemMessage: "Can't use '#uri' as a part more than once."
analyzerCode: DUPLICATE_PART
script:
part.dart: "part of 'main.dart';"
main.dart: "part 'part.dart'; part 'part.dart';"
PartOfTwoLibraries:
- template: "A file can't be part of more than one library."
- tip: "Try moving the shared declarations into the libraries, or into a new library."
+ problemMessage: "A file can't be part of more than one library."
+ correctionMessage: "Try moving the shared declarations into the libraries, or into a new library."
analyzerCode: PART_OF_DIFFERENT_LIBRARY
script:
main.dart: "library lib; import 'lib.dart'; part 'part.dart';"
@@ -2761,29 +2761,29 @@
part.dart: "part of lib;"
PartOfTwoLibrariesContext:
- template: "Used as a part in this library."
+ problemMessage: "Used as a part in this library."
severity: CONTEXT
FactoryTopLevelDeclaration:
index: 78
- template: "Top-level declarations can't be declared to be 'factory'."
- tip: "Try removing the keyword 'factory'."
+ problemMessage: "Top-level declarations can't be declared to be 'factory'."
+ correctionMessage: "Try removing the keyword 'factory'."
analyzerCode: ParserErrorCode.FACTORY_TOP_LEVEL_DECLARATION
script:
- "factory class C {}"
RedirectionInNonFactory:
index: 21
- template: "Only factory constructor can specify '=' redirection."
- tip: "Try making this a factory constructor, or remove the redirection."
+ problemMessage: "Only factory constructor can specify '=' redirection."
+ correctionMessage: "Try making this a factory constructor, or remove the redirection."
analyzerCode: ParserErrorCode.REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR
script:
- "class C { C() = D; }"
TopLevelOperator:
index: 14
- template: "Operators must be declared within a class."
- tip: "Try removing the operator, moving it to a class, or converting it to be a function."
+ problemMessage: "Operators must be declared within a class."
+ correctionMessage: "Try removing the operator, moving it to a class, or converting it to be a function."
analyzerCode: ParserErrorCode.TOP_LEVEL_OPERATOR
script:
- "operator +(bool x, bool y) => x | y;"
@@ -2791,36 +2791,36 @@
- "void operator +(bool x, bool y) => x | y;"
MissingFunctionParameters:
- template: "A function declaration needs an explicit list of parameters."
- tip: "Try adding a parameter list to the function declaration."
+ problemMessage: "A function declaration needs an explicit list of parameters."
+ correctionMessage: "Try adding a parameter list to the function declaration."
analyzerCode: MISSING_FUNCTION_PARAMETERS
script:
- "void f {}"
MissingMethodParameters:
- template: "A method declaration needs an explicit list of parameters."
- tip: "Try adding a parameter list to the method declaration."
+ problemMessage: "A method declaration needs an explicit list of parameters."
+ correctionMessage: "Try adding a parameter list to the method declaration."
analyzerCode: MISSING_METHOD_PARAMETERS
script:
- "class C { void m {} }"
MissingTypedefParameters:
- template: "A typedef needs an explicit list of parameters."
- tip: "Try adding a parameter list to the typedef."
+ problemMessage: "A typedef needs an explicit list of parameters."
+ correctionMessage: "Try adding a parameter list to the typedef."
analyzerCode: MISSING_TYPEDEF_PARAMETERS
script:
- "typedef void F;"
MissingPartOf:
- template: "Can't use '#uri' as a part, because it has no 'part of' declaration."
+ problemMessage: "Can't use '#uri' as a part, because it has no 'part of' declaration."
analyzerCode: PART_OF_NON_PART
script:
part.dart: ""
main.dart: "part 'part.dart';"
PartOfInLibrary:
- template: "Can't import '#uri', because it has a 'part of' declaration."
- tip: "Try removing the 'part of' declaration, or using '#uri' as a part."
+ problemMessage: "Can't import '#uri', because it has a 'part of' declaration."
+ correctionMessage: "Try removing the 'part of' declaration, or using '#uri' as a part."
analyzerCode: IMPORT_OF_NON_LIBRARY
script:
main.dart: |
@@ -2835,8 +2835,8 @@
part "part.dart";
PartInPart:
- template: "A file that's a part of a library can't have parts itself."
- tip: "Try moving the 'part' declaration to the containing library."
+ problemMessage: "A file that's a part of a library can't have parts itself."
+ correctionMessage: "Try moving the 'part' declaration to the containing library."
analyzerCode: NON_PART_OF_DIRECTIVE_IN_PART
script:
main.dart: |
@@ -2851,16 +2851,16 @@
part of "part.dart";
PartInPartLibraryContext:
- template: "This is the containing library."
+ problemMessage: "This is the containing library."
severity: CONTEXT
PartOrphan:
- template: "This part doesn't have a containing library."
- tip: "Try removing the 'part of' declaration."
+ problemMessage: "This part doesn't have a containing library."
+ correctionMessage: "Try removing the 'part of' declaration."
script: "part of none; main() {}"
PartExport:
- template: "Can't export this file because it contains a 'part of' declaration."
+ problemMessage: "Can't export this file because it contains a 'part of' declaration."
analyzerCode: EXPORT_OF_NON_LIBRARY
script:
main.dart: |
@@ -2875,24 +2875,24 @@
part "part.dart";
PartExportContext:
- template: "This is the file that can't be exported."
+ problemMessage: "This is the file that can't be exported."
severity: CONTEXT
SupertypeIsFunction:
- template: "Can't use a function type as supertype."
+ problemMessage: "Can't use a function type as supertype."
DeferredPrefixDuplicated:
- template: "Can't use the name '#name' for a deferred library, as the name is used elsewhere."
+ problemMessage: "Can't use the name '#name' for a deferred library, as the name is used elsewhere."
analyzerCode: SHARED_DEFERRED_PREFIX
DeferredPrefixDuplicatedCause:
- template: "'#name' is used here."
+ problemMessage: "'#name' is used here."
severity: CONTEXT
TypeArgumentsOnTypeVariable:
index: 13
- template: "Can't use type arguments with type variable '#name'."
- tip: "Try removing the type arguments."
+ problemMessage: "Can't use type arguments with type variable '#name'."
+ correctionMessage: "Try removing the type arguments."
analyzerCode: ParserErrorCode.TYPE_ARGUMENTS_ON_TYPE_VARIABLE
script:
- "dynamic<T>(x) => 0"
@@ -2913,7 +2913,7 @@
# definitions. Consequently, it is more convenient to use the word
# "declaration" instead of "definition" as the former implies less.
DuplicatedDeclaration:
- template: "'#name' is already declared in this scope."
+ problemMessage: "'#name' is already declared in this scope."
analyzerCode: DUPLICATE_DEFINITION
script: |
class C {} // First declaration (related information points here).
@@ -2925,16 +2925,16 @@
}
DuplicatedDeclarationCause:
- template: "Previous declaration of '#name'."
+ problemMessage: "Previous declaration of '#name'."
severity: CONTEXT
DuplicatedDeclarationSyntheticCause:
- template: "Previous declaration of '#name' is implied by this definition."
+ problemMessage: "Previous declaration of '#name' is implied by this definition."
severity: CONTEXT
# Use this message when a duplicated declaration is used.
DuplicatedDeclarationUse:
- template: "Can't use '#name' because it is declared more than once."
+ problemMessage: "Can't use '#name' because it is declared more than once."
exampleAllowMoreCodes: true
script:
- main.dart: |
@@ -2969,30 +2969,30 @@
var f = new C().method();
DuplicatedNamePreviouslyUsed:
- template: "Can't declare '#name' because it was already used in this scope."
+ problemMessage: "Can't declare '#name' because it was already used in this scope."
analyzerCode: REFERENCED_BEFORE_DECLARATION
script:
- "main(arguments) { arguments; var arguments; }"
DuplicatedNamePreviouslyUsedCause:
- template: "Previous use of '#name'."
+ problemMessage: "Previous use of '#name'."
severity: CONTEXT
DuplicatedNamedArgument:
- template: "Duplicated named argument '#name'."
+ problemMessage: "Duplicated named argument '#name'."
analyzerCode: DUPLICATE_NAMED_ARGUMENT
DuplicatedParameterName:
- template: "Duplicated parameter name '#name'."
+ problemMessage: "Duplicated parameter name '#name'."
analyzerCode: DUPLICATE_DEFINITION
DuplicatedParameterNameCause:
- template: "Other parameter named '#name'."
+ problemMessage: "Other parameter named '#name'."
severity: CONTEXT
MemberWithSameNameAsClass:
- template: "A class member can't have the same name as the enclosing class."
- tip: "Try renaming the member."
+ problemMessage: "A class member can't have the same name as the enclosing class."
+ correctionMessage: "Try renaming the member."
analyzerCode: ParserErrorCode.MEMBER_WITH_CLASS_NAME
index: 105
script:
@@ -3004,26 +3004,26 @@
- "class C { int? A, B, C, D, E; }"
EnumConstantSameNameAsEnclosing:
- template: "Name of enum constant '#name' can't be the same as the enum's own name."
+ problemMessage: "Name of enum constant '#name' can't be the same as the enum's own name."
analyzerCode: ENUM_CONSTANT_WITH_ENUM_NAME
MissingOperatorKeyword:
index: 31
- template: "Operator declarations must be preceded by the keyword 'operator'."
- tip: "Try adding the keyword 'operator'."
+ problemMessage: "Operator declarations must be preceded by the keyword 'operator'."
+ correctionMessage: "Try adding the keyword 'operator'."
analyzerCode: ParserErrorCode.MISSING_KEYWORD_OPERATOR
script:
- "class C { +(x) {} }"
InvalidOperator:
index: 39
- template: "The string '#lexeme' isn't a user-definable operator."
+ problemMessage: "The string '#lexeme' isn't a user-definable operator."
analyzerCode: ParserErrorCode.INVALID_OPERATOR
script:
- "class C { void operator %=(x) {} }"
NotBinaryOperator:
- template: "'#lexeme' isn't a binary operator."
+ problemMessage: "'#lexeme' isn't a binary operator."
script: >
class C { operator~() { return null; } }
@@ -3033,25 +3033,25 @@
}
OperatorParameterMismatch0:
- template: "Operator '#name' shouldn't have any parameters."
+ problemMessage: "Operator '#name' shouldn't have any parameters."
OperatorParameterMismatch1:
- template: "Operator '#name' should have exactly one parameter."
+ problemMessage: "Operator '#name' should have exactly one parameter."
analyzerCode: WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR
OperatorParameterMismatch2:
- template: "Operator '#name' should have exactly two parameters."
+ problemMessage: "Operator '#name' should have exactly two parameters."
analyzerCode: WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR
OperatorMinusParameterMismatch:
- template: "Operator '#name' should have zero or one parameter."
- tip: >-
+ problemMessage: "Operator '#name' should have zero or one parameter."
+ correctionMessage: >-
With zero parameters, it has the syntactic form '-a', formally known as 'unary-'.
With one parameter, it has the syntactic form 'a - b', formally known as '-'.
analyzerCode: WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR_MINUS
SupertypeIsIllegal:
- template: "The type '#name' can't be used as supertype."
+ problemMessage: "The type '#name' can't be used as supertype."
analyzerCode: EXTENDS_NON_CLASS
script: |
@@ -3059,14 +3059,14 @@
class C extends dynamic {}
SupertypeIsIllegalAliased:
- template: "The type '#name' which is an alias of '#type' can't be used as supertype."
+ problemMessage: "The type '#name' which is an alias of '#type' can't be used as supertype."
analyzerCode: EXTENDS_NON_CLASS
script: |
typedef F = void Function();
class C extends F {}
SupertypeIsNullableAliased:
- template: "The type '#name' which is an alias of '#type' can't be used as supertype because it is nullable."
+ problemMessage: "The type '#name' which is an alias of '#type' can't be used as supertype because it is nullable."
analyzerCode: EXTENDS_NON_CLASS
experiments: nonfunction-type-aliases
script: |
@@ -3075,78 +3075,78 @@
class C extends B {}
SupertypeIsTypeVariable:
- template: "The type variable '#name' can't be used as supertype."
+ problemMessage: "The type variable '#name' can't be used as supertype."
analyzerCode: EXTENDS_NON_CLASS
script: |
class C<T> extends T {}
PartOfLibraryNameMismatch:
- template: "Using '#uri' as part of '#name' but its 'part of' declaration says '#name2'."
+ problemMessage: "Using '#uri' as part of '#name' but its 'part of' declaration says '#name2'."
analyzerCode: PART_OF_DIFFERENT_LIBRARY
PartOfUseUri:
- template: "Using '#uri' as part of '#uri2' but its 'part of' declaration says '#name'."
- tip: "Try changing the 'part of' declaration to use a relative file name."
+ problemMessage: "Using '#uri' as part of '#uri2' but its 'part of' declaration says '#name'."
+ correctionMessage: "Try changing the 'part of' declaration to use a relative file name."
analyzerCode: PART_OF_UNNAMED_LIBRARY
PartOfUriMismatch:
- template: "Using '#uri' as part of '#uri2' but its 'part of' declaration says '#uri3'."
+ problemMessage: "Using '#uri' as part of '#uri2' but its 'part of' declaration says '#uri3'."
analyzerCode: PART_OF_DIFFERENT_LIBRARY
MissingMain:
- template: "No 'main' method found."
- tip: "Try adding a method named 'main' to your program."
+ problemMessage: "No 'main' method found."
+ correctionMessage: "Try adding a method named 'main' to your program."
MissingInput:
- template: "No input file provided to the compiler."
+ problemMessage: "No input file provided to the compiler."
InputFileNotFound:
- template: "Input file not found: #uri."
+ problemMessage: "Input file not found: #uri."
SdkRootNotFound:
- template: "SDK root directory not found: #uri."
+ problemMessage: "SDK root directory not found: #uri."
SdkSummaryNotFound:
- template: "SDK summary not found: #uri."
+ problemMessage: "SDK summary not found: #uri."
SdkSpecificationNotFound:
- template: "SDK libraries specification not found: #uri."
- tip: "Normally, the specification is a file named 'libraries.json' in the Dart SDK install location."
+ problemMessage: "SDK libraries specification not found: #uri."
+ correctionMessage: "Normally, the specification is a file named 'libraries.json' in the Dart SDK install location."
InvalidSuperInInitializer:
index: 47
- template: "Can only use 'super' in an initializer for calling the superclass constructor (e.g. 'super()' or 'super.namedConstructor()')"
+ problemMessage: "Can only use 'super' in an initializer for calling the superclass constructor (e.g. 'super()' or 'super.namedConstructor()')"
analyzerCode: ParserErrorCode.INVALID_SUPER_IN_INITIALIZER
InvalidThisInInitializer:
index: 65
- template: "Can only use 'this' in an initializer for field initialization (e.g. 'this.x = something') and constructor redirection (e.g. 'this()' or 'this.namedConstructor())"
+ problemMessage: "Can only use 'this' in an initializer for field initialization (e.g. 'this.x = something') and constructor redirection (e.g. 'this()' or 'this.namedConstructor())"
analyzerCode: ParserErrorCode.INVALID_THIS_IN_INITIALIZER
ThisAccessInFieldInitializer:
- template: "Can't access 'this' in a field initializer to read '#name'."
+ problemMessage: "Can't access 'this' in a field initializer to read '#name'."
analyzerCode: THIS_ACCESS_FROM_FIELD_INITIALIZER
ThisOrSuperAccessInFieldInitializer:
- template: "Can't access '#string' in a field initializer."
+ problemMessage: "Can't access '#string' in a field initializer."
analyzerCode: THIS_ACCESS_FROM_INITIALIZER
ThisAsIdentifier:
- template: "Expected identifier, but got 'this'."
+ problemMessage: "Expected identifier, but got 'this'."
analyzerCode: INVALID_REFERENCE_TO_THIS
# TODO(johnniwinther): Confusing message, it should probably mention that `super` is not available.
SuperAsIdentifier:
- template: "Expected identifier, but got 'super'."
+ problemMessage: "Expected identifier, but got 'super'."
analyzerCode: SUPER_AS_EXPRESSION
SuperAsExpression:
- template: "Can't use 'super' as an expression."
- tip: "To delegate a constructor to a super constructor, put the super call as an initializer."
+ problemMessage: "Can't use 'super' as an expression."
+ correctionMessage: "To delegate a constructor to a super constructor, put the super call as an initializer."
analyzerCode: SUPER_AS_EXPRESSION
SwitchExpressionNotAssignable:
- template: "Type '#type' of the switch expression isn't assignable to the type '#type2' of this case expression."
+ problemMessage: "Type '#type' of the switch expression isn't assignable to the type '#type2' of this case expression."
analyzerCode: SWITCH_EXPRESSION_NOT_ASSIGNABLE
script:
- |
@@ -3158,11 +3158,11 @@
}
SwitchExpressionNotAssignableCause:
- template: "The switch expression is here."
+ problemMessage: "The switch expression is here."
severity: CONTEXT
SwitchExpressionNotSubtype:
- template: "Type '#type' of the case expression is not a subtype of type '#type2' of this switch expression."
+ problemMessage: "Type '#type' of the case expression is not a subtype of type '#type2' of this switch expression."
script:
- |
void f() {
@@ -3173,43 +3173,43 @@
SwitchHasCaseAfterDefault:
index: 16
- template: "The default case should be the last case in a switch statement."
- tip: "Try moving the default case after the other case clauses."
+ problemMessage: "The default case should be the last case in a switch statement."
+ correctionMessage: "Try moving the default case after the other case clauses."
analyzerCode: ParserErrorCode.SWITCH_HAS_CASE_AFTER_DEFAULT_CASE
script:
- "class C { foo(int a) {switch (a) {default: return 0; case 1: return 1;}} }"
SwitchHasMultipleDefaults:
index: 15
- template: "The 'default' case can only be declared once."
- tip: "Try removing all but one default case."
+ problemMessage: "The 'default' case can only be declared once."
+ correctionMessage: "Try removing all but one default case."
analyzerCode: ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASES
script:
- "class C { foo(int a) {switch (a) {default: return 0; default: return 1;}} }"
SwitchCaseFallThrough:
- template: "Switch case may fall through to the next case."
+ problemMessage: "Switch case may fall through to the next case."
analyzerCode: CASE_BLOCK_NOT_TERMINATED
FieldAlreadyInitializedAtDeclaration:
- template: "'#name' is a final instance variable that was initialized at the declaration."
+ problemMessage: "'#name' is a final instance variable that was initialized at the declaration."
analyzerCode: FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION
script:
- "class C { final int x = 2; C(): this.x = 3 {} }"
FieldAlreadyInitializedAtDeclarationCause:
- template: "'#name' was initialized here."
+ problemMessage: "'#name' was initialized here."
severity: CONTEXT
ConstructorInitializeSameInstanceVariableSeveralTimes:
- template: "'#name' was already initialized by this constructor."
+ problemMessage: "'#name' was already initialized by this constructor."
analyzerCode: FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS
script:
- "class C { final int x; C(): this.x = 1, this.x = 2 {} }"
- "class C { int x; C(): this.x = 1, this.x = 2 {} }"
TypeVariableInStaticContext:
- template: "Type variables can't be used in static members."
+ problemMessage: "Type variables can't be used in static members."
analyzerCode: TYPE_PARAMETER_REFERENCED_BY_STATIC
declaration:
- |
@@ -3244,7 +3244,7 @@
}
TypeVariableInConstantContext:
- template: "Type variables can't be used as constants."
+ problemMessage: "Type variables can't be used as constants."
analyzerCode: TYPE_PARAMETER_IN_CONST_EXPRESSION
declaration:
- |
@@ -3267,26 +3267,26 @@
}
SuperclassMethodArgumentMismatch:
- template: "Superclass doesn't have a method named '#name' with matching arguments."
+ problemMessage: "Superclass doesn't have a method named '#name' with matching arguments."
SuperclassHasNoMember:
- template: "Superclass has no member named '#name'."
+ problemMessage: "Superclass has no member named '#name'."
analyzerCode: UNDEFINED_SUPER_GETTER
SuperclassHasNoGetter:
- template: "Superclass has no getter named '#name'."
+ problemMessage: "Superclass has no getter named '#name'."
analyzerCode: UNDEFINED_SUPER_GETTER
SuperclassHasNoSetter:
- template: "Superclass has no setter named '#name'."
+ problemMessage: "Superclass has no setter named '#name'."
analyzerCode: UNDEFINED_SUPER_SETTER
SuperclassHasNoMethod:
- template: "Superclass has no method named '#name'."
+ problemMessage: "Superclass has no method named '#name'."
analyzerCode: UNDEFINED_SUPER_METHOD
SuperclassHasNoConstructor:
- template: "Superclass has no constructor named '#name'."
+ problemMessage: "Superclass has no constructor named '#name'."
analyzerCode:
- UNDEFINED_CONSTRUCTOR_IN_INITIALIZER
- UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT
@@ -3309,26 +3309,26 @@
}
SuperclassHasNoDefaultConstructor:
- template: "The superclass, '#name', has no unnamed constructor that takes no arguments."
+ problemMessage: "The superclass, '#name', has no unnamed constructor that takes no arguments."
analyzerCode: NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT
ConstConstructorNonFinalField:
- template: "Constructor is marked 'const' so all fields must be final."
+ problemMessage: "Constructor is marked 'const' so all fields must be final."
analyzerCode: CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD
ConstConstructorNonFinalFieldCause:
- template: "Field isn't final, but constructor is 'const'."
+ problemMessage: "Field isn't final, but constructor is 'const'."
severity: CONTEXT
ConstConstructorLateFinalFieldError:
- template: "Can't have a late final field in a class with a const constructor."
+ problemMessage: "Can't have a late final field in a class with a const constructor."
ConstConstructorLateFinalFieldCause:
- template: "This constructor is const."
+ problemMessage: "This constructor is const."
severity: CONTEXT
ConstConstructorRedirectionToNonConst:
- template: "A constant constructor can't call a non-constant constructor."
+ problemMessage: "A constant constructor can't call a non-constant constructor."
script:
- >-
class A {
@@ -3337,7 +3337,7 @@
}
ConstConstructorWithNonConstSuper:
- template: "A constant constructor can't call a non-constant super constructor."
+ problemMessage: "A constant constructor can't call a non-constant super constructor."
analyzerCode: CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER
script:
- >-
@@ -3349,115 +3349,115 @@
}
AccessError:
- template: "Access error: '#name'."
+ problemMessage: "Access error: '#name'."
ExpressionNotMetadata:
- template: "This can't be used as an annotation; an annotation should be a reference to a compile-time constant variable, or a call to a constant constructor."
+ problemMessage: "This can't be used as an annotation; an annotation should be a reference to a compile-time constant variable, or a call to a constant constructor."
ExpectedAnInitializer:
index: 36
- template: "Expected an initializer."
+ problemMessage: "Expected an initializer."
analyzerCode: ParserErrorCode.MISSING_INITIALIZER
script:
- "class C { C() : {} }"
MissingAssignmentInInitializer:
index: 34
- template: "Expected an assignment after the field name."
- tip: "To initialize a field, use the syntax 'name = value'."
+ problemMessage: "Expected an assignment after the field name."
+ correctionMessage: "To initialize a field, use the syntax 'name = value'."
analyzerCode: ParserErrorCode.MISSING_ASSIGNMENT_IN_INITIALIZER
script:
- "class C { C() : x(3) {} }"
RedirectingConstructorWithBody:
index: 22
- template: "Redirecting constructors can't have a body."
- tip: "Try removing the body, or not making this a redirecting constructor."
+ problemMessage: "Redirecting constructors can't have a body."
+ correctionMessage: "Try removing the body, or not making this a redirecting constructor."
analyzerCode: ParserErrorCode.REDIRECTING_CONSTRUCTOR_WITH_BODY
script:
- "class C { C() : this.x() {} }"
CannotAssignToParenthesizedExpression:
- template: "Can't assign to a parenthesized expression."
+ problemMessage: "Can't assign to a parenthesized expression."
analyzerCode: ASSIGNMENT_TO_PARENTHESIZED_EXPRESSION
NotAnLvalue:
- template: "Can't assign to this."
+ problemMessage: "Can't assign to this."
analyzerCode: NOT_AN_LVALUE
CannotAssignToSuper:
- template: "Can't assign to super."
+ problemMessage: "Can't assign to super."
analyzerCode: NOT_AN_LVALUE
IllegalAssignmentToNonAssignable:
index: 45
- template: "Illegal assignment to non-assignable expression."
+ problemMessage: "Illegal assignment to non-assignable expression."
analyzerCode: ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE
script:
- "main(){ f()++; }"
MissingAssignableSelector:
index: 35
- template: "Missing selector such as '.identifier' or '[0]'."
- tip: "Try adding a selector."
+ problemMessage: "Missing selector such as '.identifier' or '[0]'."
+ correctionMessage: "Try adding a selector."
analyzerCode: ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR
script:
- "main(){ ++f(); }"
CannotReadSdkSpecification:
- template: "Unable to read the 'libraries.json' specification file:\n #string."
+ problemMessage: "Unable to read the 'libraries.json' specification file:\n #string."
CantInferPackagesFromManyInputs:
- template: "Can't infer a packages file when compiling multiple inputs."
- tip: "Try specifying the file explicitly with the --packages option."
+ problemMessage: "Can't infer a packages file when compiling multiple inputs."
+ correctionMessage: "Try specifying the file explicitly with the --packages option."
CantInferPackagesFromPackageUri:
- template: "Can't infer a packages file from an input 'package:*' URI."
- tip: "Try specifying the file explicitly with the --packages option."
+ problemMessage: "Can't infer a packages file from an input 'package:*' URI."
+ correctionMessage: "Try specifying the file explicitly with the --packages option."
PackageNotFound:
- template: "Couldn't resolve the package '#name' in '#uri'."
+ problemMessage: "Couldn't resolve the package '#name' in '#uri'."
InvalidPackageUri:
- template: "Invalid package URI '#uri':\n #string."
+ problemMessage: "Invalid package URI '#uri':\n #string."
CouldNotParseUri:
- template: "Couldn't parse URI '#string':\n #string2."
+ problemMessage: "Couldn't parse URI '#string':\n #string2."
ExpectedUri:
- template: "Expected a URI."
+ problemMessage: "Expected a URI."
InterpolationInUri:
- template: "Can't use string interpolation in a URI."
+ problemMessage: "Can't use string interpolation in a URI."
analyzerCode: INVALID_LITERAL_IN_CONFIGURATION
IntegerLiteralIsOutOfRange:
- template: "The integer literal #string can't be represented in 64 bits."
- tip: "Try using the BigInt class if you need an integer larger than 9,223,372,036,854,775,807 or less than -9,223,372,036,854,775,808."
+ problemMessage: "The integer literal #string can't be represented in 64 bits."
+ correctionMessage: "Try using the BigInt class if you need an integer larger than 9,223,372,036,854,775,807 or less than -9,223,372,036,854,775,808."
analyzerCode: INTEGER_LITERAL_OUT_OF_RANGE
ColonInPlaceOfIn:
index: 54
- template: "For-in loops use 'in' rather than a colon."
- tip: "Try replacing the colon with the keyword 'in'."
+ problemMessage: "For-in loops use 'in' rather than a colon."
+ correctionMessage: "Try replacing the colon with the keyword 'in'."
analyzerCode: ParserErrorCode.COLON_IN_PLACE_OF_IN
BinaryOperatorWrittenOut:
index: 112
- template: "Binary operator '#string' is written as '#string2' instead of the written out word."
- tip: "Try replacing '#string' with '#string2'."
+ problemMessage: "Binary operator '#string' is written as '#string2' instead of the written out word."
+ correctionMessage: "Try replacing '#string' with '#string2'."
analyzerCode: ParserErrorCode.BINARY_OPERATOR_WRITTEN_OUT
script: >
int foo(int x, int y) => x xor y;
ExternalFactoryRedirection:
index: 85
- template: "A redirecting factory can't be external."
- tip: "Try removing the 'external' modifier."
+ problemMessage: "A redirecting factory can't be external."
+ correctionMessage: "Try removing the 'external' modifier."
analyzerCode: ParserErrorCode.EXTERNAL_FACTORY_REDIRECTION
ArgumentTypeNotAssignable:
- template: "The argument type '#type' can't be assigned to the parameter type '#type2'."
+ problemMessage: "The argument type '#type' can't be assigned to the parameter type '#type2'."
analyzerCode: ARGUMENT_TYPE_NOT_ASSIGNABLE
script: >
method(int i) {}
@@ -3466,7 +3466,7 @@
}
ArgumentTypeNotAssignableNullability:
- template: "The argument type '#type' can't be assigned to the parameter type '#type2' because '#type' is nullable and '#type2' isn't."
+ problemMessage: "The argument type '#type' can't be assigned to the parameter type '#type2' because '#type' is nullable and '#type2' isn't."
analyzerCode: ARGUMENT_TYPE_NOT_ASSIGNABLE
configuration: nnbd-strong
script: >
@@ -3477,7 +3477,7 @@
}
ArgumentTypeNotAssignablePartNullability:
- template: "The argument type '#type' can't be assigned to the parameter type '#type2' because '#type3' is nullable and '#type4' isn't."
+ problemMessage: "The argument type '#type' can't be assigned to the parameter type '#type2' because '#type3' is nullable and '#type4' isn't."
analyzerCode: ARGUMENT_TYPE_NOT_ASSIGNABLE
configuration: nnbd-strong
script: >
@@ -3488,7 +3488,7 @@
}
ArgumentTypeNotAssignableNullabilityNull:
- template: "The value 'null' can't be assigned to the parameter type '#type' because '#type' is not nullable."
+ problemMessage: "The value 'null' can't be assigned to the parameter type '#type' because '#type' is not nullable."
analyzerCode: ARGUMENT_TYPE_NOT_ASSIGNABLE
configuration: nnbd-strong
script: >
@@ -3498,7 +3498,7 @@
}
ArgumentTypeNotAssignableNullabilityNullType:
- template: "The argument type '#type' can't be assigned to the parameter type '#type2' because '#type2' is not nullable."
+ problemMessage: "The argument type '#type' can't be assigned to the parameter type '#type2' because '#type2' is not nullable."
analyzerCode: ARGUMENT_TYPE_NOT_ASSIGNABLE
configuration: nnbd-strong
script: >
@@ -3509,7 +3509,7 @@
}
InvalidAssignmentError:
- template: "A value of type '#type' can't be assigned to a variable of type '#type2'."
+ problemMessage: "A value of type '#type' can't be assigned to a variable of type '#type2'."
analyzerCode: INVALID_ASSIGNMENT
script: >
main() {
@@ -3518,7 +3518,7 @@
}
InvalidAssignmentErrorNullability:
- template: "A value of type '#type' can't be assigned to a variable of type '#type2' because '#type' is nullable and '#type2' isn't."
+ problemMessage: "A value of type '#type' can't be assigned to a variable of type '#type2' because '#type' is nullable and '#type2' isn't."
analyzerCode: INVALID_ASSIGNMENT
configuration: nnbd-strong
script: >
@@ -3529,7 +3529,7 @@
}
InvalidAssignmentErrorPartNullability:
- template: "A value of type '#type' can't be assigned to a variable of type '#type2' because '#type3' is nullable and '#type4' isn't."
+ problemMessage: "A value of type '#type' can't be assigned to a variable of type '#type2' because '#type3' is nullable and '#type4' isn't."
analyzerCode: INVALID_ASSIGNMENT
configuration: nnbd-strong
script: >
@@ -3540,7 +3540,7 @@
}
InvalidAssignmentErrorNullabilityNull:
- template: "The value 'null' can't be assigned to a variable of type '#type' because '#type' is not nullable."
+ problemMessage: "The value 'null' can't be assigned to a variable of type '#type' because '#type' is not nullable."
analyzerCode: INVALID_ASSIGNMENT
configuration: nnbd-strong
script: >
@@ -3550,7 +3550,7 @@
}
InvalidAssignmentErrorNullabilityNullType:
- template: "A value of type '#type' can't be assigned to a variable of type '#type2' because '#type2' is not nullable."
+ problemMessage: "A value of type '#type' can't be assigned to a variable of type '#type2' because '#type2' is not nullable."
analyzerCode: INVALID_ASSIGNMENT
configuration: nnbd-strong
script: >
@@ -3561,79 +3561,79 @@
}
PatchClassTypeVariablesMismatch:
- template: "A patch class must have the same number of type variables as its origin class."
+ problemMessage: "A patch class must have the same number of type variables as its origin class."
PatchClassOrigin:
- template: "This is the origin class."
+ problemMessage: "This is the origin class."
severity: CONTEXT
PatchDeclarationMismatch:
- template: "This patch doesn't match origin declaration."
+ problemMessage: "This patch doesn't match origin declaration."
PatchDeclarationOrigin:
- template: "This is the origin declaration."
+ problemMessage: "This is the origin declaration."
severity: CONTEXT
PatchInjectionFailed:
- template: "Can't inject '#name' into '#uri'."
- tip: "Try adding '@patch'."
+ problemMessage: "Can't inject '#name' into '#uri'."
+ correctionMessage: "Try adding '@patch'."
PatchNonExternal:
- template: "Can't apply this patch as its origin declaration isn't external."
- tip: "Try adding 'external' to the origin declaration."
+ problemMessage: "Can't apply this patch as its origin declaration isn't external."
+ correctionMessage: "Try adding 'external' to the origin declaration."
InvalidCastFunctionExpr:
- template: "The function expression type '#type' isn't of expected type '#type2'."
- tip: "Change the type of the function expression or the context in which it is used."
+ problemMessage: "The function expression type '#type' isn't of expected type '#type2'."
+ correctionMessage: "Change the type of the function expression or the context in which it is used."
analyzerCode: INVALID_CAST_FUNCTION_EXPR
InvalidCastLiteralList:
- template: "The list literal type '#type' isn't of expected type '#type2'."
- tip: "Change the type of the list literal or the context in which it is used."
+ problemMessage: "The list literal type '#type' isn't of expected type '#type2'."
+ correctionMessage: "Change the type of the list literal or the context in which it is used."
analyzerCode: INVALID_CAST_LITERAL_LIST
InvalidCastLiteralMap:
- template: "The map literal type '#type' isn't of expected type '#type2'."
- tip: "Change the type of the map literal or the context in which it is used."
+ problemMessage: "The map literal type '#type' isn't of expected type '#type2'."
+ correctionMessage: "Change the type of the map literal or the context in which it is used."
analyzerCode: INVALID_CAST_LITERAL_MAP
InvalidCastLiteralSet:
- template: "The set literal type '#type' isn't of expected type '#type2'."
- tip: "Change the type of the set literal or the context in which it is used."
+ problemMessage: "The set literal type '#type' isn't of expected type '#type2'."
+ correctionMessage: "Change the type of the set literal or the context in which it is used."
analyzerCode: INVALID_CAST_LITERAL_SET
InvalidCastLocalFunction:
- template: "The local function has type '#type' that isn't of expected type '#type2'."
- tip: "Change the type of the function or the context in which it is used."
+ problemMessage: "The local function has type '#type' that isn't of expected type '#type2'."
+ correctionMessage: "Change the type of the function or the context in which it is used."
analyzerCode: INVALID_CAST_FUNCTION
InvalidCastNewExpr:
- template: "The constructor returns type '#type' that isn't of expected type '#type2'."
- tip: "Change the type of the object being constructed or the context in which it is used."
+ problemMessage: "The constructor returns type '#type' that isn't of expected type '#type2'."
+ correctionMessage: "Change the type of the object being constructed or the context in which it is used."
analyzerCode: INVALID_CAST_NEW_EXPR
InvalidCastStaticMethod:
- template: "The static method has type '#type' that isn't of expected type '#type2'."
- tip: "Change the type of the method or the context in which it is used."
+ problemMessage: "The static method has type '#type' that isn't of expected type '#type2'."
+ correctionMessage: "Change the type of the method or the context in which it is used."
analyzerCode: INVALID_CAST_METHOD
InvalidCastTopLevelFunction:
- template: "The top level function has type '#type' that isn't of expected type '#type2'."
- tip: "Change the type of the function or the context in which it is used."
+ problemMessage: "The top level function has type '#type' that isn't of expected type '#type2'."
+ correctionMessage: "Change the type of the function or the context in which it is used."
analyzerCode: INVALID_CAST_FUNCTION
InvalidCatchArguments:
- template: "Invalid catch arguments."
+ problemMessage: "Invalid catch arguments."
analyzerCode: INVALID_CATCH_ARGUMENTS
InvalidUseOfNullAwareAccess:
- template: "Cannot use '?.' here."
- tip: "Try using '.'."
+ problemMessage: "Cannot use '?.' here."
+ correctionMessage: "Try using '.'."
analyzerCode: INVALID_USE_OF_NULL_AWARE_ACCESS
UndefinedGetter:
- template: "The getter '#name' isn't defined for the class '#type'."
- tip: "Try correcting the name to the name of an existing getter, or defining a getter or field named '#name'."
+ problemMessage: "The getter '#name' isn't defined for the class '#type'."
+ correctionMessage: "Try correcting the name to the name of an existing getter, or defining a getter or field named '#name'."
analyzerCode: UNDEFINED_GETTER
script: >
class C {}
@@ -3642,8 +3642,8 @@
}
UndefinedSetter:
- template: "The setter '#name' isn't defined for the class '#type'."
- tip: "Try correcting the name to the name of an existing setter, or defining a setter or field named '#name'."
+ problemMessage: "The setter '#name' isn't defined for the class '#type'."
+ correctionMessage: "Try correcting the name to the name of an existing setter, or defining a setter or field named '#name'."
analyzerCode: UNDEFINED_SETTER
script: >
class C {}
@@ -3652,8 +3652,8 @@
}
UndefinedMethod:
- template: "The method '#name' isn't defined for the class '#type'."
- tip: "Try correcting the name to the name of an existing method, or defining a method named '#name'."
+ problemMessage: "The method '#name' isn't defined for the class '#type'."
+ correctionMessage: "Try correcting the name to the name of an existing method, or defining a method named '#name'."
analyzerCode: UNDEFINED_METHOD
script: >
class C {}
@@ -3662,8 +3662,8 @@
}
UndefinedOperator:
- template: "The operator '#name' isn't defined for the class '#type'."
- tip: "Try correcting the operator to an existing operator, or defining a '#name' operator."
+ problemMessage: "The operator '#name' isn't defined for the class '#type'."
+ correctionMessage: "Try correcting the operator to an existing operator, or defining a '#name' operator."
analyzerCode: UNDEFINED_METHOD
script: >
class C {}
@@ -3672,24 +3672,24 @@
}
UndefinedExtensionGetter:
- template: "The getter '#name' isn't defined for the extension '#type'."
- tip: "Try correcting the name to the name of an existing getter, or defining a getter or field named '#name'."
+ problemMessage: "The getter '#name' isn't defined for the extension '#type'."
+ correctionMessage: "Try correcting the name to the name of an existing getter, or defining a getter or field named '#name'."
UndefinedExtensionSetter:
- template: "The setter '#name' isn't defined for the extension '#type'."
- tip: "Try correcting the name to the name of an existing setter, or defining a setter or field named '#name'."
+ problemMessage: "The setter '#name' isn't defined for the extension '#type'."
+ correctionMessage: "Try correcting the name to the name of an existing setter, or defining a setter or field named '#name'."
UndefinedExtensionMethod:
- template: "The method '#name' isn't defined for the extension '#type'."
- tip: "Try correcting the name to the name of an existing method, or defining a method name '#name'."
+ problemMessage: "The method '#name' isn't defined for the extension '#type'."
+ correctionMessage: "Try correcting the name to the name of an existing method, or defining a method name '#name'."
UndefinedExtensionOperator:
- template: "The operator '#name' isn't defined for the extension '#type'."
- tip: "Try correcting the operator to an existing operator, or defining a '#name' operator."
+ problemMessage: "The operator '#name' isn't defined for the extension '#type'."
+ correctionMessage: "Try correcting the operator to an existing operator, or defining a '#name' operator."
AmbiguousExtensionMethod:
- template: "The method '#name' is defined in multiple extensions for '#type' and neither is more specific."
- tip: "Try using an explicit extension application of the wanted extension or hiding unwanted extensions from scope."
+ problemMessage: "The method '#name' is defined in multiple extensions for '#type' and neither is more specific."
+ correctionMessage: "Try using an explicit extension application of the wanted extension or hiding unwanted extensions from scope."
script: |
class C {}
extension A on C { method() {} }
@@ -3700,8 +3700,8 @@
}
AmbiguousExtensionProperty:
- template: "The property '#name' is defined in multiple extensions for '#type' and neither is more specific."
- tip: "Try using an explicit extension application of the wanted extension or hiding unwanted extensions from scope."
+ problemMessage: "The property '#name' is defined in multiple extensions for '#type' and neither is more specific."
+ correctionMessage: "Try using an explicit extension application of the wanted extension or hiding unwanted extensions from scope."
script: |
class C {}
extension A on C { get property => null; }
@@ -3712,8 +3712,8 @@
}
AmbiguousExtensionOperator:
- template: "The operator '#name' is defined in multiple extensions for '#type' and neither is more specific."
- tip: "Try using an explicit extension application of the wanted extension or hiding unwanted extensions from scope."
+ problemMessage: "The operator '#name' is defined in multiple extensions for '#type' and neither is more specific."
+ correctionMessage: "Try using an explicit extension application of the wanted extension or hiding unwanted extensions from scope."
script: |
class C {}
extension A on C { operator +(int i) {} }
@@ -3724,30 +3724,30 @@
}
AmbiguousExtensionCause:
- template: "This is one of the extension members."
+ problemMessage: "This is one of the extension members."
severity: CONTEXT
SourceOutlineSummary:
- template: |
+ problemMessage: |
Built outlines for #count compilation units (#count2 bytes) in #num1%.3ms, that is,
#num2%12.3 bytes/ms, and
#num3%12.3 ms/compilation unit.
SourceBodySummary:
- template: |
+ problemMessage: |
Built bodies for #count compilation units (#count2 bytes) in #num1%.3ms, that is,
#num2%12.3 bytes/ms, and
#num3%12.3 ms/compilation unit.
DillOutlineSummary:
- template: |
+ problemMessage: |
Indexed #count libraries (#count2 bytes) in #num1%.3ms, that is,
#num2%12.3 bytes/ms, and
#num3%12.3 ms/libraries.
CantInferTypesDueToNoCombinedSignature:
- template: "Can't infer types for '#name' as the overridden members don't have a combined signature."
- tip: "Try adding explicit types."
+ problemMessage: "Can't infer types for '#name' as the overridden members don't have a combined signature."
+ correctionMessage: "Try adding explicit types."
analyzerCode: COMPILE_TIME_ERROR.NO_COMBINED_SUPER_SIGNATURE
script: |
class A {
@@ -3761,8 +3761,8 @@
}
CantInferTypeDueToNoCombinedSignature:
- template: "Can't infer a type for '#name' as the overridden members don't have a combined signature."
- tip: "Try adding an explicit type."
+ problemMessage: "Can't infer a type for '#name' as the overridden members don't have a combined signature."
+ correctionMessage: "Try adding an explicit type."
analyzerCode: COMPILE_TIME_ERROR.NO_COMBINED_SUPER_SIGNATURE
configuration: nnbd-strong
script: |
@@ -3777,8 +3777,8 @@
}
CantInferReturnTypeDueToNoCombinedSignature:
- template: "Can't infer a return type for '#name' as the overridden members don't have a combined signature."
- tip: "Try adding an explicit type."
+ problemMessage: "Can't infer a return type for '#name' as the overridden members don't have a combined signature."
+ correctionMessage: "Try adding an explicit type."
analyzerCode: COMPILE_TIME_ERROR.NO_COMBINED_SUPER_SIGNATURE
configuration: nnbd-strong
script: |
@@ -3793,42 +3793,42 @@
}
CantInferTypeDueToCircularity:
- template: "Can't infer the type of '#string': circularity found during type inference."
- tip: "Specify the type explicitly."
+ problemMessage: "Can't infer the type of '#string': circularity found during type inference."
+ correctionMessage: "Specify the type explicitly."
analyzerCode: RECURSIVE_COMPILE_TIME_CONSTANT
AmbiguousSupertypes:
- template: "'#name' can't implement both '#type' and '#type2'"
+ problemMessage: "'#name' can't implement both '#type' and '#type2'"
analyzerCode: AMBIGUOUS_SUPERTYPES
MixinInferenceNoMatchingClass:
- template: "Type parameters couldn't be inferred for the mixin '#name' because '#name2' does not implement the mixin's supertype constraint '#type'."
+ problemMessage: "Type parameters couldn't be inferred for the mixin '#name' because '#name2' does not implement the mixin's supertype constraint '#type'."
analyzerCode: MIXIN_INFERENCE_NO_POSSIBLE_SUBSTITUTION
ImplicitCallOfNonMethod:
- template: "Cannot invoke an instance of '#type' because it declares 'call' to be something other than a method."
- tip: "Try changing 'call' to a method or explicitly invoke 'call'."
+ problemMessage: "Cannot invoke an instance of '#type' because it declares 'call' to be something other than a method."
+ correctionMessage: "Try changing 'call' to a method or explicitly invoke 'call'."
analyzerCode: IMPLICIT_CALL_OF_NON_METHOD
ExpectedOneExpression:
- template: "Expected one expression, but found additional input."
+ problemMessage: "Expected one expression, but found additional input."
ForInLoopNotAssignable:
- template: "Can't assign to this, so it can't be used in a for-in loop."
+ problemMessage: "Can't assign to this, so it can't be used in a for-in loop."
statement: "for (1 in []) {}"
ForInLoopExactlyOneVariable:
- template: "A for-in loop can't have more than one loop variable."
+ problemMessage: "A for-in loop can't have more than one loop variable."
statement: "for (var x, y in []) {}"
ForInLoopWithConstVariable:
- template: "A for-in loop-variable can't be 'const'."
- tip: "Try removing the 'const' modifier."
+ problemMessage: "A for-in loop-variable can't be 'const'."
+ correctionMessage: "Try removing the 'const' modifier."
analyzerCode: FOR_IN_WITH_CONST_VARIABLE
ForInLoopElementTypeNotAssignable:
- template: "A value of type '#type' can't be assigned to a variable of type '#type2'."
- tip: "Try changing the type of the variable."
+ problemMessage: "A value of type '#type' can't be assigned to a variable of type '#type2'."
+ correctionMessage: "Try changing the type of the variable."
analyzerCode: FOR_IN_OF_INVALID_ELEMENT_TYPE
script: |
method() {
@@ -3837,8 +3837,8 @@
}
ForInLoopElementTypeNotAssignableNullability:
- template: "A value of type '#type' can't be assigned to a variable of type '#type2' because '#type' is nullable and '#type2' isn't."
- tip: "Try changing the type of the variable."
+ problemMessage: "A value of type '#type' can't be assigned to a variable of type '#type2' because '#type' is nullable and '#type2' isn't."
+ correctionMessage: "Try changing the type of the variable."
analyzerCode: FOR_IN_OF_INVALID_ELEMENT_TYPE
configuration: nnbd-strong
script: |
@@ -3848,8 +3848,8 @@
}
ForInLoopElementTypeNotAssignablePartNullability:
- template: "A value of type '#type' can't be assigned to a variable of type '#type2' because '#type3' is nullable and '#type4' isn't."
- tip: "Try changing the type of the variable."
+ problemMessage: "A value of type '#type' can't be assigned to a variable of type '#type2' because '#type3' is nullable and '#type4' isn't."
+ correctionMessage: "Try changing the type of the variable."
analyzerCode: FOR_IN_OF_INVALID_ELEMENT_TYPE
configuration: nnbd-strong
script: |
@@ -3859,7 +3859,7 @@
}
ForInLoopTypeNotIterable:
- template: "The type '#type' used in the 'for' loop must implement '#type2'."
+ problemMessage: "The type '#type' used in the 'for' loop must implement '#type2'."
analyzerCode: FOR_IN_OF_INVALID_TYPE
script: |
method() {
@@ -3868,7 +3868,7 @@
}
ForInLoopTypeNotIterableNullability:
- template: "The type '#type' used in the 'for' loop must implement '#type2' because '#type' is nullable and '#type2' isn't."
+ problemMessage: "The type '#type' used in the 'for' loop must implement '#type2' because '#type' is nullable and '#type2' isn't."
analyzerCode: FOR_IN_OF_INVALID_TYPE
configuration: nnbd-strong
script: |
@@ -3881,12 +3881,12 @@
# only be a problem at the immediate level as in [ForInLoopTypeNotIterableNullability]. The message is needed for
# symmetry in the call site.
ForInLoopTypeNotIterablePartNullability:
- template: "The type '#type' used in the 'for' loop must implement '#type2' because '#type3' is nullable and '#type4' isn't."
+ problemMessage: "The type '#type' used in the 'for' loop must implement '#type2' because '#type3' is nullable and '#type4' isn't."
analyzerCode: FOR_IN_OF_INVALID_TYPE
InitializingFormalTypeMismatch:
- template: "The type of parameter '#name', '#type' is not a subtype of the corresponding field's type, '#type2'."
- tip: "Try changing the type of parameter '#name' to a subtype of '#type2'."
+ problemMessage: "The type of parameter '#name', '#type' is not a subtype of the corresponding field's type, '#type2'."
+ correctionMessage: "Try changing the type of parameter '#name' to a subtype of '#type2'."
analyzerCode: INVALID_PARAMETER_DECLARATION
script: >
class C {
@@ -3895,11 +3895,11 @@
}
InitializingFormalTypeMismatchField:
- template: "The field that corresponds to the parameter."
+ problemMessage: "The field that corresponds to the parameter."
severity: CONTEXT
InitializeFromDillNotSelfContained:
- template: |
+ problemMessage: |
Tried to initialize from a previous compilation (#string), but the file was not self-contained. This might be a bug.
The Dart team would greatly appreciate it if you would take a moment to report this problem at http://dartbug.com/new.
@@ -3911,7 +3911,7 @@
external: test/incremental_load_from_invalid_dill_test.dart
InitializeFromDillNotSelfContainedNoDump:
- template: |
+ problemMessage: |
Tried to initialize from a previous compilation (#string), but the file was not self-contained. This might be a bug.
The Dart team would greatly appreciate it if you would take a moment to report this problem at http://dartbug.com/new.
@@ -3921,7 +3921,7 @@
external: test/incremental_load_from_invalid_dill_test.dart
InitializeFromDillUnknownProblem:
- template: |
+ problemMessage: |
Tried to initialize from a previous compilation (#string), but couldn't.
Error message was '#string2'.
Stacktrace included '#string3'.
@@ -3936,7 +3936,7 @@
external: test/incremental_load_from_invalid_dill_test.dart
InitializeFromDillUnknownProblemNoDump:
- template: |
+ problemMessage: |
Tried to initialize from a previous compilation (#string), but couldn't.
Error message was '#string2'.
Stacktrace included '#string3'.
@@ -3949,56 +3949,56 @@
external: test/incremental_load_from_invalid_dill_test.dart
WebLiteralCannotBeRepresentedExactly:
- template: "The integer literal #string can't be represented exactly in JavaScript."
- tip: "Try changing the literal to something that can be represented in Javascript. In Javascript #string2 is the nearest value that can be represented exactly."
+ problemMessage: "The integer literal #string can't be represented exactly in JavaScript."
+ correctionMessage: "Try changing the literal to something that can be represented in Javascript. In Javascript #string2 is the nearest value that can be represented exactly."
BoundIssueViaRawTypeWithNonSimpleBounds:
- template: "Generic type '#name' can't be used without type arguments in a type variable bound."
- tip: "Try providing type arguments to '#name' here."
+ problemMessage: "Generic type '#name' can't be used without type arguments in a type variable bound."
+ correctionMessage: "Try providing type arguments to '#name' here."
analyzerCode: NOT_INSTANTIATED_BOUND
script: >
class Hest<X extends Hest<X>> {}
class Fisk<Y extends Hest> {}
NonSimpleBoundViaVariable:
- template: "Bound of this variable references variable '#name' from the same declaration."
+ problemMessage: "Bound of this variable references variable '#name' from the same declaration."
severity: CONTEXT
BoundIssueViaLoopNonSimplicity:
- template: "Generic type '#name' can't be used without type arguments in the bounds of its own type variables."
- tip: "Try providing type arguments to '#name' here."
+ problemMessage: "Generic type '#name' can't be used without type arguments in the bounds of its own type variables."
+ correctionMessage: "Try providing type arguments to '#name' here."
analyzerCode: NOT_INSTANTIATED_BOUND
script: >
class Hest<X extends Hest> {}
BoundIssueViaCycleNonSimplicity:
- template: "Generic type '#name' can't be used without type arguments in the bounds of its own type variables. It is referenced indirectly through '#name2'."
- tip: "Try providing type arguments to '#name2' here or to some other raw types in the bounds along the reference chain."
+ problemMessage: "Generic type '#name' can't be used without type arguments in the bounds of its own type variables. It is referenced indirectly through '#name2'."
+ correctionMessage: "Try providing type arguments to '#name2' here or to some other raw types in the bounds along the reference chain."
analyzerCode: NOT_INSTANTIATED_BOUND
script: >
class Hest<X extends Fisk> {}
class Fisk<Y extends Hest> {}
NonSimpleBoundViaReference:
- template: "Bound of this variable references raw type '#name'."
+ problemMessage: "Bound of this variable references raw type '#name'."
severity: CONTEXT
CycleInTypeVariables:
- template: "Type '#name' is a bound of itself via '#string'."
- tip: "Try breaking the cycle by removing at least on of the 'extends' clauses in the cycle."
+ problemMessage: "Type '#name' is a bound of itself via '#string'."
+ correctionMessage: "Try breaking the cycle by removing at least on of the 'extends' clauses in the cycle."
analyzerCode: TYPE_PARAMETER_SUPERTYPE_OF_ITS_BOUND
script:
- "foo<A extends B, B extends A>() {}"
DirectCycleInTypeVariables:
- template: "Type '#name' can't use itself as a bound."
- tip: "Try breaking the cycle by removing at least on of the 'extends' clauses in the cycle."
+ problemMessage: "Type '#name' can't use itself as a bound."
+ correctionMessage: "Try breaking the cycle by removing at least on of the 'extends' clauses in the cycle."
analyzerCode: TYPE_PARAMETER_SUPERTYPE_OF_ITS_BOUND
script:
- "foo<A extends A>() {}"
CantUsePrefixAsExpression:
- template: "A prefix can't be used as an expression."
+ problemMessage: "A prefix can't be used as an expression."
analyzerCode: PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT
script: |
import "dart:core" as prefix;
@@ -4008,8 +4008,8 @@
}
CantUsePrefixWithNullAware:
- template: "A prefix can't be used with null-aware operators."
- tip: "Try replacing '?.' with '.'"
+ problemMessage: "A prefix can't be used with null-aware operators."
+ correctionMessage: "Try replacing '?.' with '.'"
analyzerCode: PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT
script: |
import "dart:core" as prefix;
@@ -4019,14 +4019,14 @@
}
CantUseControlFlowOrSpreadAsConstant:
- template: "'#lexeme' is not supported in constant expressions."
+ problemMessage: "'#lexeme' is not supported in constant expressions."
analyzerCode: NOT_CONSTANT_EXPRESSION
CantUseDeferredPrefixAsConstant:
- template: >
+ problemMessage: >
'#lexeme' can't be used in a constant expression because it's marked as
'deferred' which means it isn't available until loaded.
- tip: >
+ correctionMessage: >
Try moving the constant from the deferred library, or removing 'deferred'
from the import.
analyzerCode: CONST_DEFERRED_CLASS
@@ -4038,7 +4038,7 @@
}
CyclicRedirectingFactoryConstructors:
- template: "Cyclic definition of factory '#name'."
+ problemMessage: "Cyclic definition of factory '#name'."
analyzerCode: RECURSIVE_FACTORY_REDIRECT
script: |
class Foo {
@@ -4048,14 +4048,14 @@
main() { var foo = new Foo.foo(); }
GenericFunctionTypeInBound:
- template: "Type variables can't have generic function types in their bounds."
+ problemMessage: "Type variables can't have generic function types in their bounds."
analyzerCode: GENERIC_FUNCTION_TYPE_CANNOT_BE_BOUND
script: |
// @dart=2.13
class Hest<X extends Y Function<Y>(Y)> {}
VoidExpression:
- template: "This expression has type 'void' and can't be used."
+ problemMessage: "This expression has type 'void' and can't be used."
analyzerCode: USE_OF_VOID_RESULT
statement: |
{
@@ -4064,12 +4064,12 @@
}
ReturnFromVoidFunction:
- template: "Can't return a value from a void function."
+ problemMessage: "Can't return a value from a void function."
analyzerCode: RETURN_OF_INVALID_TYPE
declaration: "void foo() { return 1; }"
ReturnWithoutExpression:
- template: "Must explicitly return a value from a non-void function."
+ problemMessage: "Must explicitly return a value from a non-void function."
severity: WARNING
analyzerCode: RETURN_WITHOUT_VALUE
script: |
@@ -4077,79 +4077,79 @@
int foo() { return; }
ReturnWithoutExpressionSync:
- template: "A value must be explicitly returned from a non-void function."
+ problemMessage: "A value must be explicitly returned from a non-void function."
configuration: nnbd-strong
script: |
import "dart:async";
FutureOr<Object?> foo() { return; }
ReturnWithoutExpressionAsync:
- template: "A value must be explicitly returned from a non-void async function."
+ problemMessage: "A value must be explicitly returned from a non-void async function."
configuration: nnbd-strong
declaration: "Future<int> foo() async { return; }"
InvalidReturn:
- template: "A value of type '#type' can't be returned from a function with return type '#type2'."
+ problemMessage: "A value of type '#type' can't be returned from a function with return type '#type2'."
configuration: nnbd-strong
declaration: "int foo() { return true; }"
InvalidReturnNullability:
- template: "A value of type '#type' can't be returned from a function with return type '#type2' because '#type' is nullable and '#type2' isn't."
+ problemMessage: "A value of type '#type' can't be returned from a function with return type '#type2' because '#type' is nullable and '#type2' isn't."
configuration: nnbd-strong
declaration: "int foo(int? i) { return i; }"
InvalidReturnPartNullability:
- template: "A value of type '#type' can't be returned from a function with return type '#type2' because '#type3' is nullable and '#type4' isn't."
+ problemMessage: "A value of type '#type' can't be returned from a function with return type '#type2' because '#type3' is nullable and '#type4' isn't."
configuration: nnbd-strong
declaration: "List<int> foo(List<int?> list) { return list; }"
InvalidReturnNullabilityNull:
- template: "The value 'null' can't be returned from a function with return type '#type' because '#type' is not nullable."
+ problemMessage: "The value 'null' can't be returned from a function with return type '#type' because '#type' is not nullable."
configuration: nnbd-strong
declaration: "int foo() { return null; }"
InvalidReturnNullabilityNullType:
- template: "A value of type '#type' can't be returned from a function with return type '#type2' because '#type2' is not nullable."
+ problemMessage: "A value of type '#type' can't be returned from a function with return type '#type2' because '#type2' is not nullable."
configuration: nnbd-strong
declaration: "int foo(Null i) { return i; }"
InvalidReturnAsync:
- template: "A value of type '#type' can't be returned from an async function with return type '#type2'."
+ problemMessage: "A value of type '#type' can't be returned from an async function with return type '#type2'."
configuration: nnbd-strong
declaration: "Future<int> foo() async { return true; }"
InvalidReturnAsyncNullability:
- template: "A value of type '#type' can't be returned from an async function with return type '#type2' because '#type' is nullable and '#type2' isn't."
+ problemMessage: "A value of type '#type' can't be returned from an async function with return type '#type2' because '#type' is nullable and '#type2' isn't."
configuration: nnbd-strong
declaration: "Future<int> foo(int? i) async { return i; }"
InvalidReturnAsyncPartNullability:
- template: "A value of type '#type' can't be returned from an async function with return type '#type2' because '#type3' is nullable and '#type4' isn't."
+ problemMessage: "A value of type '#type' can't be returned from an async function with return type '#type2' because '#type3' is nullable and '#type4' isn't."
configuration: nnbd-strong
declaration: "Future<List<int>> foo(List<int?> list) async { return list; }"
InvalidReturnAsyncNullabilityNull:
- template: "The value 'null' can't be returned from an async function with return type '#type' because '#type' is not nullable."
+ problemMessage: "The value 'null' can't be returned from an async function with return type '#type' because '#type' is not nullable."
configuration: nnbd-strong
declaration: "Future<int> foo() async { return null; }"
InvalidReturnAsyncNullabilityNullType:
- template: "A value of type '#type' can't be returned from an async function with return type '#type2' because '#type2' is not nullable."
+ problemMessage: "A value of type '#type' can't be returned from an async function with return type '#type2' because '#type2' is not nullable."
configuration: nnbd-strong
declaration: "Future<int> foo(Null n) async { return n; }"
ImplicitReturnNull:
- template: "A non-null value must be returned since the return type '#type' doesn't allow null."
+ problemMessage: "A non-null value must be returned since the return type '#type' doesn't allow null."
configuration: nnbd-strong
script: |
String method() {}
RethrowNotCatch:
- template: "'rethrow' can only be used in catch clauses."
+ problemMessage: "'rethrow' can only be used in catch clauses."
analyzerCode: RETHROW_OUTSIDE_CATCH
InvokeNonFunction:
- template: "'#name' isn't a function or method and can't be invoked."
+ problemMessage: "'#name' isn't a function or method and can't be invoked."
analyzerCode: INVOCATION_OF_NON_FUNCTION
script: |
// @dart=2.9
@@ -4162,15 +4162,15 @@
}
ConstInstanceField:
- template: "Only static fields can be declared as const."
- tip: "Try using 'final' instead of 'const', or adding the keyword 'static'."
+ problemMessage: "Only static fields can be declared as const."
+ correctionMessage: "Try using 'final' instead of 'const', or adding the keyword 'static'."
analyzerCode: CONST_INSTANCE_FIELD
script:
- "class C { const field = 0; }"
DefaultValueInRedirectingFactoryConstructor:
- template: "Can't have a default value here because any default values of '#name' would be used instead."
- tip: "Try removing the default value."
+ problemMessage: "Can't have a default value here because any default values of '#name' would be used instead."
+ correctionMessage: "Try removing the default value."
analyzerCode: DEFAULT_VALUE_IN_REDIRECTING_FACTORY_CONSTRUCTOR
script:
- >-
@@ -4180,7 +4180,7 @@
}
UntranslatableUri:
- template: "Not found: '#uri'"
+ problemMessage: "Not found: '#uri'"
analyzerCode: URI_DOES_NOT_EXIST
script: |
import "dart:non_existing_library";
@@ -4189,7 +4189,7 @@
}
CantReadFile:
- template: "Error when reading '#uri': #string"
+ problemMessage: "Error when reading '#uri': #string"
analyzerCode: URI_DOES_NOT_EXIST
external: test/packages_format_error_test.dart
script: |
@@ -4199,14 +4199,14 @@
}
ExceptionReadingFile:
- template: "Exception when reading '#uri': #string"
+ problemMessage: "Exception when reading '#uri': #string"
PackagesFileFormat:
- template: "Problem in packages configuration file: #string"
+ problemMessage: "Problem in packages configuration file: #string"
external: test/packages_format_error_test.dart
IncompatibleRedirecteeFunctionType:
- template: "The constructor function type '#type' isn't a subtype of '#type2'."
+ problemMessage: "The constructor function type '#type' isn't a subtype of '#type2'."
analyzerCode: REDIRECT_TO_INVALID_TYPE
script:
- >-
@@ -4243,8 +4243,8 @@
class B<T extends int, S extends String> implements A<T> {}
RedirectingFactoryIncompatibleTypeArgument:
- template: "The type '#type' doesn't extend '#type2'."
- tip: "Try using a different type as argument."
+ problemMessage: "The type '#type' doesn't extend '#type2'."
+ correctionMessage: "Try using a different type as argument."
analyzerCode: TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
script:
- >-
@@ -4254,68 +4254,68 @@
class B<T extends int, S extends String> implements A<T> {}
SyntheticToken:
- template: "This couldn't be parsed."
+ problemMessage: "This couldn't be parsed."
frontendInternal: true
IncorrectTypeArgument:
- template: "Type argument '#type' doesn't conform to the bound '#type2' of the type variable '#name' on '#name2'."
- tip: "Try changing type arguments so that they conform to the bounds."
+ problemMessage: "Type argument '#type' doesn't conform to the bound '#type2' of the type variable '#name' on '#name2'."
+ correctionMessage: "Try changing type arguments so that they conform to the bounds."
analyzerCode: TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
script: >
class C<T extends num> {}
main() { new C<String>(); }
IncorrectTypeArgumentQualified:
- template: "Type argument '#type' doesn't conform to the bound '#type2' of the type variable '#name' on '#type3.#name2'."
- tip: "Try changing type arguments so that they conform to the bounds."
+ problemMessage: "Type argument '#type' doesn't conform to the bound '#type2' of the type variable '#name' on '#type3.#name2'."
+ correctionMessage: "Try changing type arguments so that they conform to the bounds."
analyzerCode: TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
script: >
class C<T> { foo<U extends num>() {} }
main() { new C<String>().foo<String>(); }
IncorrectTypeArgumentInSupertype:
- template: "Type argument '#type' doesn't conform to the bound '#type2' of the type variable '#name' on '#name2' in the supertype '#name3' of class '#name4'."
- tip: "Try changing type arguments so that they conform to the bounds."
+ problemMessage: "Type argument '#type' doesn't conform to the bound '#type2' of the type variable '#name' on '#name2' in the supertype '#name3' of class '#name4'."
+ correctionMessage: "Try changing type arguments so that they conform to the bounds."
analyzerCode: TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
script: >
class A<T extends num> {}
class B extends A<String> {}
IncorrectTypeArgumentInReturnType:
- template: "Type argument '#type' doesn't conform to the bound '#type2' of the type variable '#name' on '#name2' in the return type."
- tip: "Try changing type arguments so that they conform to the bounds."
+ problemMessage: "Type argument '#type' doesn't conform to the bound '#type2' of the type variable '#name' on '#name2' in the return type."
+ correctionMessage: "Try changing type arguments so that they conform to the bounds."
analyzerCode: TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
script: >
class A<T extends num> {}
A<String> foo() => throw '';
IncorrectTypeArgumentInferred:
- template: "Inferred type argument '#type' doesn't conform to the bound '#type2' of the type variable '#name' on '#name2'."
- tip: "Try specifying type arguments explicitly so that they conform to the bounds."
+ problemMessage: "Inferred type argument '#type' doesn't conform to the bound '#type2' of the type variable '#name' on '#name2'."
+ correctionMessage: "Try specifying type arguments explicitly so that they conform to the bounds."
analyzerCode: TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
script: >
void foo<T extends num>(T t) {}
main() { foo("bar"); }
IncorrectTypeArgumentQualifiedInferred:
- template: "Inferred type argument '#type' doesn't conform to the bound '#type2' of the type variable '#name' on '#type3.#name2'."
- tip: "Try specifying type arguments explicitly so that they conform to the bounds."
+ problemMessage: "Inferred type argument '#type' doesn't conform to the bound '#type2' of the type variable '#name' on '#type3.#name2'."
+ correctionMessage: "Try specifying type arguments explicitly so that they conform to the bounds."
analyzerCode: TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
script: >
class C<T> { foo<U extends num>(U u) {} }
main() { new C<String>().foo(""); }
IncorrectTypeArgumentInSupertypeInferred:
- template: "Inferred type argument '#type' doesn't conform to the bound '#type2' of the type variable '#name' on '#name2' in the supertype '#name3' of class '#name4'."
- tip: "Try specifying type arguments explicitly so that they conform to the bounds."
+ problemMessage: "Inferred type argument '#type' doesn't conform to the bound '#type2' of the type variable '#name' on '#name2' in the supertype '#name3' of class '#name4'."
+ correctionMessage: "Try specifying type arguments explicitly so that they conform to the bounds."
analyzerCode: TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
script: >
class A<T extends A<T>> {}
class B extends A {}
IncorrectTypeArgumentInstantiation:
- template: "Type argument '#type' doesn't conform to the bound '#type2' of the type variable '#name' on '#type3'."
- tip: "Try changing type arguments so that they conform to the bounds."
+ problemMessage: "Type argument '#type' doesn't conform to the bound '#type2' of the type variable '#name' on '#type3'."
+ correctionMessage: "Try changing type arguments so that they conform to the bounds."
analyzerCode: TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
experiments: constructor-tearoffs
script: |
@@ -4325,8 +4325,8 @@
}
IncorrectTypeArgumentInstantiationInferred:
- template: "Inferred type argument '#type' doesn't conform to the bound '#type2' of the type variable '#name' on '#type3'."
- tip: "Try specifying type arguments explicitly so that they conform to the bounds."
+ problemMessage: "Inferred type argument '#type' doesn't conform to the bound '#type2' of the type variable '#name' on '#type3'."
+ correctionMessage: "Try specifying type arguments explicitly so that they conform to the bounds."
analyzerCode: TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
script: |
X bounded<X extends num>(X x) => x;
@@ -4335,15 +4335,15 @@
}
IncorrectTypeArgumentVariable:
- template: "This is the type variable whose bound isn't conformed to."
+ problemMessage: "This is the type variable whose bound isn't conformed to."
severity: CONTEXT
SuperBoundedHint:
- template: "If you want '#type' to be a super-bounded type, note that the inverted type '#type2' must then satisfy its bounds, which it does not."
+ problemMessage: "If you want '#type' to be a super-bounded type, note that the inverted type '#type2' must then satisfy its bounds, which it does not."
severity: CONTEXT
InferredPackageUri:
- template: "Interpreting this as package URI, '#uri'."
+ problemMessage: "Interpreting this as package URI, '#uri'."
severity: WARNING
frontendInternal: true
script:
@@ -4353,7 +4353,7 @@
example:./
MixinApplicationIncompatibleSupertype:
- template: "'#type' doesn't implement '#type2' so it can't be used with '#type3'."
+ problemMessage: "'#type' doesn't implement '#type2' so it can't be used with '#type3'."
analyzerCode: MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE
script: >-
class I {}
@@ -4361,8 +4361,8 @@
class C = Object with M;
GenericFunctionTypeUsedAsActualTypeArgument:
- template: "A generic function type can't be used as a type argument."
- tip: "Try using a non-generic function type."
+ problemMessage: "A generic function type can't be used as a type argument."
+ correctionMessage: "Try using a non-generic function type."
analyzerCode: GENERIC_FUNCTION_CANNOT_BE_TYPE_ARGUMENT
script:
- |
@@ -4381,8 +4381,8 @@
}
GenericFunctionTypeInferredAsActualTypeArgument:
- template: "Generic function type '#type' inferred as a type argument."
- tip: "Try providing a non-generic function type explicitly."
+ problemMessage: "Generic function type '#type' inferred as a type argument."
+ correctionMessage: "Try providing a non-generic function type explicitly."
analyzerCode: GENERIC_FUNCTION_CANNOT_BE_TYPE_ARGUMENT
script: |
// @dart=2.13
@@ -4393,32 +4393,32 @@
# These two message templates are used for constructing supplemental text
# about the origins of raw interface types in error messages containing types.
TypeOrigin:
- template: "'#name' is from '#uri'."
+ problemMessage: "'#name' is from '#uri'."
frontendInternal: true
external: test/type_labeler_test.dart
TypeOriginWithFileUri:
- template: "'#name' is from '#uri' ('#uri2')."
+ problemMessage: "'#name' is from '#uri' ('#uri2')."
frontendInternal: true
external: test/type_labeler_test.dart
ObjectExtends:
- template: "The class 'Object' can't have a superclass."
+ problemMessage: "The class 'Object' can't have a superclass."
frontendInternal: true
external: test/fasta/object_supertype_test.dart
ObjectImplements:
- template: "The class 'Object' can't implement anything."
+ problemMessage: "The class 'Object' can't implement anything."
frontendInternal: true
external: test/fasta/object_supertype_test.dart
ObjectMixesIn:
- template: "The class 'Object' can't use mixins."
+ problemMessage: "The class 'Object' can't use mixins."
frontendInternal: true
external: test/fasta/object_supertype_test.dart
StaticAndInstanceConflict:
- template: "This static member conflicts with an instance member."
+ problemMessage: "This static member conflicts with an instance member."
script:
- |
class C {
@@ -4433,139 +4433,139 @@
analyzerCode: CONFLICTING_STATIC_AND_INSTANCE
StaticAndInstanceConflictCause:
- template: "This is the instance member."
+ problemMessage: "This is the instance member."
severity: CONTEXT
FfiTypeMismatch:
# Used by dart:ffi
- template: "Expected type '#type' to be '#type2', which is the Dart type corresponding to '#type3'."
+ problemMessage: "Expected type '#type' to be '#type2', which is the Dart type corresponding to '#type3'."
external: test/ffi_test.dart
FfiEmptyStruct:
# Used by dart:ffi
- template: "#string '#name' is empty. Empty structs and unions are undefined behavior."
+ problemMessage: "#string '#name' is empty. Empty structs and unions are undefined behavior."
external: test/ffi_test.dart
FfiTypeInvalid:
# Used by dart:ffi
- template: "Expected type '#type' to be a valid and instantiated subtype of 'NativeType'."
+ problemMessage: "Expected type '#type' to be a valid and instantiated subtype of 'NativeType'."
external: test/ffi_test.dart
FfiFieldNull:
# Used by dart:ffi
- template: "Field '#name' cannot have type 'Null', it must be `int`, `double`, `Pointer`, or a subtype of `Struct` or `Union`."
+ problemMessage: "Field '#name' cannot have type 'Null', it must be `int`, `double`, `Pointer`, or a subtype of `Struct` or `Union`."
external: test/ffi_test.dart
FfiFieldAnnotation:
# Used by dart:ffi
- template: "Field '#name' requires exactly one annotation to declare its native type, which cannot be Void. dart:ffi Structs and Unions cannot have regular Dart fields."
+ problemMessage: "Field '#name' requires exactly one annotation to declare its native type, which cannot be Void. dart:ffi Structs and Unions cannot have regular Dart fields."
external: test/ffi_test.dart
FfiFieldNoAnnotation:
# Used by dart:ffi
- template: "Field '#name' requires no annotation to declare its native type, it is a Pointer which is represented by the same type in Dart and native code."
+ problemMessage: "Field '#name' requires no annotation to declare its native type, it is a Pointer which is represented by the same type in Dart and native code."
external: test/ffi_test.dart
FfiFieldCyclic:
# Used by dart:ffi
- template: |
+ problemMessage: |
#string '#name' contains itself. Cycle elements:
#names
external: test/ffi_test.dart
FfiNotStatic:
# Used by dart:ffi
- template: "#name expects a static function as parameter. dart:ffi only supports calling static Dart functions from native code. Closures and tear-offs are not supported because they can capture context."
+ problemMessage: "#name expects a static function as parameter. dart:ffi only supports calling static Dart functions from native code. Closures and tear-offs are not supported because they can capture context."
external: test/ffi_test.dart
FfiFieldInitializer:
# Used by dart:ffi
- template: "Field '#name' is a dart:ffi Pointer to a struct field and therefore cannot be initialized before constructor execution."
- tip: "Mark the field as external to avoid having to initialize it."
+ problemMessage: "Field '#name' is a dart:ffi Pointer to a struct field and therefore cannot be initialized before constructor execution."
+ correctionMessage: "Mark the field as external to avoid having to initialize it."
external: test/ffi_test.dart
FfiExtendsOrImplementsSealedClass:
# Used by dart:ffi
- template: "Class '#name' cannot be extended or implemented."
+ problemMessage: "Class '#name' cannot be extended or implemented."
external: test/ffi_test.dart
FfiPackedAnnotation:
# Used by dart:ffi
- template: "Struct '#name' must have at most one 'Packed' annotation."
+ problemMessage: "Struct '#name' must have at most one 'Packed' annotation."
external: test/ffi_test.dart
FfiPackedAnnotationAlignment:
# Used by dart:ffi
- template: "Only packing to 1, 2, 4, 8, and 16 bytes is supported."
+ problemMessage: "Only packing to 1, 2, 4, 8, and 16 bytes is supported."
external: test/ffi_test.dart
FfiPackedNestingNonPacked:
# Used by dart:ffi
- template: "Nesting the non-packed or less tightly packed struct '#name' in a packed struct '#name2' is not supported."
+ problemMessage: "Nesting the non-packed or less tightly packed struct '#name' in a packed struct '#name2' is not supported."
external: test/ffi_test.dart
FfiSizeAnnotation:
# Used by dart:ffi
- template: "Field '#name' must have exactly one 'Array' annotation."
+ problemMessage: "Field '#name' must have exactly one 'Array' annotation."
external: test/ffi_test.dart
FfiSizeAnnotationDimensions:
# Used by dart:ffi
- template: "Field '#name' must have an 'Array' annotation that matches the dimensions."
+ problemMessage: "Field '#name' must have an 'Array' annotation that matches the dimensions."
external: test/ffi_test.dart
FfiStructGeneric:
# Used by dart:ffi
- template: "#string '#name' should not be generic."
+ problemMessage: "#string '#name' should not be generic."
external: test/ffi_test.dart
FfiDartTypeMismatch:
# Used by dart:ffi
- template: "Expected '#type' to be a subtype of '#type2'."
+ problemMessage: "Expected '#type' to be a subtype of '#type2'."
external: test/ffi_test.dart
FfiExpectedExceptionalReturn:
# Used by dart:ffi
- template: "Expected an exceptional return value for a native callback returning '#type'."
+ problemMessage: "Expected an exceptional return value for a native callback returning '#type'."
external: test/ffi_test.dart
FfiExpectedNoExceptionalReturn:
# Used by dart:ffi
- template: "Exceptional return value cannot be provided for a native callback returning '#type'."
+ problemMessage: "Exceptional return value cannot be provided for a native callback returning '#type'."
external: test/ffi_test.dart
FfiExpectedConstant:
# Used by dart:ffi
- template: "Exceptional return value must be a constant."
+ problemMessage: "Exceptional return value must be a constant."
external: test/ffi_test.dart
FfiExceptionalReturnNull:
# Used by dart:ffi
- template: "Exceptional return value must not be null."
+ problemMessage: "Exceptional return value must not be null."
external: test/ffi_test.dart
FfiExpectedConstantArg:
# Used by dart:ffi
- template: "Argument '#name' must be a constant."
+ problemMessage: "Argument '#name' must be a constant."
external: test/ffi_test.dart
FfiLeafCallMustNotTakeHandle:
# Used by dart:ffi
- template: "FFI leaf call must not have Handle argument types."
+ problemMessage: "FFI leaf call must not have Handle argument types."
external: test/ffi_test.dart
FfiLeafCallMustNotReturnHandle:
# Used by dart:ffi
- template: "FFI leaf call must not have Handle return type."
+ problemMessage: "FFI leaf call must not have Handle return type."
external: test/ffi_test.dart
FfiNativeAnnotationMustAnnotateStatic:
# Used by dart:ffi
- template: "FfiNative annotations can only be used on static functions."
+ problemMessage: "FfiNative annotations can only be used on static functions."
external: test/ffi_test.dart
SpreadTypeMismatch:
- template: "Unexpected type '#type' of a spread. Expected 'dynamic' or an Iterable."
+ problemMessage: "Unexpected type '#type' of a spread. Expected 'dynamic' or an Iterable."
script:
- |
main() {
@@ -4579,7 +4579,7 @@
}
SpreadElementTypeMismatch:
- template: "Can't assign spread elements of type '#type' to collection elements of type '#type2'."
+ problemMessage: "Can't assign spread elements of type '#type' to collection elements of type '#type2'."
analyzerCode: LIST_ELEMENT_TYPE_NOT_ASSIGNABLE
script: >
main() {
@@ -4588,7 +4588,7 @@
}
SpreadElementTypeMismatchNullability:
- template: "Can't assign spread elements of type '#type' to collection elements of type '#type2' because '#type' is nullable and '#type2' isn't."
+ problemMessage: "Can't assign spread elements of type '#type' to collection elements of type '#type2' because '#type' is nullable and '#type2' isn't."
analyzerCode: LIST_ELEMENT_TYPE_NOT_ASSIGNABLE
configuration: nnbd-strong
script: >
@@ -4598,7 +4598,7 @@
}
SpreadElementTypeMismatchPartNullability:
- template: "Can't assign spread elements of type '#type' to collection elements of type '#type2' because '#type3' is nullable and '#type4' isn't."
+ problemMessage: "Can't assign spread elements of type '#type' to collection elements of type '#type2' because '#type3' is nullable and '#type4' isn't."
analyzerCode: LIST_ELEMENT_TYPE_NOT_ASSIGNABLE
configuration: nnbd-strong
script: >
@@ -4608,7 +4608,7 @@
}
SpreadMapEntryTypeMismatch:
- template: "Unexpected type '#type' of a map spread entry. Expected 'dynamic' or a Map."
+ problemMessage: "Unexpected type '#type' of a map spread entry. Expected 'dynamic' or a Map."
script:
- |
main() {
@@ -4622,7 +4622,7 @@
}
SpreadMapEntryElementKeyTypeMismatch:
- template: "Can't assign spread entry keys of type '#type' to map entry keys of type '#type2'."
+ problemMessage: "Can't assign spread entry keys of type '#type' to map entry keys of type '#type2'."
analyzerCode: MAP_KEY_TYPE_NOT_ASSIGNABLE
script: >
main() {
@@ -4631,7 +4631,7 @@
}
SpreadMapEntryElementKeyTypeMismatchNullability:
- template: "Can't assign spread entry keys of type '#type' to map entry keys of type '#type2' because '#type' is nullable and '#type2' isn't."
+ problemMessage: "Can't assign spread entry keys of type '#type' to map entry keys of type '#type2' because '#type' is nullable and '#type2' isn't."
analyzerCode: MAP_KEY_TYPE_NOT_ASSIGNABLE
configuration: nnbd-strong
script: >
@@ -4641,7 +4641,7 @@
}
SpreadMapEntryElementKeyTypeMismatchPartNullability:
- template: "Can't assign spread entry keys of type '#type' to map entry keys of type '#type2' because '#type3' is nullable and '#type4' isn't."
+ problemMessage: "Can't assign spread entry keys of type '#type' to map entry keys of type '#type2' because '#type3' is nullable and '#type4' isn't."
analyzerCode: MAP_KEY_TYPE_NOT_ASSIGNABLE
configuration: nnbd-strong
script: >
@@ -4651,7 +4651,7 @@
}
SpreadMapEntryElementValueTypeMismatch:
- template: "Can't assign spread entry values of type '#type' to map entry values of type '#type2'."
+ problemMessage: "Can't assign spread entry values of type '#type' to map entry values of type '#type2'."
analyzerCode: MAP_VALUE_TYPE_NOT_ASSIGNABLE
script: >
main() {
@@ -4660,7 +4660,7 @@
}
SpreadMapEntryElementValueTypeMismatchNullability:
- template: "Can't assign spread entry values of type '#type' to map entry values of type '#type2' because '#type' is nullable and '#type2' isn't."
+ problemMessage: "Can't assign spread entry values of type '#type' to map entry values of type '#type2' because '#type' is nullable and '#type2' isn't."
analyzerCode: MAP_VALUE_TYPE_NOT_ASSIGNABLE
configuration: nnbd-strong
script: >
@@ -4670,7 +4670,7 @@
}
SpreadMapEntryElementValueTypeMismatchPartNullability:
- template: "Can't assign spread entry values of type '#type' to map entry values of type '#type2' because '#type3' is nullable and '#type4' isn't."
+ problemMessage: "Can't assign spread entry values of type '#type' to map entry values of type '#type2' because '#type3' is nullable and '#type4' isn't."
analyzerCode: MAP_VALUE_TYPE_NOT_ASSIGNABLE
configuration: nnbd-strong
script: >
@@ -4680,30 +4680,30 @@
}
CantDisambiguateNotEnoughInformation:
- template: "Not enough type information to disambiguate between literal set and literal map."
- tip: "Try providing type arguments for the literal explicitly to disambiguate it."
+ problemMessage: "Not enough type information to disambiguate between literal set and literal map."
+ correctionMessage: "Try providing type arguments for the literal explicitly to disambiguate it."
script: >
foo(dynamic spread) {
var a = {...spread};
}
CantDisambiguateAmbiguousInformation:
- template: "Both Iterable and Map spread elements encountered in ambiguous literal."
+ problemMessage: "Both Iterable and Map spread elements encountered in ambiguous literal."
script: >
foo(Iterable<int> iterableSpread, Map<int, int> mapSpread) {
var c = {...iterableSpread, ...mapSpread};
}
SpreadElement:
- template: "Iterable spread."
+ problemMessage: "Iterable spread."
severity: CONTEXT
SpreadMapElement:
- template: "Map spread."
+ problemMessage: "Map spread."
severity: CONTEXT
NonNullAwareSpreadIsNull:
- template: "Can't spread a value with static type '#type'."
+ problemMessage: "Can't spread a value with static type '#type'."
script: >
main() {
<int>[...null];
@@ -4711,30 +4711,30 @@
NonPositiveArrayDimensions:
# Used by dart:ffi
- template: "Array dimensions must be positive numbers."
+ problemMessage: "Array dimensions must be positive numbers."
external: test/ffi_test.dart
InvalidTypeVariableInSupertype:
- template: "Can't use implicitly 'out' variable '#name' in an '#string2' position in supertype '#name2'."
+ problemMessage: "Can't use implicitly 'out' variable '#name' in an '#string2' position in supertype '#name2'."
script: >
class A<X> {}
class B<Y> extends A<Function(Y)> {}
InvalidTypeVariableInSupertypeWithVariance:
- template: "Can't use '#string' type variable '#name' in an '#string2' position in supertype '#name2'."
+ problemMessage: "Can't use '#string' type variable '#name' in an '#string2' position in supertype '#name2'."
script: >
class A<out X> {}
class B<out Y> extends A<Function(Y)> {}
InvalidTypeVariableVariancePosition:
- template: "Can't use '#string' type variable '#name' in an '#string2' position."
+ problemMessage: "Can't use '#string' type variable '#name' in an '#string2' position."
script: >
class A<out T> {
void method(T x) {}
}
InvalidTypeVariableVariancePositionInReturnType:
- template: "Can't use '#string' type variable '#name' in an '#string2' position in the return type."
+ problemMessage: "Can't use '#string' type variable '#name' in an '#string2' position in the return type."
script: >
class A<in T> {
T method() {
@@ -4743,8 +4743,8 @@
}
CombinedMemberSignatureFailed:
- template: "Class '#name' inherits multiple members named '#name2' with incompatible signatures."
- tip: "Try adding a declaration of '#name2' to '#name'."
+ problemMessage: "Class '#name' inherits multiple members named '#name2' with incompatible signatures."
+ correctionMessage: "Try adding a declaration of '#name2' to '#name'."
analyzerCode: INCONSISTENT_INHERITANCE
script:
- |
@@ -4759,12 +4759,12 @@
abstract class C implements I2, I1 {}
LanguageVersionTooHigh:
- template: "The specified language version is too high. The highest supported language version is #count.#count2."
+ problemMessage: "The specified language version is too high. The highest supported language version is #count.#count2."
script: >
// @dart = 100.200
LanguageVersionInvalidInDotPackages:
- template: "The language version is not specified correctly in the packages file."
+ problemMessage: "The language version is not specified correctly in the packages file."
exampleAllowMoreCodes: true
script:
main.dart: "import 'package:foo/foo.dart';"
@@ -4782,7 +4782,7 @@
}
LanguageVersionMismatchInPart:
- template: "The language version override has to be the same in the library and its part(s)."
+ problemMessage: "The language version override has to be the same in the library and its part(s)."
script:
main.dart: >
// @dart = 2.4
@@ -4794,90 +4794,90 @@
part of 'main.dart';
LanguageVersionMismatchInPatch:
- template: "The language version override has to be the same in the library and its patch(es)."
+ problemMessage: "The language version override has to be the same in the library and its patch(es)."
LanguageVersionLibraryContext:
- template: "This is language version annotation in the library."
+ problemMessage: "This is language version annotation in the library."
severity: CONTEXT
LanguageVersionPartContext:
- template: "This is language version annotation in the part."
+ problemMessage: "This is language version annotation in the part."
severity: CONTEXT
LanguageVersionPatchContext:
- template: "This is language version annotation in the patch."
+ problemMessage: "This is language version annotation in the patch."
severity: CONTEXT
ExplicitExtensionArgumentMismatch:
- template: "Explicit extension application requires exactly 1 positional argument."
+ problemMessage: "Explicit extension application requires exactly 1 positional argument."
ExplicitExtensionTypeArgumentMismatch:
- template: "Explicit extension application of extension '#name' takes '#count' type argument(s)."
+ problemMessage: "Explicit extension application of extension '#name' takes '#count' type argument(s)."
ExplicitExtensionAsExpression:
- template: "Explicit extension application cannot be used as an expression."
+ problemMessage: "Explicit extension application cannot be used as an expression."
ExplicitExtensionAsLvalue:
- template: "Explicit extension application cannot be a target for assignment."
+ problemMessage: "Explicit extension application cannot be a target for assignment."
DeferredExtensionImport:
- template: "Extension '#name' cannot be imported through a deferred import."
- tip: "Try adding the `hide #name` to the import."
+ problemMessage: "Extension '#name' cannot be imported through a deferred import."
+ correctionMessage: "Try adding the `hide #name` to the import."
script:
main.dart: "import 'lib.dart' deferred as prefix;"
lib.dart: "extension Extension on void {}"
MultipleVarianceModifiers:
index: 97
- template: "Each type parameter can have at most one variance modifier."
- tip: "Use at most one of the 'in', 'out', or 'inout' modifiers."
+ problemMessage: "Each type parameter can have at most one variance modifier."
+ correctionMessage: "Use at most one of the 'in', 'out', or 'inout' modifiers."
analyzerCode: ParserErrorCode.MULTIPLE_VARIANCE_MODIFIERS
VariableCouldBeNullDueToWrite:
- template: "Variable '#name' could not be promoted due to an assignment."
- tip: "Try null checking the variable after the assignment. See #string"
+ problemMessage: "Variable '#name' could not be promoted due to an assignment."
+ correctionMessage: "Try null checking the variable after the assignment. See #string"
FieldNotPromoted:
- template: "'#name' refers to a property so it couldn't be promoted."
- tip: "See #string"
+ problemMessage: "'#name' refers to a property so it couldn't be promoted."
+ correctionMessage: "See #string"
ThisNotPromoted:
- template: "'this' can't be promoted."
- tip: "See #string"
+ problemMessage: "'this' can't be promoted."
+ correctionMessage: "See #string"
NullablePropertyAccessError:
- template: "Property '#name' cannot be accessed on '#type' because it is potentially null."
- tip: "Try accessing using ?. instead."
+ problemMessage: "Property '#name' cannot be accessed on '#type' because it is potentially null."
+ correctionMessage: "Try accessing using ?. instead."
NullableMethodCallError:
- template: "Method '#name' cannot be called on '#type' because it is potentially null."
- tip: "Try calling using ?. instead."
+ problemMessage: "Method '#name' cannot be called on '#type' because it is potentially null."
+ correctionMessage: "Try calling using ?. instead."
NullableExpressionCallError:
- template: "Can't use an expression of type '#type' as a function because it's potentially null."
- tip: "Try calling using ?.call instead."
+ problemMessage: "Can't use an expression of type '#type' as a function because it's potentially null."
+ correctionMessage: "Try calling using ?.call instead."
NullableOperatorCallError:
- template: "Operator '#name' cannot be called on '#type' because it is potentially null."
+ problemMessage: "Operator '#name' cannot be called on '#type' because it is potentially null."
NullableTearoffError:
- template: "Can't tear off method '#name' from a potentially null value."
+ problemMessage: "Can't tear off method '#name' from a potentially null value."
NullableSpreadError:
- template: "An expression whose value can be 'null' must be null-checked before it can be dereferenced."
+ problemMessage: "An expression whose value can be 'null' must be null-checked before it can be dereferenced."
ThrowingNotAssignableToObjectError:
- template: "Can't throw a value of '#type' since it is neither dynamic nor non-nullable."
+ problemMessage: "Can't throw a value of '#type' since it is neither dynamic nor non-nullable."
RequiredNamedParameterHasDefaultValueError:
- template: "Named parameter '#name' is required and can't have a default value."
+ problemMessage: "Named parameter '#name' is required and can't have a default value."
ValueForRequiredParameterNotProvidedError:
- template: "Required named parameter '#name' must be provided."
+ problemMessage: "Required named parameter '#name' must be provided."
OptionalNonNullableWithoutInitializerError:
- template: "The parameter '#name' can't have a value of 'null' because of its type '#type', but the implicit default value is 'null'."
- tip: "Try adding either an explicit non-'null' default value or the 'required' modifier."
+ problemMessage: "The parameter '#name' can't have a value of 'null' because of its type '#type', but the implicit default value is 'null'."
+ correctionMessage: "Try adding either an explicit non-'null' default value or the 'required' modifier."
analyzerCode: MISSING_DEFAULT_VALUE_FOR_PARAMETER
configuration: nnbd-strong
script:
@@ -4885,94 +4885,94 @@
- method2([int a]) {}
FieldNonNullableWithoutInitializerError:
- template: "Field '#name' should be initialized because its type '#type' doesn't allow null."
+ problemMessage: "Field '#name' should be initialized because its type '#type' doesn't allow null."
FieldNonNullableNotInitializedByConstructorError:
- template: "This constructor should initialize field '#name' because its type '#type' doesn't allow null."
+ problemMessage: "This constructor should initialize field '#name' because its type '#type' doesn't allow null."
NonNullableOptOutExplicit:
- template: "Null safety features are disabled for this library."
- tip: "Try removing the `@dart=` annotation or setting the language version to #string or higher."
+ problemMessage: "Null safety features are disabled for this library."
+ correctionMessage: "Try removing the `@dart=` annotation or setting the language version to #string or higher."
NonNullableOptOutImplicit:
- template: "Null safety features are disabled for this library."
- tip: "Try removing the package language version or setting the language version to #string or higher."
+ problemMessage: "Null safety features are disabled for this library."
+ correctionMessage: "Try removing the package language version or setting the language version to #string or higher."
NonNullableOptOutComment:
- template: "This is the annotation that opts out this library from null safety features."
+ problemMessage: "This is the annotation that opts out this library from null safety features."
severity: CONTEXT
AwaitInLateLocalInitializer:
- template: "`await` expressions are not supported in late local initializers."
+ problemMessage: "`await` expressions are not supported in late local initializers."
NullableSuperclassError:
- template: "Can't extend '#name' because it's marked with '?'."
+ problemMessage: "Can't extend '#name' because it's marked with '?'."
NullableInterfaceError:
- template: "Can't implement '#name' because it's marked with '?'."
+ problemMessage: "Can't implement '#name' because it's marked with '?'."
NullableMixinError:
- template: "Can't mix '#name' in because it's marked with '?'."
+ problemMessage: "Can't mix '#name' in because it's marked with '?'."
JsInteropAnonymousFactoryPositionalParameters:
- template: "Factory constructors for @anonymous JS interop classes should not contain any positional parameters."
- tip: "Try replacing them with named parameters instead."
+ problemMessage: "Factory constructors for @anonymous JS interop classes should not contain any positional parameters."
+ correctionMessage: "Try replacing them with named parameters instead."
JsInteropDartClassExtendsJSClass:
- template: "Dart class '#name' cannot extend JS interop class '#name2'."
- tip: "Try adding the JS interop annotation or removing it from the parent class."
+ problemMessage: "Dart class '#name' cannot extend JS interop class '#name2'."
+ correctionMessage: "Try adding the JS interop annotation or removing it from the parent class."
JsInteropEnclosingClassJSAnnotation:
- template: "Member has a JS interop annotation but the enclosing class does not."
- tip: "Try adding the annotation to the enclosing class."
+ problemMessage: "Member has a JS interop annotation but the enclosing class does not."
+ correctionMessage: "Try adding the annotation to the enclosing class."
JsInteropEnclosingClassJSAnnotationContext:
- template: "This is the enclosing class."
+ problemMessage: "This is the enclosing class."
severity: CONTEXT
JsInteropExternalExtensionMemberOnTypeInvalid:
- template: "JS interop or Native class required for 'external' extension members."
- tip: "Try adding a JS interop annotation to the on type class of the extension."
+ problemMessage: "JS interop or Native class required for 'external' extension members."
+ correctionMessage: "Try adding a JS interop annotation to the on type class of the extension."
JsInteropExternalMemberNotJSAnnotated:
- template: "Only JS interop members may be 'external'."
- tip: "Try removing the 'external' keyword or adding a JS interop annotation."
+ problemMessage: "Only JS interop members may be 'external'."
+ correctionMessage: "Try removing the 'external' keyword or adding a JS interop annotation."
JsInteropIndexNotSupported:
- template: "JS interop classes do not support [] and []= operator methods."
- tip: "Try replacing with a normal method."
+ problemMessage: "JS interop classes do not support [] and []= operator methods."
+ correctionMessage: "Try replacing with a normal method."
JsInteropJSClassExtendsDartClass:
- template: "JS interop class '#name' cannot extend Dart class '#name2'."
- tip: "Try removing the JS interop annotation or adding it to the parent class."
+ problemMessage: "JS interop class '#name' cannot extend Dart class '#name2'."
+ correctionMessage: "Try removing the JS interop annotation or adding it to the parent class."
JsInteropNamedParameters:
- template: "Named parameters for JS interop functions are only allowed in a factory constructor of an @anonymous JS class."
- tip: "Try replacing them with normal or optional parameters."
+ problemMessage: "Named parameters for JS interop functions are only allowed in a factory constructor of an @anonymous JS class."
+ correctionMessage: "Try replacing them with normal or optional parameters."
JsInteropNativeClassInAnnotation:
- template: "JS interop class '#name' conflicts with natively supported class '#name2' in '#string3'."
- tip: "Try making the @JS class into an @anonymous class or use js_util on the JS object."
+ problemMessage: "JS interop class '#name' conflicts with natively supported class '#name2' in '#string3'."
+ correctionMessage: "Try making the @JS class into an @anonymous class or use js_util on the JS object."
JsInteropNonExternalConstructor:
- template: "JS interop classes do not support non-external constructors."
- tip: "Try annotating with `external`."
+ problemMessage: "JS interop classes do not support non-external constructors."
+ correctionMessage: "Try annotating with `external`."
JsInteropNonExternalMember:
- template: "This JS interop member must be annotated with `external`. Only factories and static methods can be non-external."
- tip: "Try annotating the member with `external`."
+ problemMessage: "This JS interop member must be annotated with `external`. Only factories and static methods can be non-external."
+ correctionMessage: "Try annotating the member with `external`."
DefaultListConstructorError:
- template: "Can't use the default List constructor."
- tip: "Try using List.filled instead."
+ problemMessage: "Can't use the default List constructor."
+ correctionMessage: "Try using List.filled instead."
NonNullableInNullAware:
- template: "Operand of null-aware operation '#name' has type '#type' which excludes null."
+ problemMessage: "Operand of null-aware operation '#name' has type '#type' which excludes null."
severity: WARNING
ThisInNullAwareReceiver:
- template: "The receiver 'this' cannot be null."
- tip: "Try replacing '?.' with '.'"
+ problemMessage: "The receiver 'this' cannot be null."
+ correctionMessage: "Try replacing '?.' with '.'"
severity: WARNING
configuration: nnbd-strong
script: |
@@ -4984,8 +4984,8 @@
}
ClassInNullAwareReceiver:
- template: "The class '#name' cannot be null."
- tip: "Try replacing '?.' with '.'"
+ problemMessage: "The class '#name' cannot be null."
+ correctionMessage: "Try replacing '?.' with '.'"
severity: WARNING
configuration: nnbd-strong
script: |
@@ -4997,7 +4997,7 @@
}
NonNullableNotAssignedError:
- template: "Non-nullable variable '#name' must be assigned before it can be used."
+ problemMessage: "Non-nullable variable '#name' must be assigned before it can be used."
configuration: nnbd-strong
script: |
method<T>() {
@@ -5005,7 +5005,7 @@
}
FinalNotAssignedError:
- template: "Final variable '#name' must be assigned before it can be used."
+ problemMessage: "Final variable '#name' must be assigned before it can be used."
analyzerCode: READ_POTENTIALLY_UNASSIGNED_FINAL
configuration: nnbd-strong
script: >
@@ -5018,7 +5018,7 @@
}
LateDefinitelyUnassignedError:
- template: "Late variable '#name' without initializer is definitely unassigned."
+ problemMessage: "Late variable '#name' without initializer is definitely unassigned."
configuration: nnbd-strong
script: |
method<T>() {
@@ -5026,7 +5026,7 @@
}
LateDefinitelyAssignedError:
- template: "Late final variable '#name' definitely assigned."
+ problemMessage: "Late final variable '#name' definitely assigned."
configuration: nnbd-strong
script: |
method() {
@@ -5036,7 +5036,7 @@
}
FinalPossiblyAssignedError:
- template: "Final variable '#name' might already be assigned at this point."
+ problemMessage: "Final variable '#name' might already be assigned at this point."
analyzerCode: ASSIGNMENT_TO_FINAL_LOCAL
configuration: nnbd-strong
script: |
@@ -5047,10 +5047,10 @@
}
NonAgnosticConstant:
- template: "Constant value is not strong/weak mode agnostic."
+ problemMessage: "Constant value is not strong/weak mode agnostic."
ExportOptOutFromOptIn:
- template: "Null safe libraries are not allowed to export declarations from of opt-out libraries."
+ problemMessage: "Null safe libraries are not allowed to export declarations from of opt-out libraries."
configuration: nnbd-weak
script:
main.dart: |
@@ -5060,28 +5060,28 @@
class A {}
ExtendFunction:
- template: "Extending 'Function' is deprecated."
- tip: "Try removing 'Function' from the 'extends' clause."
+ problemMessage: "Extending 'Function' is deprecated."
+ correctionMessage: "Try removing 'Function' from the 'extends' clause."
severity: IGNORED
script: |
class A extends Function {}
ImplementFunction:
- template: "Implementing 'Function' is deprecated."
- tip: "Try removing 'Function' from the 'implements' clause."
+ problemMessage: "Implementing 'Function' is deprecated."
+ correctionMessage: "Try removing 'Function' from the 'implements' clause."
severity: IGNORED
script: |
class A implements Function {}
MixinFunction:
- template: "Mixing in 'Function' is deprecated."
- tip: "Try removing 'Function' from the 'with' clause."
+ problemMessage: "Mixing in 'Function' is deprecated."
+ correctionMessage: "Try removing 'Function' from the 'with' clause."
severity: IGNORED
script: |
class A extends Object with Function {}
CannotAssignToFinalVariable:
- template: "Can't assign to the final variable '#name'."
+ problemMessage: "Can't assign to the final variable '#name'."
script: |
main() {
final int i = 0;
@@ -5089,7 +5089,7 @@
}
CannotAssignToConstVariable:
- template: "Can't assign to the const variable '#name'."
+ problemMessage: "Can't assign to the const variable '#name'."
script: |
main() {
const int i = 0;
@@ -5097,7 +5097,7 @@
}
CannotAssignToExtensionThis:
- template: "Can't assign to 'this'."
+ problemMessage: "Can't assign to 'this'."
script: |
extension E on String {
method() {
@@ -5106,50 +5106,50 @@
}
CannotAssignToTypeLiteral:
- template: "Can't assign to a type literal."
+ problemMessage: "Can't assign to a type literal."
script: |
main() {
Object = String;
}
NonVoidReturnOperator:
- template: "The return type of the operator []= must be 'void'."
- tip: "Try changing the return type to 'void'."
+ problemMessage: "The return type of the operator []= must be 'void'."
+ correctionMessage: "Try changing the return type to 'void'."
analyzerCode: NON_VOID_RETURN_FOR_OPERATOR
script:
- class Class { int operator[]=(a, b) {} }
- class Class { dynamic operator[]=(a, b) {} }
NonVoidReturnSetter:
- template: "The return type of the setter must be 'void' or absent."
- tip: "Try removing the return type, or define a method rather than a setter."
+ problemMessage: "The return type of the setter must be 'void' or absent."
+ correctionMessage: "Try removing the return type, or define a method rather than a setter."
analyzerCode: NON_VOID_RETURN_FOR_SETTER
script:
- int set setter(_) {}
- dynamic set setter(_) {}
NeverReachableSwitchDefaultError:
- template: "`null` encountered as case in a switch expression with a non-nullable enum type."
+ problemMessage: "`null` encountered as case in a switch expression with a non-nullable enum type."
NeverReachableSwitchDefaultWarning:
- template: "The default case is not reachable with sound null safety because the switch expression is non-nullable."
+ problemMessage: "The default case is not reachable with sound null safety because the switch expression is non-nullable."
severity: WARNING
NeverValueError:
- template: "`null` encountered as the result from expression with type `Never`."
+ problemMessage: "`null` encountered as the result from expression with type `Never`."
NeverValueWarning:
- template: "The expression can not result in a value with sound null safety because the expression type is `Never`."
+ problemMessage: "The expression can not result in a value with sound null safety because the expression type is `Never`."
severity: WARNING
MainNotFunctionDeclaration:
- template: "The 'main' declaration must be a function declaration."
+ problemMessage: "The 'main' declaration must be a function declaration."
configuration: nnbd-strong
script:
- var main;
MainNotFunctionDeclarationExported:
- template: "The exported 'main' declaration must be a function declaration."
+ problemMessage: "The exported 'main' declaration must be a function declaration."
configuration: nnbd-strong
exampleAllowMoreCodes: true
script:
@@ -5159,13 +5159,13 @@
var main;
MainTooManyRequiredParameters:
- template: "The 'main' method must have at most 2 required parameters."
+ problemMessage: "The 'main' method must have at most 2 required parameters."
configuration: nnbd-strong
script:
- main(a, b, c) {}
MainTooManyRequiredParametersExported:
- template: "The exported 'main' method must have at most 2 required parameters."
+ problemMessage: "The exported 'main' method must have at most 2 required parameters."
configuration: nnbd-strong
exampleAllowMoreCodes: true
script:
@@ -5175,13 +5175,13 @@
main(a, b, c) {}
MainRequiredNamedParameters:
- template: "The 'main' method cannot have required named parameters."
+ problemMessage: "The 'main' method cannot have required named parameters."
configuration: nnbd-strong
script:
- main({required a}) {}
MainRequiredNamedParametersExported:
- template: "The exported 'main' method cannot have required named parameters."
+ problemMessage: "The exported 'main' method cannot have required named parameters."
configuration: nnbd-strong
exampleAllowMoreCodes: true
script:
@@ -5191,13 +5191,13 @@
main({required a}) {}
MainWrongParameterType:
- template: "The type '#type' of the first parameter of the 'main' method is not a supertype of '#type2'."
+ problemMessage: "The type '#type' of the first parameter of the 'main' method is not a supertype of '#type2'."
configuration: nnbd-strong
script:
- main(Set<String> args) {}
MainWrongParameterTypeExported:
- template: "The type '#type' of the first parameter of the exported 'main' method is not a supertype of '#type2'."
+ problemMessage: "The type '#type' of the first parameter of the exported 'main' method is not a supertype of '#type2'."
configuration: nnbd-strong
exampleAllowMoreCodes: true
script:
@@ -5207,11 +5207,11 @@
main(Set<String> args) {}
ExportedMain:
- template: "This is exported 'main' declaration."
+ problemMessage: "This is exported 'main' declaration."
severity: CONTEXT
UnexpectedModifierInNonNnbd:
- template: "The modifier '#lexeme' is only available in null safe libraries."
+ problemMessage: "The modifier '#lexeme' is only available in null safe libraries."
exampleAllowMoreCodes: true
analyzerCode: UNEXPECTED_TOKEN
script: |
@@ -5219,14 +5219,14 @@
late int x;
CompilingWithSoundNullSafety:
- template: "Compiling with sound null safety"
+ problemMessage: "Compiling with sound null safety"
configuration: nnbd-strong,compile
severity: INFO
script: |
main() {}
CompilingWithoutSoundNullSafety:
- template: "Compiling without sound null safety"
+ problemMessage: "Compiling without sound null safety"
configuration: nnbd-weak,compile
severity: INFO
script: |
@@ -5234,45 +5234,45 @@
main() {}
UnsupportedDartExt:
- template: "Dart native extensions are no longer supported."
- tip: "Migrate to using FFI instead (https://dart.dev/guides/libraries/c-interop)"
+ problemMessage: "Dart native extensions are no longer supported."
+ correctionMessage: "Migrate to using FFI instead (https://dart.dev/guides/libraries/c-interop)"
script: |
import 'dart-ext:foo.dart';
InstantiationNonGenericFunctionType:
- template: "The static type of the explicit instantiation operand must be a generic function type but is '#type'."
- tip: "Try changing the operand or remove the type arguments."
+ problemMessage: "The static type of the explicit instantiation operand must be a generic function type but is '#type'."
+ correctionMessage: "Try changing the operand or remove the type arguments."
experiments: constructor-tearoffs
script: |
f() {}
main() => f<int>;
InstantiationTooFewArguments:
- template: "Too few type arguments: #count required, #count2 given."
- tip: "Try adding the missing type arguments."
+ problemMessage: "Too few type arguments: #count required, #count2 given."
+ correctionMessage: "Try adding the missing type arguments."
experiments: constructor-tearoffs
script: |
f<X, Y>() {}
main() => f<int>;
InstantiationTooManyArguments:
- template: "Too many type arguments: #count allowed, but #count2 found."
- tip: "Try removing the extra type arguments."
+ problemMessage: "Too many type arguments: #count allowed, but #count2 found."
+ correctionMessage: "Try removing the extra type arguments."
experiments: constructor-tearoffs
script: |
f<X>() {}
main() => f<int, String>;
AbstractClassConstructorTearOff:
- template: "Constructors on abstract classes can't be torn off."
+ problemMessage: "Constructors on abstract classes can't be torn off."
experiments: constructor-tearoffs
script: |
abstract class Class {}
main() => Class.new;
StaticTearOffFromInstantiatedClass:
- template: "Cannot access static member on an instantiated generic class."
- tip: "Try removing the type arguments or placing them after the member name."
+ problemMessage: "Cannot access static member on an instantiated generic class."
+ correctionMessage: "Try removing the type arguments or placing them after the member name."
experiments: constructor-tearoffs
script: |
class A<X> { static f() {} }
@@ -5280,8 +5280,8 @@
ConstructorTearOffWithTypeArguments:
- template: "A constructor tear-off can't have type arguments after the constructor name."
- tip: "Try removing the type arguments or placing them after the class name."
+ problemMessage: "A constructor tear-off can't have type arguments after the constructor name."
+ correctionMessage: "Try removing the type arguments or placing them after the class name."
experiments: constructor-tearoffs
script:
- "class C<X> { C.foo(); } bar() { C.foo<int>; }"
diff --git a/pkg/front_end/test/fasta/messages_suite.dart b/pkg/front_end/test/fasta/messages_suite.dart
index b62fceb..152fa07 100644
--- a/pkg/front_end/test/fasta/messages_suite.dart
+++ b/pkg/front_end/test/fasta/messages_suite.dart
@@ -218,7 +218,7 @@
// characters with two characters without actually having the string
// "backslash n".
switch (key) {
- case "template":
+ case "problemMessage":
spell.SpellingResult spellingResult = spell.spellcheckString(
node.span.text.replaceAll(r"\n", "\n\n"),
dictionaries: const [
@@ -230,14 +230,14 @@
spellingMessages.addAll(formatSpellingMistakes(
spellingResult,
node.span.start.offset,
- "Template has the following word that is "
+ "problemMessage has the following word that is "
"not in our dictionary",
- "Template has the following word that is "
+ "problemMessage has the following word that is "
"on our deny-list"));
}
break;
- case "tip":
+ case "correctionMessage":
spell.SpellingResult spellingResult = spell.spellcheckString(
node.span.text.replaceAll(r"\n", "\n\n"),
dictionaries: const [
@@ -249,9 +249,9 @@
spellingMessages.addAll(formatSpellingMistakes(
spellingResult,
node.span.start.offset,
- "Tip has the following word that is "
+ "correctionMessage has the following word that is "
"not in our dictionary",
- "Tip has the following word that is "
+ "correctionMessage has the following word that is "
"on our deny-list"));
}
break;
diff --git a/pkg/front_end/tool/_fasta/generate_messages.dart b/pkg/front_end/tool/_fasta/generate_messages.dart
index 97bf6d8..55d233a 100644
--- a/pkg/front_end/tool/_fasta/generate_messages.dart
+++ b/pkg/front_end/tool/_fasta/generate_messages.dart
@@ -96,7 +96,7 @@
}
Map<dynamic, dynamic>? map = description;
if (map == null) {
- throw "No 'template:' in key $name.";
+ throw "No 'problemMessage:' in key $name.";
}
var index = map['index'];
if (index != null) {
@@ -121,8 +121,8 @@
}
}
}
- Template template = compileTemplate(name, index, map['template'],
- map['tip'], map['analyzerCode'], map['severity']);
+ Template template = compileTemplate(name, index, map['problemMessage'],
+ map['correctionMessage'], map['analyzerCode'], map['severity']);
if (template.isShared) {
sharedMessages.writeln(template.text);
} else {
@@ -164,17 +164,17 @@
Template(this.text, {this.isShared}) : assert(isShared != null);
}
-Template compileTemplate(String name, int? index, String? template, String? tip,
- Object? analyzerCode, String? severity) {
- if (template == null) {
- print('Error: missing template for message: $name');
+Template compileTemplate(String name, int? index, String? problemMessage,
+ String? correctionMessage, Object? analyzerCode, String? severity) {
+ if (problemMessage == null) {
+ print('Error: missing problemMessage for message: $name');
exitCode = 1;
return new Template('', isShared: true);
}
// Remove trailing whitespace. This is necessary for templates defined with
// `|` (verbatim) as they always contain a trailing newline that we don't
// want.
- template = template.trimRight();
+ problemMessage = problemMessage.trimRight();
const String ignoreNotNull = "// ignore: unnecessary_null_comparison";
var parameters = new Set<String>();
var conversions = new Set<String>();
@@ -190,8 +190,8 @@
canBeShared = false;
}
- for (Match match
- in placeholderPattern.allMatches("$template\n${tip ?? ''}")) {
+ for (Match match in placeholderPattern
+ .allMatches("$problemMessage\n${correctionMessage ?? ''}")) {
String name = match[1]!;
String? padding = match[2];
String? fractionDigits = match[3];
@@ -429,11 +429,11 @@
if (parameters.isEmpty && conversions.isEmpty && arguments.isEmpty) {
// ignore: unnecessary_null_comparison
- if (template != null) {
- codeArguments.add('message: r"""$template"""');
+ if (problemMessage != null) {
+ codeArguments.add('message: r"""$problemMessage"""');
}
- if (tip != null) {
- codeArguments.add('tip: r"""$tip"""');
+ if (correctionMessage != null) {
+ codeArguments.add('tip: r"""$correctionMessage"""');
}
return new Template("""
@@ -448,23 +448,23 @@
List<String> templateArguments = <String>[];
// ignore: unnecessary_null_comparison
- if (template != null) {
- templateArguments.add('messageTemplate: r"""$template"""');
+ if (problemMessage != null) {
+ templateArguments.add('messageTemplate: r"""$problemMessage"""');
}
- if (tip != null) {
- templateArguments.add('tipTemplate: r"""$tip"""');
+ if (correctionMessage != null) {
+ templateArguments.add('tipTemplate: r"""$correctionMessage"""');
}
templateArguments.add("withArguments: _withArguments$name");
List<String> messageArguments = <String>[];
- String message = interpolate(template);
+ String message = interpolate(problemMessage);
if (hasLabeler) {
message += " + labeler.originMessages";
}
messageArguments.add("message: ${message}");
- if (tip != null) {
- messageArguments.add("tip: ${interpolate(tip)}");
+ if (correctionMessage != null) {
+ messageArguments.add("tip: ${interpolate(correctionMessage)}");
}
messageArguments.add("arguments: { ${arguments.join(', ')} }");
diff --git a/tools/VERSION b/tools/VERSION
index 3eb35a7..bd4c19d 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 15
PATCH 0
-PRERELEASE 172
+PRERELEASE 173
PRERELEASE_PATCH 0
\ No newline at end of file
diff --git a/tools/manage_deps.dart b/tools/manage_deps.dart
new file mode 100755
index 0000000..0d1e8b4
--- /dev/null
+++ b/tools/manage_deps.dart
@@ -0,0 +1,261 @@
+#!tools/sdks/dart-sdk/bin/dart
+// 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.
+
+/// Helps rolling dependency to the newest version available
+/// (or a target version).
+///
+/// Usage: ./tools/manage_deps.dart bump <dependency> [--branch <branch>] [--target <ref>]
+///
+/// This will:
+/// 0. Check that git is clean
+/// 1. Create branch `<branch> ?? bump_<dependency>`
+/// 2. Update `DEPS` for `<dependency>`
+/// 3. Create a commit with `git log` of imported commits in the message.
+/// 4. Prompt to create a CL
+
+// @dart = 2.13
+library bump;
+
+import 'dart:io';
+import 'package:args/command_runner.dart';
+
+import 'package:path/path.dart' as p;
+
+class BumpCommand extends Command<int> {
+ @override
+ String get description => '''
+Bump a dependency in DEPS and create a CL
+
+This will:
+0. Check that git is clean
+1. Create branch `<branch> ?? bump_<dependency>`
+2. Update `DEPS` for `<dependency>`
+3. Create a commit with `git log` of imported commits in the message.
+4. Prompt to create a CL
+''';
+
+ String get invocation =>
+ './tools/manage_deps.dart bump <path/to/dependency> <options>';
+
+ BumpCommand() {
+ argParser.addOption(
+ 'branch',
+ help: 'The name of the branch where the update is created.',
+ valueHelp: 'branch-name',
+ );
+ argParser.addOption(
+ 'target',
+ help: 'The git ref to update to.',
+ valueHelp: 'ref',
+ );
+ }
+
+ @override
+ String get name => 'bump';
+
+ @override
+ Future<int> run() async {
+ final argResults = this.argResults!;
+ if (argResults.rest.length != 1) {
+ usageException('No dependency directory given');
+ }
+ final status = runProcessForLines(['git', 'status', '--porcelain'],
+ explanation: 'Checking if your git checkout is clean');
+ if (status.isNotEmpty) {
+ print('Note your git checkout is dirty!');
+ }
+
+ final pkgDir = argResults.rest.first;
+ if (!Directory(pkgDir).existsSync()) {
+ usageException('No directory $pkgDir');
+ }
+ final toUpdate = p.split(pkgDir).last;
+ final branchName = argResults['branch'] ?? 'bump_$toUpdate';
+
+ final exists = runProcessForExitCode(
+ ['git', 'show-ref', '--quiet', 'refs/head/$branchName'],
+ explanation: 'Checking if branch-name exists');
+ if (exists != 0) {
+ print('Branch $branchName already exist - delete it?');
+ if (!prompt()) {
+ print('Ok - exiting');
+ exit(-1);
+ }
+ runProcessAssumingSuccess(
+ ['git', 'branch', '-D', branchName],
+ explanation: 'Deleting existing branch',
+ );
+ }
+ runProcessAssumingSuccess(
+ ['git', 'checkout', '-b', branchName],
+ explanation: 'Creating branch',
+ );
+
+ final currentRev = runProcessForLines(
+ ['gclient', 'getdep', '-r', p.join('sdk', pkgDir)],
+ explanation: 'Finding current revision',
+ ).first;
+
+ final originUrl = runProcessForLines(
+ ['git', 'config', '--get', 'remote.origin.url'],
+ workingDirectory: pkgDir,
+ explanation: 'Finding origin url',
+ ).first;
+
+ runProcessAssumingSuccess(
+ ['git', 'fetch', 'origin'],
+ workingDirectory: pkgDir,
+ explanation: 'Retrieving updates to $toUpdate',
+ );
+
+ final gitRevParseResult = runProcessForLines([
+ 'git',
+ 'rev-parse',
+ if (argResults.wasParsed('target'))
+ argResults['target']
+ else
+ 'origin/HEAD',
+ ], workingDirectory: pkgDir, explanation: 'Finding sha-id');
+
+ final target = gitRevParseResult.first;
+ if (currentRev == target) {
+ print('Already at $target - nothing to do');
+ return -1;
+ }
+ runProcessAssumingSuccess(
+ ['gclient', 'setdep', '-r', '${p.join('sdk', pkgDir)}@$target'],
+ explanation: 'Updating $toUpdate',
+ );
+ runProcessAssumingSuccess(
+ ['gclient', 'sync', '-D'],
+ explanation: 'Syncing your deps',
+ );
+ runProcessAssumingSuccess(
+ [
+ Platform.resolvedExecutable,
+ 'tools/generate_package_config.dart',
+ ],
+ explanation: 'Updating package config',
+ );
+ final gitLogResult = runProcessForLines([
+ 'git',
+ 'log',
+ '--format=%C(auto) $originUrl/+/%h %s ',
+ '$currentRev..$target',
+ ], workingDirectory: pkgDir, explanation: 'Listing new commits');
+ final commitMessage = '''
+Bump $toUpdate to $target
+
+Changes:
+```
+> git log --format="%C(auto) %h %s" ${currentRev.substring(0, 7)}..${target.substring(0, 7)}
+${gitLogResult.join('\n')}
+```
+Diff: $originUrl/+/$currentRev~..$target/
+''';
+ runProcessAssumingSuccess(['git', 'commit', '-am', commitMessage],
+ explanation: 'Committing');
+ print('Consider updating CHANGELOG.md');
+ print('Do you want to create a CL?');
+ if (prompt()) {
+ await runProcessInteractively(
+ ['git', 'cl', 'upload', '-m', commitMessage],
+ explanation: 'Creating CL',
+ );
+ }
+ return 0;
+ }
+}
+
+Future<void> main(List<String> args) async {
+ final runner = CommandRunner<int>(
+ 'manage_deps.dart', 'helps managing the DEPS file',
+ usageLineLength: 80)
+ ..addCommand(BumpCommand());
+ try {
+ exit(await runner.run(args) ?? -1);
+ } on UsageException catch (e) {
+ print(e.message);
+ print(e.usage);
+ }
+}
+
+bool prompt() {
+ stdout.write('(y/N):');
+ final answer = stdin.readLineSync() ?? '';
+ return answer.trim().toLowerCase() == 'y';
+}
+
+void printRunningLine(
+ List<String> cmd, String? explanation, String? workingDirectory) {
+ stdout.write(
+ "${explanation ?? 'Running'}: `${cmd.join(' ')}` ${workingDirectory == null ? '' : 'in $workingDirectory'}");
+}
+
+void printSuccessTrailer(ProcessResult result, String? onFailure) {
+ if (result.exitCode == 0) {
+ stdout.writeln(' ✓');
+ } else {
+ stdout.writeln(' X');
+ stderr.write(result.stdout);
+ stderr.write(result.stderr);
+ if (onFailure != null) {
+ print(onFailure);
+ }
+ throw Exception();
+ }
+}
+
+void runProcessAssumingSuccess(List<String> cmd,
+ {String? explanation,
+ String? workingDirectory,
+ Map<String, String> environment = const {},
+ String? onFailure}) {
+ printRunningLine(cmd, explanation, workingDirectory);
+ final result = Process.runSync(
+ cmd[0],
+ cmd.skip(1).toList(),
+ workingDirectory: workingDirectory,
+ environment: environment,
+ );
+ printSuccessTrailer(result, onFailure);
+}
+
+List<String> runProcessForLines(List<String> cmd,
+ {String? explanation, String? workingDirectory, String? onFailure}) {
+ printRunningLine(cmd, explanation, workingDirectory);
+ final result = Process.runSync(
+ cmd[0],
+ cmd.skip(1).toList(),
+ workingDirectory: workingDirectory,
+ );
+ printSuccessTrailer(result, onFailure);
+ final output = (result.stdout as String);
+ return output == '' ? <String>[] : output.split('\n');
+}
+
+Future<void> runProcessInteractively(List<String> cmd,
+ {String? explanation, String? workingDirectory}) async {
+ printRunningLine(cmd, explanation, workingDirectory);
+ stdout.writeln('');
+ final process = await Process.start(cmd[0], cmd.skip(1).toList(),
+ workingDirectory: workingDirectory, mode: ProcessStartMode.inheritStdio);
+ final exitCode = await process.exitCode;
+ if (exitCode != 0) {
+ throw Exception();
+ }
+}
+
+int runProcessForExitCode(List<String> cmd,
+ {String? explanation, String? workingDirectory}) {
+ printRunningLine(cmd, explanation, workingDirectory);
+ final result = Process.runSync(
+ cmd[0],
+ cmd.skip(1).toList(),
+ workingDirectory: workingDirectory,
+ );
+ stdout.writeln(' => ${result.exitCode}');
+ return result.exitCode;
+}