Index: pkg/compiler/lib/src/compiler.dart |
diff --git a/pkg/compiler/lib/src/compiler.dart b/pkg/compiler/lib/src/compiler.dart |
index b591b4042bd5aa8550d3c77d7260fa1742475abc..8b587156fcf8cb18ef901e64a8b93f9714db9561 100644 |
--- a/pkg/compiler/lib/src/compiler.dart |
+++ b/pkg/compiler/lib/src/compiler.dart |
@@ -115,8 +115,7 @@ abstract class Compiler { |
ResolvedUriTranslator get resolvedUriTranslator; |
- LibraryEntity mainApp; |
- FunctionEntity mainFunction; |
+ Uri mainLibraryUri; |
DiagnosticReporter get reporter => _reporter; |
Resolution get resolution => _resolution; |
@@ -433,6 +432,7 @@ abstract class Compiler { |
Uri resolvePatchUri(String dartLibraryPath); |
Future runInternal(Uri uri) async { |
+ mainLibraryUri = uri; |
// TODO(ahe): This prevents memory leaks when invoking the compiler |
// multiple times. Implement a better mechanism where we can store |
// such caches in the compiler and get access to them through a |
@@ -457,6 +457,7 @@ abstract class Compiler { |
processLoadedLibraries(loadedLibraries); |
}); |
} |
+ LibraryEntity mainApp; |
if (uri != null) { |
if (options.analyzeOnly) { |
reporter.log('Analyzing $uri (${options.buildId})'); |
@@ -515,7 +516,8 @@ abstract class Compiler { |
selfTask.measureSubtask("Compiler.compileLoadedLibraries", () { |
ResolutionEnqueuer resolutionEnqueuer = startResolution(); |
WorldImpactBuilderImpl mainImpact = new WorldImpactBuilderImpl(); |
- mainFunction = frontendStrategy.computeMain(rootLibrary, mainImpact); |
+ FunctionEntity mainFunction = |
+ frontendStrategy.computeMain(rootLibrary, mainImpact); |
if (!options.loadFromDill) { |
// TODO(johnniwinther): Support mirrors usages analysis from dill. |
@@ -526,7 +528,7 @@ abstract class Compiler { |
// compile-time constants that are metadata. This means adding |
// something to the resolution queue. So we cannot wait with |
// this until after the resolution queue is processed. |
- deferredLoadTask.beforeResolution(this); |
+ deferredLoadTask.beforeResolution(rootLibrary); |
impactStrategy = backend.createImpactStrategy( |
supportDeferredLoad: deferredLoadTask.isProgramSplit, |
supportDumpInfo: options.dumpInfo, |
@@ -596,8 +598,9 @@ abstract class Compiler { |
if (options.analyzeOnly) return; |
assert(mainFunction != null); |
- ClosedWorldRefiner closedWorldRefiner = closeResolution(); |
+ ClosedWorldRefiner closedWorldRefiner = closeResolution(mainFunction); |
ClosedWorld closedWorld = closedWorldRefiner.closedWorld; |
+ mainFunction = closedWorld.elementEnvironment.mainFunction; |
reporter.log('Inferring types...'); |
globalInference.runGlobalTypeInference( |
@@ -637,7 +640,7 @@ abstract class Compiler { |
}); |
/// Perform the steps needed to fully end the resolution phase. |
- ClosedWorldRefiner closeResolution() { |
+ ClosedWorldRefiner closeResolution(FunctionEntity mainFunction) { |
phase = PHASE_DONE_RESOLVING; |
ClosedWorld closedWorld = resolutionWorldBuilder.closeWorld(); |
@@ -910,8 +913,8 @@ abstract class Compiler { |
Iterable<CodeLocation> computeUserCodeLocations( |
{bool assumeInUserCode: false}) { |
List<CodeLocation> userCodeLocations = <CodeLocation>[]; |
- if (mainApp != null) { |
- userCodeLocations.add(new CodeLocation(mainApp.canonicalUri)); |
+ if (mainLibraryUri != null) { |
+ userCodeLocations.add(new CodeLocation(mainLibraryUri)); |
} |
if (librariesToAnalyzeWhenRun != null) { |
userCodeLocations.addAll( |
@@ -955,7 +958,7 @@ abstract class Compiler { |
// Record as global error. |
// TODO(zarah): Extend element model to represent compile-time |
// errors instead of using a map. |
- element = mainFunction; |
+ element = frontendStrategy.elementEnvironment.mainFunction; |
} |
elementsWithCompileTimeErrors |
.putIfAbsent(element, () => <DiagnosticMessage>[]) |