Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(239)

Unified Diff: sdk/lib/_internal/compiler/implementation/deferred_load.dart

Issue 169703003: Add prefix constraints for deferred imports. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/warnings.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/deferred_load.dart
diff --git a/sdk/lib/_internal/compiler/implementation/deferred_load.dart b/sdk/lib/_internal/compiler/implementation/deferred_load.dart
index 47ea3a1bc0c4f059188e0f53938d5992644f837a..1f0040aba2deb0df0882fbcd178dc92640658686 100644
--- a/sdk/lib/_internal/compiler/implementation/deferred_load.dart
+++ b/sdk/lib/_internal/compiler/implementation/deferred_load.dart
@@ -617,13 +617,20 @@ class DeferredLoadTask extends CompilerTask {
_allDeferredImports[_fakeMainImport] = compiler.mainApp;
bool deferredUsedFromMain = false;
var lastDeferred;
+ Map<String, List<Import>> prefixImports = new Map<String, List<Import>>();
for (LibraryElement library in compiler.libraries.values) {
+ prefixImports.clear();
// TODO(sigurdm): Make helper getLibraryImportTags when tags is a List
// instead of a Link.
for (LibraryTag tag in library.tags) {
if (tag is! Import) continue;
Import import = tag;
if (_isImportDeferred(import)) {
+ if (import.prefix == null) {
+ compiler.reportError(
+ import,
+ MessageKind.DEFERRED_LIBRARY_WITHOUT_PREFIX);
+ }
splitProgram = true;
_allDeferredImports[tag] = library.getLibraryFromTag(tag);
lastDeferred = import.metadata.first;
@@ -631,6 +638,20 @@ class DeferredLoadTask extends CompilerTask {
deferredUsedFromMain = true;
}
}
+ if (import.prefix != null) {
floitsch 2014/02/18 09:45:22 Add comment explaining why simpler approaches woul
+ prefixImports.putIfAbsent(import.prefix.toString(),
+ () => new List<Import>()).add(import);
+ }
+ }
+ for (String prefix in prefixImports.keys) {
+ List<Import> imports = prefixImports[prefix];
+ if (imports.length <= 1) continue;
+ for (Import import in imports) {
+ if (_isImportDeferred(import)) {
+ compiler.reportError(import,
+ MessageKind.DEFERRED_LIBRARY_DUPLICATE_PREFIX);
+ }
+ }
}
}
if (splitProgram && !deferredUsedFromMain) {
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/warnings.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698