Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Unified Diff: pkg/analyzer/lib/source/error_processor.dart

Issue 1780783002: Don't report redundant type errors in strong mode. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Stop type propagation in test. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/error_verifier.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/source/error_processor.dart
diff --git a/pkg/analyzer/lib/source/error_processor.dart b/pkg/analyzer/lib/source/error_processor.dart
index 8e369aad746e50053c249e3447af002741e823fc..6b69cb71fe24ab6d1049a89088f36faa637015b4 100644
--- a/pkg/analyzer/lib/source/error_processor.dart
+++ b/pkg/analyzer/lib/source/error_processor.dart
@@ -93,9 +93,37 @@ class ErrorProcessor {
if (context == null) {
return null;
}
+
+ // By default, the error is not processed.
+ ErrorProcessor processor;
+
+ // Give strong mode a chance to upgrade it.
+ if (context.analysisOptions.strongMode) {
+ processor = _StrongModeTypeErrorProcessor.instance;
+ }
+
+ // Let the user configure how specific errors are processed.
List<ErrorProcessor> processors =
context.getConfigurationData(CONFIGURED_ERROR_PROCESSORS);
+
return processors.firstWhere((ErrorProcessor p) => p.appliesTo(error),
- orElse: () => null);
+ orElse: () => processor);
}
}
+
+/// 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.");
+
+ /// 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) =>
+ error.errorCode.type == ErrorType.STATIC_TYPE_WARNING;
+}
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/error_verifier.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698