Chromium Code Reviews| Index: dart/pkg/compiler/lib/src/compiler.dart |
| diff --git a/dart/pkg/compiler/lib/src/compiler.dart b/dart/pkg/compiler/lib/src/compiler.dart |
| index dbf06e4f2fb3a86f89de6a5c6ab3dbf7228bcc4c..9aaa1c9c07c51a1f1038574d09b2c50250df2646 100644 |
| --- a/dart/pkg/compiler/lib/src/compiler.dart |
| +++ b/dart/pkg/compiler/lib/src/compiler.dart |
| @@ -833,6 +833,9 @@ abstract class Compiler implements DiagnosticListener { |
| Element boolEnvironment; |
| Element stringEnvironment; |
| + /// Tracks elements with compile-time errors. |
| + final Set<Element> elementsWithCompileTimeErrors = new Set<Element>(); |
| + |
| fromEnvironment(String name) => null; |
| Element get currentElement => _currentElement; |
| @@ -950,7 +953,16 @@ abstract class Compiler implements DiagnosticListener { |
| static const int PHASE_COMPILING = 3; |
| int phase; |
| - bool compilationFailed = false; |
| + bool compilationFailedInternal = false; |
| + |
| + bool get compilationFailed => compilationFailedInternal; |
| + |
| + void set compilationFailed(bool value) { |
| + if (value) { |
| + elementsWithCompileTimeErrors.add(currentElement); |
|
Johnni Winther
2015/01/15 11:34:46
How do we know that currentElement is correct (and
ahe
2015/01/15 12:09:31
I don't think we do. But I'm not sure it matters.
|
| + } |
| + compilationFailedInternal = value; |
| + } |
| bool hasCrashed = false; |
| @@ -1067,7 +1079,9 @@ abstract class Compiler implements DiagnosticListener { |
| bool get compileAll => false; |
| - bool get disableTypeInference => disableTypeInferenceFlag; |
| + bool get disableTypeInference { |
| + return disableTypeInferenceFlag || compilationFailed; |
| + } |
| int getNextFreeClassId() => nextFreeClassId++; |
| @@ -1539,7 +1553,6 @@ abstract class Compiler implements DiagnosticListener { |
| processQueue(enqueuer.resolution, mainFunction); |
| enqueuer.resolution.logSummary(log); |
| - if (compilationFailed) return; |
| if (!showPackageWarnings && !suppressWarnings) { |
| suppressedWarnings.forEach((Uri uri, SuppressionInfo info) { |
| MessageKind kind = MessageKind.HIDDEN_WARNINGS_HINTS; |
| @@ -1557,9 +1570,11 @@ abstract class Compiler implements DiagnosticListener { |
| }); |
| } |
| if (analyzeOnly) { |
| - if (!analyzeAll) { |
| + if (!analyzeAll && !compilationFailed) { |
| // No point in reporting unused code when [analyzeAll] is true: all |
| // code is artificially used. |
| + // If compilation failed, it is possible that the error prevents the |
| + // compiler from analyzing all the code. |
| reportUnusedCode(); |
| } |
| return; |
| @@ -1601,8 +1616,6 @@ abstract class Compiler implements DiagnosticListener { |
| processQueue(enqueuer.codegen, mainFunction); |
| enqueuer.codegen.logSummary(log); |
| - if (compilationFailed) return; |
| - |
| int programSize = backend.assembleProgram(); |
| if (dumpInfo) { |
| @@ -1666,8 +1679,7 @@ abstract class Compiler implements DiagnosticListener { |
| withCurrentElement(work.element, () => work.run(this, world)); |
| }); |
| world.queueIsClosed = true; |
| - if (compilationFailed) return; |
| - assert(world.checkNoEnqueuedInvokedInstanceMethods()); |
| + assert(compilationFailed || world.checkNoEnqueuedInvokedInstanceMethods()); |
| } |
| /** |
| @@ -2078,6 +2090,10 @@ abstract class Compiler implements DiagnosticListener { |
| } |
| backend.forgetElement(element); |
| } |
| + |
| + bool elementHasCompileTimeError(Element element) { |
| + return elementsWithCompileTimeErrors.contains(element); |
| + } |
| } |
| class CompilerTask { |