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

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

Issue 1525603002: Associate compile-time errors with elements (Closed) Base URL: git@github.com:dart-lang/sdk.git@_temporary_fletch_patches
Patch Set: Address review 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 | 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 085a25f71bf1793e0363e698336f14bce762d49f..0bcc283efe75b538f027f0b83490fe37f70c3631 100644
--- a/pkg/compiler/lib/src/compiler.dart
+++ b/pkg/compiler/lib/src/compiler.dart
@@ -346,7 +346,8 @@ abstract class Compiler {
ConstructorElement stringEnvironment;
/// Tracks elements with compile-time errors.
- final Set<Element> elementsWithCompileTimeErrors = new Set<Element>();
+ final Map<Element, DiagnosticMessage> elementsWithCompileTimeErrors =
+ new Map<Element, DiagnosticMessage>();
fromEnvironment(String name) => null;
@@ -408,16 +409,7 @@ abstract class Compiler {
static const int PHASE_COMPILING = 3;
int phase;
- bool compilationFailedInternal = false;
-
- bool get compilationFailed => compilationFailedInternal;
-
- void set compilationFailed(bool value) {
- if (value) {
- elementsWithCompileTimeErrors.add(currentElement);
- }
- compilationFailedInternal = value;
- }
+ bool compilationFailed = false;
/// Set by the backend if real reflection is detected in use of dart:mirrors.
bool disableTypeInferenceForMirrors = false;
@@ -1423,8 +1415,17 @@ abstract class Compiler {
backend.forgetElement(element);
}
+ /// Returns [true] if a compile-time error has been reported for element.
bool elementHasCompileTimeError(Element element) {
- return elementsWithCompileTimeErrors.contains(element);
+ return elementsWithCompileTimeErrors.containsKey(element);
+ }
+
+ /// Associate [element] with a compile-time error [message].
+ void registerCompiletimeError(Element element, DiagnosticMessage message) {
+ // The information is only needed if [generateCodeWithCompileTimeErrors].
+ if (generateCodeWithCompileTimeErrors) {
+ elementsWithCompileTimeErrors[element] = message;
+ }
}
EventSink<String> outputProvider(String name, String extension) {
@@ -1693,6 +1694,7 @@ class _CompilerDiagnosticReporter extends DiagnosticReporter {
kind == api.Diagnostic.CRASH ||
(options.fatalWarnings &&
kind == api.Diagnostic.WARNING)) {
+ compiler.registerCompiletimeError(currentElement, 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