| Index: pkg/analyzer/lib/src/generated/error_verifier.dart
|
| diff --git a/pkg/analyzer/lib/src/generated/error_verifier.dart b/pkg/analyzer/lib/src/generated/error_verifier.dart
|
| index 91b072cf8238b31138601e2b4e988af54f301a4b..dff34027eadeec61808fa934d7b87999dd391743 100644
|
| --- a/pkg/analyzer/lib/src/generated/error_verifier.dart
|
| +++ b/pkg/analyzer/lib/src/generated/error_verifier.dart
|
| @@ -1659,28 +1659,24 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| });
|
|
|
| if (notInitFinalFields.isNotEmpty) {
|
| - AnalysisErrorWithProperties analysisError;
|
| List<String> names = notInitFinalFields.map((item) => item.name).toList();
|
| names.sort();
|
| if (names.length == 1) {
|
| - analysisError = _errorReporter.newErrorWithProperties(
|
| + _errorReporter.reportErrorForNode(
|
| StaticWarningCode.FINAL_NOT_INITIALIZED_CONSTRUCTOR_1,
|
| constructor.returnType,
|
| names);
|
| } else if (names.length == 2) {
|
| - analysisError = _errorReporter.newErrorWithProperties(
|
| + _errorReporter.reportErrorForNode(
|
| StaticWarningCode.FINAL_NOT_INITIALIZED_CONSTRUCTOR_2,
|
| constructor.returnType,
|
| names);
|
| } else {
|
| - analysisError = _errorReporter.newErrorWithProperties(
|
| + _errorReporter.reportErrorForNode(
|
| StaticWarningCode.FINAL_NOT_INITIALIZED_CONSTRUCTOR_3_PLUS,
|
| constructor.returnType,
|
| [names[0], names[1], names.length - 2]);
|
| }
|
| - analysisError.setProperty(
|
| - ErrorProperty.NOT_INITIALIZED_FIELDS, notInitFinalFields);
|
| - _errorReporter.reportError(analysisError);
|
| }
|
| }
|
|
|
| @@ -6655,6 +6651,45 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| }
|
|
|
| /**
|
| + * Return [FieldElement]s that are declared in the [ClassDeclaration] with
|
| + * the given [constructor], but are not initialized.
|
| + */
|
| + static List<FieldElement> computeNotInitializedFields(
|
| + ConstructorDeclaration constructor) {
|
| + Set<FieldElement> fields = new Set<FieldElement>();
|
| + var classDeclaration = constructor.parent as ClassDeclaration;
|
| + for (ClassMember fieldDeclaration in classDeclaration.members) {
|
| + if (fieldDeclaration is FieldDeclaration) {
|
| + for (VariableDeclaration field in fieldDeclaration.fields.variables) {
|
| + if (field.initializer == null) {
|
| + fields.add(field.element);
|
| + }
|
| + }
|
| + }
|
| + }
|
| +
|
| + List<FormalParameter> parameters = constructor.parameters?.parameters ?? [];
|
| + for (FormalParameter parameter in parameters) {
|
| + if (parameter is DefaultFormalParameter) {
|
| + parameter = (parameter as DefaultFormalParameter).parameter;
|
| + }
|
| + if (parameter is FieldFormalParameter) {
|
| + FieldFormalParameterElement element =
|
| + parameter.identifier.staticElement as FieldFormalParameterElement;
|
| + fields.remove(element.field);
|
| + }
|
| + }
|
| +
|
| + for (ConstructorInitializer initializer in constructor.initializers) {
|
| + if (initializer is ConstructorFieldInitializer) {
|
| + fields.remove(initializer.fieldName.staticElement);
|
| + }
|
| + }
|
| +
|
| + return fields.toList();
|
| + }
|
| +
|
| + /**
|
| * Return the static type of the given [expression] that is to be used for
|
| * type analysis.
|
| */
|
|
|