Chromium Code Reviews| 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); |