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

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

Issue 1851433002: Better record compile-time errors on elements (Closed) Base URL: https://github.com/dart-lang/sdk.git@_temporary_fletch_patches
Patch Set: 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/compiler/lib/src/js_backend/backend.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 652850b92f5e94aa4809bc836270bf361198460e..bd0fe5d04fb2d5833c4ecf21a9f4bf4c51325d62 100644
--- a/pkg/compiler/lib/src/compiler.dart
+++ b/pkg/compiler/lib/src/compiler.dart
@@ -354,9 +354,11 @@ abstract class Compiler {
/// The [String.fromEnvironment] constructor.
ConstructorElement stringEnvironment;
+ // TODO(zarah): Remove this map and incorporate compile-time errors
+ // in the model.
/// Tracks elements with compile-time errors.
- final Map<Element, DiagnosticMessage> elementsWithCompileTimeErrors =
- new Map<Element, DiagnosticMessage>();
+ final Map<Element, List<DiagnosticMessage>> elementsWithCompileTimeErrors =
+ new Map<Element, List<DiagnosticMessage>>();
fromEnvironment(String name) => null;
@@ -1455,7 +1457,16 @@ abstract class Compiler {
void registerCompiletimeError(Element element, DiagnosticMessage message) {
// The information is only needed if [generateCodeWithCompileTimeErrors].
if (generateCodeWithCompileTimeErrors) {
- elementsWithCompileTimeErrors[element] = message;
+ if (element == null) {
+ // Record as global error.
+ // TODO(zarah): Extend element model to represent compile-time
+ // errors instead of using a map.
+ elementsWithCompileTimeErrors.
Johnni Winther 2016/03/31 09:59:34 Maybe just: if (element == null) { // .... el
zarah 2016/04/01 07:29:52 Done.
+ putIfAbsent(mainFunction, () => <DiagnosticMessage>[]).add(message);
+ } else {
+ elementsWithCompileTimeErrors.
+ putIfAbsent(element, () => <DiagnosticMessage>[]).add(message);
+ }
}
}
@@ -1725,7 +1736,12 @@ class CompilerDiagnosticReporter extends DiagnosticReporter {
kind == api.Diagnostic.CRASH ||
(options.fatalWarnings &&
kind == api.Diagnostic.WARNING)) {
- compiler.registerCompiletimeError(currentElement, message);
+ if (message.spannable is Element) {
+ errorElement = message.spannable;
+ } else {
+ errorElement = currentElement;
+ }
+ compiler.registerCompiletimeError(errorElement, message);
compiler.compilationFailed = true;
}
compiler.reportDiagnostic(message, infos, kind);
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_backend/backend.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698