Index: pkg/compiler/lib/src/library_loader.dart |
diff --git a/pkg/compiler/lib/src/library_loader.dart b/pkg/compiler/lib/src/library_loader.dart |
index 0903f6e84aaf494005a61d4150989ddd4230f410..9caf929497f187d9dfbe50b2a1b65ee05318526f 100644 |
--- a/pkg/compiler/lib/src/library_loader.dart |
+++ b/pkg/compiler/lib/src/library_loader.dart |
@@ -873,12 +873,13 @@ class _DillLibraryLoaderTask extends CompilerTask implements LibraryLoaderTask { |
_worldBuilder = new KernelWorldBuilder(reporter, program); |
program.libraries.forEach((ir.Library library) => _allLoadedLibraries |
.add(_worldBuilder.lookupLibrary(library.importUri))); |
- // TODO(efortuna): Handle `prgram.mainMethod == null` gracefully. |
+ LibraryEntity rootLibrary = null; |
+ if (program.mainMethod != null) { |
+ rootLibrary = _worldBuilder |
+ .lookupLibrary(program.mainMethod.enclosingLibrary.importUri); |
+ } |
return new _LoadedLibrariesAdapter( |
- _worldBuilder |
- .lookupLibrary(program.mainMethod.enclosingLibrary.importUri), |
- _allLoadedLibraries, |
- _worldBuilder); |
+ rootLibrary, _allLoadedLibraries, _worldBuilder); |
}); |
}); |
} |