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

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

Issue 27008003: Handle clash of prefix/non-prefix imports. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased + updated cf. comments. Created 7 years, 2 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
Index: sdk/lib/_internal/compiler/implementation/library_loader.dart
diff --git a/sdk/lib/_internal/compiler/implementation/library_loader.dart b/sdk/lib/_internal/compiler/implementation/library_loader.dart
index 85191f17ef019e4440efdf532f39c81134e4eff7..0e34da1c07e9d19f920fa56d348f6d497922caeb 100644
--- a/sdk/lib/_internal/compiler/implementation/library_loader.dart
+++ b/sdk/lib/_internal/compiler/implementation/library_loader.dart
@@ -521,36 +521,18 @@ class ImportLink {
var combinatorFilter = new CombinatorFilter.fromTag(import);
if (import != null && import.prefix != null) {
SourceString prefix = import.prefix.source;
- Element e = importingLibrary.find(prefix);
- if (e == null) {
- e = new PrefixElementX(prefix, importingLibrary.entryCompilationUnit,
- import.getBeginToken());
- importingLibrary.addToScope(e, compiler);
- }
- if (!identical(e.kind, ElementKind.PREFIX)) {
- compiler.withCurrentElement(e, () {
- compiler.reportWarning(e, 'duplicated definition');
- });
- compiler.reportFatalError(
- import.prefix,
- MessageKind.GENERIC, {'text': 'Error: Duplicate definition.'});
+ Element existingElement = importingLibrary.find(prefix);
+ PrefixElement prefixElement;
+ if (existingElement == null || !existingElement.isPrefix()) {
+ prefixElement = new PrefixElementX(prefix,
+ importingLibrary.entryCompilationUnit, import.getBeginToken());
+ } else {
+ prefixElement = existingElement;
}
- PrefixElement prefixElement = e;
+ importingLibrary.addToScope(prefixElement, compiler);
importedLibrary.forEachExport((Element element) {
if (combinatorFilter.exclude(element)) return;
- // TODO(johnniwinther): Clean-up like [checkDuplicateLibraryName].
- Element existing =
- prefixElement.imported.putIfAbsent(element.name, () => element);
- if (!identical(existing, element)) {
- compiler.withCurrentElement(existing, () {
- compiler.reportWarning(existing, 'duplicated import');
- });
- compiler.withCurrentElement(element, () {
- compiler.reportFatalError(
- element,
- MessageKind.GENERIC, {'text': 'Error: Duplicated import.'});
- });
- }
+ prefixElement.addImport(element, import, compiler);
});
} else {
importedLibrary.forEachExport((Element element) {

Powered by Google App Engine
This is Rietveld 408576698