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

Unified Diff: pkg/compiler/lib/src/compiler.dart

Issue 1525593002: Introduce benign errors. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 5 years 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 | tests/compiler/dart2js/benign_error_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/compiler.dart
diff --git a/pkg/compiler/lib/src/compiler.dart b/pkg/compiler/lib/src/compiler.dart
index 3b98b92e0506283af7288b3a5aa5386f6eafb22d..4a43f6b59fe303696cd9656c649fb491ce3ff93a 100644
--- a/pkg/compiler/lib/src/compiler.dart
+++ b/pkg/compiler/lib/src/compiler.dart
@@ -1250,6 +1250,32 @@ abstract class Compiler {
_reporter.onCrashInUserCode(message, exception, stackTrace);
}
+ /// Messages for which compile-time errors are reported but compilation
+ /// continues regardless.
+ static const List<MessageKind> BENIGN_ERRORS = const <MessageKind>[
+ MessageKind.INVALID_METADATA,
+ MessageKind.INVALID_METADATA_GENERIC,
+ ];
+
+ bool markCompilationAsFailed(DiagnosticMessage message, api.Diagnostic kind) {
+ if (testMode) {
+ // When in test mode, i.e. on the build-bot, we always stop compilation.
+ return true;
+ }
+ if (reporter.options.fatalWarnings) {
+ return true;
+ }
+ return !BENIGN_ERRORS.contains(message.message.kind);
+ }
+
+ void fatalDiagnosticReported(DiagnosticMessage message,
+ List<DiagnosticMessage> infos,
+ api.Diagnostic kind) {
+ if (markCompilationAsFailed(message, kind)) {
+ compilationFailed = true;
+ }
+ }
+
/**
* Translates the [resolvedUri] into a readable URI.
*
@@ -1701,13 +1727,13 @@ class _CompilerDiagnosticReporter extends DiagnosticReporter {
void reportDiagnostic(DiagnosticMessage message,
List<DiagnosticMessage> infos,
api.Diagnostic kind) {
+ compiler.reportDiagnostic(message, infos, kind);
if (kind == api.Diagnostic.ERROR ||
kind == api.Diagnostic.CRASH ||
(options.fatalWarnings &&
kind == api.Diagnostic.WARNING)) {
- compiler.compilationFailed = true;
+ compiler.fatalDiagnosticReported(message, infos, kind);
}
- compiler.reportDiagnostic(message, infos, kind);
}
/**
« no previous file with comments | « no previous file | tests/compiler/dart2js/benign_error_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698