Index: sdk/lib/_internal/compiler/implementation/compiler.dart |
diff --git a/sdk/lib/_internal/compiler/implementation/compiler.dart b/sdk/lib/_internal/compiler/implementation/compiler.dart |
index 067ee8832462ed521dcf011f14cf57bf43853467..e0de9ffee27b0c102d411996203d5534b3ced5d3 100644 |
--- a/sdk/lib/_internal/compiler/implementation/compiler.dart |
+++ b/sdk/lib/_internal/compiler/implementation/compiler.dart |
@@ -416,7 +416,9 @@ abstract class Compiler implements DiagnosticListener { |
LibraryElement jsHelperLibrary; |
LibraryElement interceptorsLibrary; |
LibraryElement foreignLibrary; |
+ |
LibraryElement mainApp; |
+ FunctionElement mainFunction; |
/// Initialized when dart:mirrors is loaded. |
LibraryElement mirrorsLibrary; |
@@ -1025,7 +1027,7 @@ abstract class Compiler implements DiagnosticListener { |
void compileLoadedLibraries() { |
Element main = null; |
if (mainApp != null) { |
- main = mainApp.find(MAIN); |
+ main = mainApp.findExported(MAIN); |
if (main == null) { |
if (!analyzeOnly) { |
// Allow analyze only of libraries with no main. |
@@ -1042,14 +1044,19 @@ abstract class Compiler implements DiagnosticListener { |
"Use '--analyze-all' to analyze all code in the library."}); |
} |
} else { |
- if (!main.isFunction()) { |
+ if (main.isErroneous()) { |
+ reportFatalError( |
+ main, |
+ MessageKind.GENERIC, |
+ {'text': "Error: Cannot determine which '$MAIN' to use."}); |
+ } else if (!main.isFunction()) { |
reportFatalError( |
main, |
MessageKind.GENERIC, |
{'text': "Error: '$MAIN' is not a function."}); |
} |
- FunctionElement mainMethod = main; |
- FunctionSignature parameters = mainMethod.computeSignature(this); |
+ mainFunction = main; |
+ FunctionSignature parameters = mainFunction.computeSignature(this); |
if (parameters.parameterCount > 2) { |
int index = 0; |
parameters.forEachParameter((Element parameter) { |
@@ -1110,7 +1117,7 @@ abstract class Compiler implements DiagnosticListener { |
if (hasIsolateSupport()) { |
enqueuer.codegen.addToWorkList( |
isolateHelperLibrary.find(Compiler.START_ROOT_ISOLATE)); |
- enqueuer.codegen.registerGetOfStaticFunction(mainApp.find(MAIN)); |
+ enqueuer.codegen.registerGetOfStaticFunction(main); |
} |
if (enabledNoSuchMethod) { |
backend.enableNoSuchMethod(enqueuer.codegen); |