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

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: 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
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..86f7ab7fbc2e66ae71b03fbc496475431d707c7a 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,13 @@ abstract class Compiler {
backend.forgetElement(element);
}
+ /// Returns [true] if a compile-time error has been reported for element.
+ ///
+ /// This function should only be called when
+ /// [generateCodeWithCompileTimeErrors] is true.
bool elementHasCompileTimeError(Element element) {
- return elementsWithCompileTimeErrors.contains(element);
+ assert(generateCodeWithCompileTimeErrors);
Johnni Winther 2015/12/14 11:31:20 Change the approach to only store message when [ge
sigurdm 2015/12/14 12:07:43 Done.
+ return elementsWithCompileTimeErrors.containsKey(element);
}
EventSink<String> outputProvider(String name, String extension) {
@@ -1693,6 +1690,7 @@ class _CompilerDiagnosticReporter extends DiagnosticReporter {
kind == api.Diagnostic.CRASH ||
(options.fatalWarnings &&
kind == api.Diagnostic.WARNING)) {
+ compiler.elementsWithCompileTimeErrors[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') | pkg/compiler/lib/src/js_backend/backend.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698