Make ERROR the default severity for StaticWarningCode. Remove _StrongModeTypeErrorProcessor.
As a preparatory step for re-landing https://dart-review.googlesource.com/c/sdk/+/91170
and making these two restored problems to warnings.
R=brianwilkerson@google.com, paulberry@google.com
Change-Id: I6266632ade84743b5725c54475fe402902576c00
Reviewed-on: https://dart-review.googlesource.com/c/91420
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analysis_server/test/edit/fixes_test.dart b/pkg/analysis_server/test/edit/fixes_test.dart
index 4c48892..2fa8a24 100644
--- a/pkg/analysis_server/test/edit/fixes_test.dart
+++ b/pkg/analysis_server/test/edit/fixes_test.dart
@@ -44,7 +44,7 @@
await _getFixesAt('Completer<String>');
expect(errorFixes, hasLength(1));
AnalysisError error = errorFixes[0].error;
- expect(error.severity, AnalysisErrorSeverity.WARNING);
+ expect(error.severity, AnalysisErrorSeverity.ERROR);
expect(error.type, AnalysisErrorType.STATIC_WARNING);
List<SourceChange> fixes = errorFixes[0].fixes;
expect(fixes, hasLength(3));
diff --git a/pkg/analyzer/lib/source/error_processor.dart b/pkg/analyzer/lib/source/error_processor.dart
index b1cf472..3391264 100644
--- a/pkg/analyzer/lib/source/error_processor.dart
+++ b/pkg/analyzer/lib/source/error_processor.dart
@@ -3,7 +3,6 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/error/error.dart';
-import 'package:analyzer/src/error/codes.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/utilities_general.dart';
import 'package:analyzer/src/task/options.dart';
@@ -99,33 +98,7 @@
// Add the strong mode processor.
processors = processors.toList();
- processors.add(_StrongModeTypeErrorProcessor.instance);
return processors.firstWhere((ErrorProcessor p) => p.appliesTo(error),
orElse: () => null);
}
}
-
-/// In strong mode, this upgrades static type warnings to errors.
-class _StrongModeTypeErrorProcessor implements ErrorProcessor {
- static final instance = new _StrongModeTypeErrorProcessor();
-
- // TODO(rnystrom): As far as I know, this is only used to implement
- // appliesTo(). Consider making it private in ErrorProcessor if possible.
- String get code => throw new UnsupportedError(
- "_StrongModeTypeErrorProcessor is not specific to an error code.");
-
- @override
- String get description => 'allStrongWarnings -> ERROR';
-
- /// In strong mode, type warnings are upgraded to errors.
- ErrorSeverity get severity => ErrorSeverity.ERROR;
-
- /// Check if this processor applies to the given [error].
- bool appliesTo(AnalysisError error) {
- ErrorCode errorCode = error.errorCode;
- if (errorCode is StaticWarningCode) {
- return true;
- }
- return false;
- }
-}
diff --git a/pkg/analyzer/lib/src/error/codes.dart b/pkg/analyzer/lib/src/error/codes.dart
index ddfb545..599447e 100644
--- a/pkg/analyzer/lib/src/error/codes.dart
+++ b/pkg/analyzer/lib/src/error/codes.dart
@@ -4624,6 +4624,9 @@
" call that returns void you didn't expect. Also check type parameters"
' and variables which, in rare cases, may be void as well.');
+ @override
+ final ErrorSeverity errorSeverity;
+
/**
* Initialize a newly created error code to have the given [name]. The message
* associated with the error will be created from the given [message]
@@ -4631,15 +4634,14 @@
* given [correction] template.
*/
const StaticWarningCode(String name, String message,
- {String correction, bool isUnresolvedIdentifier: false})
+ {String correction,
+ this.errorSeverity: ErrorSeverity.ERROR,
+ bool isUnresolvedIdentifier: false})
: super.temporary(name, message,
correction: correction,
isUnresolvedIdentifier: isUnresolvedIdentifier);
@override
- ErrorSeverity get errorSeverity => ErrorType.STATIC_WARNING.severity;
-
- @override
ErrorType get type => ErrorType.STATIC_WARNING;
}
diff --git a/pkg/analyzer/test/source/error_processor_test.dart b/pkg/analyzer/test/source/error_processor_test.dart
index 247d10f..d55cd52 100644
--- a/pkg/analyzer/test/source/error_processor_test.dart
+++ b/pkg/analyzer/test/source/error_processor_test.dart
@@ -39,11 +39,6 @@
['x']
]);
- AnalysisError assignment_no_type = new AnalysisError(
- new TestSource(), 0, 1, StaticWarningCode.ASSIGNMENT_TO_TYPE, [
- ['x']
- ]);
-
// We in-line a lint code here in order to avoid adding a dependency on the
// linter package.
AnalysisError annotate_overrides = new AnalysisError(
@@ -68,15 +63,7 @@
expect(getProcessor(invalid_assignment).severity, ErrorSeverity.ERROR);
expect(getProcessor(missing_return).severity, isNull);
expect(getProcessor(unused_local_variable), isNull);
- expect(getProcessor(use_of_void_result), isNotNull);
- });
-
- test('upgrades static warnings to errors in strong mode', () {
- configureOptions('''
-analyzer:
- strong-mode: true
-''');
- expect(getProcessor(assignment_no_type).severity, ErrorSeverity.ERROR);
+ expect(getProcessor(use_of_void_result), isNull);
});
test('does not upgrade other warnings to errors in strong mode', () {