Improve handling of duplicated declarations

Change-Id: Ib13a14908c8c6a1fc8e78c1bf5b031317945a344
Reviewed-on: https://dart-review.googlesource.com/c/85682
Commit-Queue: Peter von der Ahé <ahe@google.com>
Auto-Submit: Peter von der Ahé <ahe@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
diff --git a/pkg/front_end/lib/src/fasta/builder/builder.dart b/pkg/front_end/lib/src/fasta/builder/builder.dart
index 5abea63..70b361c 100644
--- a/pkg/front_end/lib/src/fasta/builder/builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/builder.dart
@@ -46,6 +46,8 @@
 
 export 'modifier_builder.dart' show ModifierBuilder;
 
+export 'name_iterator.dart' show NameIterator;
+
 export 'named_type_builder.dart' show NamedTypeBuilder;
 
 export 'prefix_builder.dart' show PrefixBuilder;
diff --git a/pkg/front_end/lib/src/fasta/builder/library_builder.dart b/pkg/front_end/lib/src/fasta/builder/library_builder.dart
index a53b6a4..0d54faa 100644
--- a/pkg/front_end/lib/src/fasta/builder/library_builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/library_builder.dart
@@ -27,6 +27,7 @@
         ClassBuilder,
         Declaration,
         ModifierBuilder,
+        NameIterator,
         PrefixBuilder,
         Scope,
         ScopeBuilder,
@@ -75,6 +76,14 @@
 
   Uri get uri;
 
+  Iterator<Declaration> get iterator {
+    return LibraryLocalDeclarationIterator(this);
+  }
+
+  NameIterator get nameIterator {
+    return new LibraryLocalDeclarationNameIterator(this);
+  }
+
   Declaration addBuilder(String name, Declaration declaration, int charOffset);
 
   void addExporter(
@@ -198,14 +207,6 @@
 
   void addSyntheticDeclarationOfDynamic();
 
-  void forEach(void f(String name, Declaration declaration)) {
-    scope.forEach((String name, Declaration declaration) {
-      if (declaration.parent == this) {
-        f(name, declaration);
-      }
-    });
-  }
-
   /// Don't use for scope lookup. Only use when an element is known to exist
   /// (and not a setter).
   Declaration operator [](String name) {
@@ -228,3 +229,39 @@
 
   void recordAccess(int charOffset, int length, Uri fileUri) {}
 }
+
+class LibraryLocalDeclarationIterator implements Iterator<Declaration> {
+  final LibraryBuilder library;
+  final Iterator<Declaration> iterator;
+
+  LibraryLocalDeclarationIterator(this.library)
+      : iterator = library.scope.iterator;
+
+  Declaration get current => iterator.current;
+
+  bool moveNext() {
+    while (iterator.moveNext()) {
+      if (current.parent == library) return true;
+    }
+    return false;
+  }
+}
+
+class LibraryLocalDeclarationNameIterator implements NameIterator {
+  final LibraryBuilder library;
+  final NameIterator iterator;
+
+  LibraryLocalDeclarationNameIterator(this.library)
+      : iterator = library.scope.nameIterator;
+
+  Declaration get current => iterator.current;
+
+  String get name => iterator.name;
+
+  bool moveNext() {
+    while (iterator.moveNext()) {
+      if (current.parent == library) return true;
+    }
+    return false;
+  }
+}
diff --git a/pkg/front_end/lib/src/fasta/builder/name_iterator.dart b/pkg/front_end/lib/src/fasta/builder/name_iterator.dart
new file mode 100644
index 0000000..9a93124
--- /dev/null
+++ b/pkg/front_end/lib/src/fasta/builder/name_iterator.dart
@@ -0,0 +1,11 @@
+// Copyright (c) 2016, the Dart project authors.  Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library fasta.name_iterator;
+
+import 'builder.dart' show Declaration;
+
+abstract class NameIterator implements Iterator<Declaration> {
+  String get name;
+}
diff --git a/pkg/front_end/lib/src/fasta/import.dart b/pkg/front_end/lib/src/fasta/import.dart
index b484601..b15bce3 100644
--- a/pkg/front_end/lib/src/fasta/import.dart
+++ b/pkg/front_end/lib/src/fasta/import.dart
@@ -80,7 +80,7 @@
     });
     if (prefixBuilder != null) {
       Declaration existing =
-          importer.addBuilder(prefix, prefixBuilder, charOffset);
+          importer.addBuilder(prefix, prefixBuilder, prefixCharOffset);
       if (existing == prefixBuilder) {
         importer.addToScope(prefix, prefixBuilder, prefixCharOffset, true);
       }
diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_library_builder.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_library_builder.dart
index 895661e..9cae333 100644
--- a/pkg/front_end/lib/src/fasta/kernel/kernel_library_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/kernel_library_builder.dart
@@ -134,6 +134,7 @@
         LoadLibraryBuilder,
         MemberBuilder,
         MetadataBuilder,
+        NameIterator,
         PrefixBuilder,
         ProcedureBuilder,
         QualifiedName,
@@ -1308,7 +1309,10 @@
   @override
   void applyPatches() {
     if (!isPatch) return;
-    origin.forEach((String name, Declaration member) {
+    NameIterator originDeclarations = origin.nameIterator;
+    while (originDeclarations.moveNext()) {
+      String name = originDeclarations.name;
+      Declaration member = originDeclarations.current;
       bool isSetter = member.isSetter;
       Declaration patch = isSetter ? scope.setters[name] : scope.local[name];
       if (patch != null) {
@@ -1326,8 +1330,11 @@
           scopeBuilder.addMember(name, member);
         }
       }
-    });
-    forEach((String name, Declaration member) {
+    }
+    NameIterator patchDeclarations = nameIterator;
+    while (patchDeclarations.moveNext()) {
+      String name = patchDeclarations.name;
+      Declaration member = patchDeclarations.current;
       // We need to inject all non-patch members into the origin library. This
       // should only apply to private members.
       if (member.isPatch) {
@@ -1337,15 +1344,16 @@
       } else {
         origin.exportMemberFromPatch(name, member);
       }
-    });
+    }
   }
 
   int finishPatchMethods() {
     if (!isPatch) return 0;
     int count = 0;
-    forEach((String name, Declaration member) {
-      count += member.finishPatch();
-    });
+    Iterator<Declaration> iterator = this.iterator;
+    while (iterator.moveNext()) {
+      count += iterator.current.finishPatch();
+    }
     return count;
   }
 
@@ -1662,7 +1670,9 @@
 
   void checkBoundsInOutline(TypeEnvironment typeEnvironment) {
     if (loader.target.legacyMode) return;
-    forEach((String name, Declaration declaration) {
+    Iterator<Declaration> iterator = this.iterator;
+    while (iterator.moveNext()) {
+      Declaration declaration = iterator.current;
       if (declaration is KernelFieldBuilder) {
         checkBoundsInField(declaration.target, typeEnvironment);
       } else if (declaration is KernelProcedureBuilder) {
@@ -1670,8 +1680,7 @@
       } else if (declaration is KernelClassBuilder) {
         declaration.checkBoundsInOutline(typeEnvironment);
       }
-    });
-
+    }
     inferredTypes.clear();
   }
 }
diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart
index ee564d1..424d996 100644
--- a/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart
@@ -233,11 +233,13 @@
     List<SourceClassBuilder> result = <SourceClassBuilder>[];
     loader.builders.forEach((Uri uri, LibraryBuilder library) {
       if (library.loader == loader) {
-        library.forEach((String name, Declaration member) {
+        Iterator<Declaration> iterator = library.iterator;
+        while (iterator.moveNext()) {
+          Declaration member = iterator.current;
           if (member is SourceClassBuilder && !member.isPatch) {
             result.add(member);
           }
-        });
+        }
       }
     });
     return result;
@@ -385,24 +387,23 @@
     Class objectClass = this.objectClass;
     loader.builders.forEach((Uri uri, LibraryBuilder library) {
       if (library.loader == loader) {
-        library.forEach((String name, Declaration declaration) {
-          while (declaration != null) {
-            if (declaration is SourceClassBuilder) {
-              Class cls = declaration.target;
-              if (cls != objectClass) {
-                cls.supertype ??= objectClass.asRawSupertype;
-                declaration.supertype ??=
-                    new KernelNamedTypeBuilder("Object", null)
-                      ..bind(objectClassBuilder);
-              }
-              if (declaration.isMixinApplication) {
-                cls.mixedInType = declaration.mixedInType.buildMixedInType(
-                    library, declaration.charOffset, declaration.fileUri);
-              }
+        Iterator<Declaration> iterator = library.iterator;
+        while (iterator.moveNext()) {
+          Declaration declaration = iterator.current;
+          if (declaration is SourceClassBuilder) {
+            Class cls = declaration.target;
+            if (cls != objectClass) {
+              cls.supertype ??= objectClass.asRawSupertype;
+              declaration.supertype ??=
+                  new KernelNamedTypeBuilder("Object", null)
+                    ..bind(objectClassBuilder);
             }
-            declaration = declaration.next;
+            if (declaration.isMixinApplication) {
+              cls.mixedInType = declaration.mixedInType.buildMixedInType(
+                  library, declaration.charOffset, declaration.fileUri);
+            }
           }
-        });
+        }
       }
     });
     ticker.logMs("Installed Object as implicit superclass");
diff --git a/pkg/front_end/lib/src/fasta/scope.dart b/pkg/front_end/lib/src/fasta/scope.dart
index 6abbc4f..b7c8584 100644
--- a/pkg/front_end/lib/src/fasta/scope.dart
+++ b/pkg/front_end/lib/src/fasta/scope.dart
@@ -4,7 +4,8 @@
 
 library fasta.scope;
 
-import 'builder/builder.dart' show Declaration, TypeVariableBuilder;
+import 'builder/builder.dart'
+    show Declaration, NameIterator, TypeVariableBuilder;
 
 import 'fasta_codes.dart'
     show
@@ -68,6 +69,14 @@
             <String, Declaration>{}, <String, Declaration>{}, parent, debugName,
             isModifiable: isModifiable);
 
+  Iterator<Declaration> get iterator {
+    return new ScopeLocalDeclarationIterator(this);
+  }
+
+  NameIterator get nameIterator {
+    return new ScopeLocalDeclarationNameIterator(this);
+  }
+
   Scope copyWithParent(Scope parent, String debugName) {
     return new Scope(super.local, super.setters, parent, debugName,
         isModifiable: isModifiable);
@@ -365,3 +374,74 @@
     return declaration;
   }
 }
+
+class ScopeLocalDeclarationIterator implements Iterator<Declaration> {
+  Iterator<Declaration> local;
+  final Iterator<Declaration> setters;
+  Declaration current;
+
+  ScopeLocalDeclarationIterator(Scope scope)
+      : local = scope.local.values.iterator,
+        setters = scope.setters.values.iterator;
+
+  bool moveNext() {
+    Declaration next = current?.next;
+    if (next != null) {
+      current = next;
+      return true;
+    }
+    if (local != null) {
+      if (local.moveNext()) {
+        current = local.current;
+        return true;
+      }
+      local = null;
+    }
+    if (setters.moveNext()) {
+      current = setters.current;
+      return true;
+    } else {
+      current = null;
+      return false;
+    }
+  }
+}
+
+class ScopeLocalDeclarationNameIterator extends ScopeLocalDeclarationIterator
+    implements NameIterator {
+  Iterator<String> localNames;
+  final Iterator<String> setterNames;
+
+  String name;
+
+  ScopeLocalDeclarationNameIterator(Scope scope)
+      : localNames = scope.local.keys.iterator,
+        setterNames = scope.setters.keys.iterator,
+        super(scope);
+
+  bool moveNext() {
+    Declaration next = current?.next;
+    if (next != null) {
+      current = next;
+      return true;
+    }
+    if (local != null) {
+      if (local.moveNext()) {
+        localNames.moveNext();
+        current = local.current;
+        name = localNames.current;
+        return true;
+      }
+      localNames = null;
+    }
+    if (setters.moveNext()) {
+      setterNames.moveNext();
+      current = setters.current;
+      name = setterNames.current;
+      return true;
+    } else {
+      current = null;
+      return false;
+    }
+  }
+}
diff --git a/pkg/front_end/lib/src/fasta/source/diet_listener.dart b/pkg/front_end/lib/src/fasta/source/diet_listener.dart
index 7d3c35b..1890f1b 100644
--- a/pkg/front_end/lib/src/fasta/source/diet_listener.dart
+++ b/pkg/front_end/lib/src/fasta/source/diet_listener.dart
@@ -895,16 +895,19 @@
       Declaration nearestDeclaration;
       int minDistance = -1;
       do {
-        // [distance] will always be non-negative as we ensure [token] is
-        // always at the beginning of the declaration. The minimum distance
-        // will often be larger than 0, for example, in a class declaration
-        // where [token] will point to `abstract` or `class`, but the
-        // declaration's offset points to the name of the class.
-        int distance = declaration.charOffset - offset;
-        if (distance >= 0) {
-          if (minDistance == -1 || distance < minDistance) {
-            minDistance = distance;
-            nearestDeclaration = declaration;
+        // Only look at declarations from this file (part).
+        if (uri == declaration.fileUri) {
+          // [distance] will always be non-negative as we ensure [token] is
+          // always at the beginning of the declaration. The minimum distance
+          // will often be larger than 0, for example, in a class declaration
+          // where [token] will point to `abstract` or `class`, but the
+          // declaration's offset points to the name of the class.
+          int distance = declaration.charOffset - offset;
+          if (distance >= 0) {
+            if (minDistance == -1 || distance < minDistance) {
+              minDistance = distance;
+              nearestDeclaration = declaration;
+            }
           }
         }
         declaration = declaration.next;
diff --git a/pkg/front_end/lib/src/fasta/source/source_library_builder.dart b/pkg/front_end/lib/src/fasta/source/source_library_builder.dart
index f1cb326..ceae497 100644
--- a/pkg/front_end/lib/src/fasta/source/source_library_builder.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_library_builder.dart
@@ -23,6 +23,7 @@
         LibraryBuilder,
         MemberBuilder,
         MetadataBuilder,
+        NameIterator,
         PrefixBuilder,
         ProcedureBuilder,
         QualifiedName,
@@ -72,7 +73,7 @@
 
 import '../configuration.dart' show Configuration;
 
-import '../problems.dart' show unhandled;
+import '../problems.dart' show unexpected, unhandled;
 
 import 'source_loader.dart' show SourceLoader;
 
@@ -515,9 +516,16 @@
             ? currentDeclaration.setters
             : currentDeclaration.members);
     Declaration existing = members[name];
+    if (declaration.next != null && declaration.next != existing) {
+      unexpected(
+          "${declaration.next.fileUri}@${declaration.next.charOffset}",
+          "${existing?.fileUri}@${existing?.charOffset}",
+          declaration.charOffset,
+          declaration.fileUri);
+    }
     declaration.next = existing;
     if (declaration is PrefixBuilder && existing is PrefixBuilder) {
-      assert(existing.next == null);
+      assert(existing.next is! PrefixBuilder);
       Declaration deferred;
       Declaration other;
       if (declaration.deferred) {
@@ -552,7 +560,7 @@
         }
       }
       addProblem(templateDuplicatedDeclaration.withArguments(fullName),
-          charOffset, fullName.length, fileUri,
+          charOffset, fullName.length, declaration.fileUri,
           context: <LocatedMessage>[
             templateDuplicatedDeclarationCause
                 .withArguments(fullName)
@@ -587,12 +595,10 @@
   R build(LibraryBuilder coreLibrary) {
     assert(implementationBuilders.isEmpty);
     canAddImplementationBuilders = true;
-    forEach((String name, Declaration declaration) {
-      do {
-        buildBuilder(declaration, coreLibrary);
-        declaration = declaration.next;
-      } while (declaration != null);
-    });
+    Iterator<Declaration> iterator = this.iterator;
+    while (iterator.moveNext()) {
+      buildBuilder(iterator.current, coreLibrary);
+    }
     for (List list in implementationBuilders) {
       String name = list[0];
       Declaration declaration = list[1];
@@ -720,15 +726,47 @@
       }
     }
     part.validatePart(this, usedParts);
-    part.forEach((String name, Declaration declaration) {
+    NameIterator partDeclarations = part.nameIterator;
+    while (partDeclarations.moveNext()) {
+      String name = partDeclarations.name;
+      Declaration declaration = partDeclarations.current;
+
       if (declaration.next != null) {
-        // TODO(ahe): This shouldn't be necessary as setters have been added to
-        // their own scope.
-        assert(declaration.next.next == null);
-        addBuilder(name, declaration.next, declaration.next.charOffset);
+        List<Declaration> duplicated = <Declaration>[];
+        while (declaration.next != null) {
+          duplicated.add(declaration);
+          partDeclarations.moveNext();
+          declaration = partDeclarations.current;
+        }
+        duplicated.add(declaration);
+        // Handle duplicated declarations in the part.
+        //
+        // Duplicated declarations are handled by creating a linked list using
+        // the `next` field. This is preferred over making all scope entries be
+        // a `List<Declaration>`.
+        //
+        // We maintain the linked list so that the last entry is easy to
+        // recognize (it's `next` field is null). This means that it is
+        // reversed with respect to source code order. Since kernel doesn't
+        // allow duplicated declarations, we ensure that we only add the first
+        // declaration to the kernel tree.
+        //
+        // Since the duplicated declarations are stored in reverse order, we
+        // iterate over them in reverse order as this is simpler and normally
+        // not a problem. However, in this case we need to call [addBuilder] in
+        // source order as it would otherwise create cycles.
+        //
+        // We also need to be careful preserving the order of the links. The
+        // part library still keeps these declarations in its scope so that
+        // DietListener can find them.
+        for (int i = duplicated.length; i > 0; i--) {
+          Declaration declaration = duplicated[i - 1];
+          addBuilder(name, declaration, declaration.charOffset);
+        }
+      } else {
+        addBuilder(name, declaration, declaration.charOffset);
       }
-      addBuilder(name, declaration, declaration.charOffset);
-    });
+    }
     types.addAll(part.types);
     constructorReferences.addAll(part.constructorReferences);
     part.partOfLibrary = this;
@@ -737,7 +775,10 @@
   }
 
   void buildInitialScopes() {
-    forEach(addToExportScope);
+    NameIterator iterator = nameIterator;
+    while (iterator.moveNext()) {
+      addToExportScope(iterator.name, iterator.current);
+    }
   }
 
   void addImportsToScope() {
@@ -798,9 +839,10 @@
   @override
   int resolveConstructors(_) {
     int count = 0;
-    forEach((String name, Declaration member) {
-      count += member.resolveConstructors(this);
-    });
+    Iterator<Declaration> iterator = this.iterator;
+    while (iterator.moveNext()) {
+      count += iterator.current.resolveConstructors(this);
+    }
     return count;
   }
 
@@ -819,9 +861,10 @@
 
   @override
   void instrumentTopLevelInference(Instrumentation instrumentation) {
-    forEach((String name, Declaration member) {
-      member.instrumentTopLevelInference(instrumentation);
-    });
+    Iterator<Declaration> iterator = this.iterator;
+    while (iterator.moveNext()) {
+      iterator.current.instrumentTopLevelInference(instrumentation);
+    }
   }
 
   @override
diff --git a/pkg/front_end/lib/src/fasta/source/source_loader.dart b/pkg/front_end/lib/src/fasta/source/source_loader.dart
index ebf0fa1..5b41004 100644
--- a/pkg/front_end/lib/src/fasta/source/source_loader.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_loader.dart
@@ -400,12 +400,10 @@
     builders.forEach((Uri uri, dynamic l) {
       SourceLibraryBuilder library = l;
       Set<Declaration> members = new Set<Declaration>();
-      library.forEach((String name, Declaration member) {
-        while (member != null) {
-          members.add(member);
-          member = member.next;
-        }
-      });
+      Iterator<Declaration> iterator = library.iterator;
+      while (iterator.moveNext()) {
+        members.add(iterator.current);
+      }
       List<String> exports = <String>[];
       library.exportScope.forEach((String name, Declaration member) {
         while (member != null) {
@@ -926,15 +924,17 @@
         typeInferenceEngine.typeSchemaEnvironment,
         instrumentation,
         target.legacyMode);
-    builders.forEach((Uri uri, LibraryBuilder library) {
+    for (LibraryBuilder library in builders.values) {
       if (library.loader == this) {
-        library.forEach((String name, Declaration member) {
+        Iterator<Declaration> iterator = library.iterator;
+        while (iterator.moveNext()) {
+          Declaration member = iterator.current;
           if (member is FieldBuilder) {
             member.prepareTopLevelInference();
           }
-        });
+        }
       }
-    });
+    }
     {
       // Note: we need to create a list before iterating, since calling
       // builder.prepareTopLevelInference causes further class hierarchy
diff --git a/pkg/front_end/testcases/bug31124.dart.strong.expect b/pkg/front_end/testcases/bug31124.dart.strong.expect
index 90dd470..71f519f 100644
--- a/pkg/front_end/testcases/bug31124.dart.strong.expect
+++ b/pkg/front_end/testcases/bug31124.dart.strong.expect
@@ -25,5 +25,6 @@
 
 library;
 import self as self;
+import "dart:core" as core;
 
-static field dynamic a;
+static field () → core::String a;
diff --git a/pkg/front_end/testcases/bug31124.dart.strong.transformed.expect b/pkg/front_end/testcases/bug31124.dart.strong.transformed.expect
index b75686c..90fd8c8 100644
--- a/pkg/front_end/testcases/bug31124.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/bug31124.dart.strong.transformed.expect
@@ -11,5 +11,6 @@
 
 library;
 import self as self;
+import "dart:core" as core;
 
-static field dynamic a;
+static field () → core::String a;
diff --git a/pkg/front_end/testcases/duplicated_bad_prefix.dart.legacy.expect b/pkg/front_end/testcases/duplicated_bad_prefix.dart.legacy.expect
index 157828e..bb80ade 100644
--- a/pkg/front_end/testcases/duplicated_bad_prefix.dart.legacy.expect
+++ b/pkg/front_end/testcases/duplicated_bad_prefix.dart.legacy.expect
@@ -11,9 +11,9 @@
 //   Dupe.a b;
 //   ^^^^^^
 //
-// pkg/front_end/testcases/duplicated_bad_prefix.dart:6:1: Warning: 'C' is imported from both 'pkg/front_end/testcases/duplicated_bad_prefix_lib1.dart' and 'pkg/front_end/testcases/duplicated_bad_prefix_lib2.dart'.
+// pkg/front_end/testcases/duplicated_bad_prefix.dart:6:45: Warning: 'C' is imported from both 'pkg/front_end/testcases/duplicated_bad_prefix_lib1.dart' and 'pkg/front_end/testcases/duplicated_bad_prefix_lib2.dart'.
 // import 'duplicated_bad_prefix_lib2.dart' as dupe;
-// ^
+//                                             ^
 //
 // pkg/front_end/testcases/duplicated_bad_prefix.dart:13:3: Warning: 'Dupe.a' isn't a type.
 //   Dupe.a b;
@@ -35,6 +35,9 @@
     ;
 }
 class Dupe extends core::Object {
+  synthetic constructor •() → self::Dupe
+    : super core::Object::•()
+    ;
 }
 class C extends core::Object {
   field invalid-type b = null;
diff --git a/pkg/front_end/testcases/duplicated_bad_prefix.dart.legacy.transformed.expect b/pkg/front_end/testcases/duplicated_bad_prefix.dart.legacy.transformed.expect
index 7d25f05..c095d13 100644
--- a/pkg/front_end/testcases/duplicated_bad_prefix.dart.legacy.transformed.expect
+++ b/pkg/front_end/testcases/duplicated_bad_prefix.dart.legacy.transformed.expect
@@ -14,6 +14,9 @@
     ;
 }
 class Dupe extends core::Object {
+  synthetic constructor •() → self::Dupe
+    : super core::Object::•()
+    ;
 }
 class C extends core::Object {
   field invalid-type b = null;
diff --git a/pkg/front_end/testcases/duplicated_bad_prefix.dart.outline.expect b/pkg/front_end/testcases/duplicated_bad_prefix.dart.outline.expect
index 4917a59..28dac21 100644
--- a/pkg/front_end/testcases/duplicated_bad_prefix.dart.outline.expect
+++ b/pkg/front_end/testcases/duplicated_bad_prefix.dart.outline.expect
@@ -11,9 +11,9 @@
 //   Dupe.a b;
 //   ^^^^^^
 //
-// pkg/front_end/testcases/duplicated_bad_prefix.dart:6:1: Warning: 'C' is imported from both 'pkg/front_end/testcases/duplicated_bad_prefix_lib1.dart' and 'pkg/front_end/testcases/duplicated_bad_prefix_lib2.dart'.
+// pkg/front_end/testcases/duplicated_bad_prefix.dart:6:45: Warning: 'C' is imported from both 'pkg/front_end/testcases/duplicated_bad_prefix_lib1.dart' and 'pkg/front_end/testcases/duplicated_bad_prefix_lib2.dart'.
 // import 'duplicated_bad_prefix_lib2.dart' as dupe;
-// ^
+//                                             ^
 
 library;
 import self as self;
@@ -24,6 +24,8 @@
     ;
 }
 class Dupe extends core::Object {
+  synthetic constructor •() → self::Dupe
+    ;
 }
 class C extends core::Object {
   field invalid-type b;
diff --git a/pkg/front_end/testcases/duplicated_bad_prefix.dart.strong.expect b/pkg/front_end/testcases/duplicated_bad_prefix.dart.strong.expect
index 9da6855..a2b97c5 100644
--- a/pkg/front_end/testcases/duplicated_bad_prefix.dart.strong.expect
+++ b/pkg/front_end/testcases/duplicated_bad_prefix.dart.strong.expect
@@ -11,9 +11,9 @@
 //   Dupe.a b;
 //   ^^^^^^
 //
-// pkg/front_end/testcases/duplicated_bad_prefix.dart:6:1: Error: 'C' is imported from both 'pkg/front_end/testcases/duplicated_bad_prefix_lib1.dart' and 'pkg/front_end/testcases/duplicated_bad_prefix_lib2.dart'.
+// pkg/front_end/testcases/duplicated_bad_prefix.dart:6:45: Error: 'C' is imported from both 'pkg/front_end/testcases/duplicated_bad_prefix_lib1.dart' and 'pkg/front_end/testcases/duplicated_bad_prefix_lib2.dart'.
 // import 'duplicated_bad_prefix_lib2.dart' as dupe;
-// ^
+//                                             ^
 //
 // pkg/front_end/testcases/duplicated_bad_prefix.dart:13:3: Error: 'Dupe.a' isn't a type.
 //   Dupe.a b;
@@ -29,9 +29,9 @@
 //   Dupe.a b;
 //   ^^^^^^
 //
-// pkg/front_end/testcases/duplicated_bad_prefix.dart:6:1: Error: 'C' is imported from both 'pkg/front_end/testcases/duplicated_bad_prefix_lib1.dart' and 'pkg/front_end/testcases/duplicated_bad_prefix_lib2.dart'.
+// pkg/front_end/testcases/duplicated_bad_prefix.dart:6:45: Error: 'C' is imported from both 'pkg/front_end/testcases/duplicated_bad_prefix_lib1.dart' and 'pkg/front_end/testcases/duplicated_bad_prefix_lib2.dart'.
 // import 'duplicated_bad_prefix_lib2.dart' as dupe;
-// ^
+//                                             ^
 //
 // pkg/front_end/testcases/duplicated_bad_prefix.dart:13:3: Error: 'Dupe.a' isn't a type.
 //   Dupe.a b;
@@ -47,6 +47,9 @@
     ;
 }
 class Dupe extends core::Object {
+  synthetic constructor •() → self::Dupe
+    : super core::Object::•()
+    ;
 }
 class C extends core::Object {
   field invalid-type b = null;
diff --git a/pkg/front_end/testcases/duplicated_bad_prefix.dart.strong.transformed.expect b/pkg/front_end/testcases/duplicated_bad_prefix.dart.strong.transformed.expect
index b6f3b03..ff27603 100644
--- a/pkg/front_end/testcases/duplicated_bad_prefix.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/duplicated_bad_prefix.dart.strong.transformed.expect
@@ -8,9 +8,9 @@
 //   Dupe.a b;
 //   ^^^^^^
 //
-// pkg/front_end/testcases/duplicated_bad_prefix.dart:6:1: Error: 'C' is imported from both 'pkg/front_end/testcases/duplicated_bad_prefix_lib1.dart' and 'pkg/front_end/testcases/duplicated_bad_prefix_lib2.dart'.
+// pkg/front_end/testcases/duplicated_bad_prefix.dart:6:45: Error: 'C' is imported from both 'pkg/front_end/testcases/duplicated_bad_prefix_lib1.dart' and 'pkg/front_end/testcases/duplicated_bad_prefix_lib2.dart'.
 // import 'duplicated_bad_prefix_lib2.dart' as dupe;
-// ^
+//                                             ^
 //
 // pkg/front_end/testcases/duplicated_bad_prefix.dart:13:3: Error: 'Dupe.a' isn't a type.
 //   Dupe.a b;
@@ -26,6 +26,9 @@
     ;
 }
 class Dupe extends core::Object {
+  synthetic constructor •() → self::Dupe
+    : super core::Object::•()
+    ;
 }
 class C extends core::Object {
   field invalid-type b = null;
diff --git a/pkg/front_end/testcases/duplicated_declarations.dart b/pkg/front_end/testcases/duplicated_declarations.dart
index d971623..b0d3787 100644
--- a/pkg/front_end/testcases/duplicated_declarations.dart
+++ b/pkg/front_end/testcases/duplicated_declarations.dart
@@ -2,10 +2,18 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
+part "duplicated_declarations_part.dart";
+
+import 'duplicated_declarations_lib.dart' as Typedef;
+
+import 'duplicated_declarations_lib.dart' as Typedef;
+
 typedef Typedef = void Function();
 
 typedef Typedef = Object Function();
 
+import 'duplicated_declarations_lib.dart' as Typedef;
+
 typedef void OldTypedef();
 
 typedef Object OldTypedef();
diff --git a/pkg/front_end/testcases/duplicated_declarations.dart.legacy.expect b/pkg/front_end/testcases/duplicated_declarations.dart.legacy.expect
index bdfb562..6436332 100644
--- a/pkg/front_end/testcases/duplicated_declarations.dart.legacy.expect
+++ b/pkg/front_end/testcases/duplicated_declarations.dart.legacy.expect
@@ -1,226 +1,540 @@
 // Formatted problems:
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:7:9: Error: 'Typedef' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:7:1: Error: Import directives must preceed part directives.
+// Try moving the import directives before the part directives.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+// ^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations.dart:9:1: Error: Import directives must preceed part directives.
+// Try moving the import directives before the part directives.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+// ^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations.dart:13:9: Error: 'Typedef' is already declared in this scope.
 // typedef Typedef = Object Function();
 //         ^^^^^^^
-// pkg/front_end/testcases/duplicated_declarations.dart:5:9: Context: Previous declaration of 'Typedef'.
+// pkg/front_end/testcases/duplicated_declarations.dart:11:9: Context: Previous declaration of 'Typedef'.
 // typedef Typedef = void Function();
 //         ^^^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:11:16: Error: 'OldTypedef' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:15:1: Error: Directives must appear before any declarations.
+// Try moving the directive before any declarations.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+// ^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations.dart:19:16: Error: 'OldTypedef' is already declared in this scope.
 // typedef Object OldTypedef();
 //                ^^^^^^^^^^
-// pkg/front_end/testcases/duplicated_declarations.dart:9:14: Context: Previous declaration of 'OldTypedef'.
+// pkg/front_end/testcases/duplicated_declarations.dart:17:14: Context: Previous declaration of 'OldTypedef'.
 // typedef void OldTypedef();
 //              ^^^^^^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:15:5: Error: 'field' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:23:5: Error: 'field' is already declared in this scope.
 // var field = "2nd";
 //     ^^^^^
-// pkg/front_end/testcases/duplicated_declarations.dart:13:5: Context: Previous declaration of 'field'.
+// pkg/front_end/testcases/duplicated_declarations.dart:21:5: Context: Previous declaration of 'field'.
 // var field = "1st";
 //     ^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:21:1: Error: 'main' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:29:1: Error: 'main' is already declared in this scope.
 // main() {
 // ^^^^
-// pkg/front_end/testcases/duplicated_declarations.dart:17:1: Context: Previous declaration of 'main'.
+// pkg/front_end/testcases/duplicated_declarations.dart:25:1: Context: Previous declaration of 'main'.
 // main() {
 // ^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:33:3: Error: 'C' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:41:3: Error: 'C' is already declared in this scope.
 //   C(a, b);
 //   ^
-// pkg/front_end/testcases/duplicated_declarations.dart:32:3: Context: Previous declaration of 'C'.
+// pkg/front_end/testcases/duplicated_declarations.dart:40:3: Context: Previous declaration of 'C'.
 //   C(a);
 //   ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:36:7: Error: 'field' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:44:7: Error: 'field' is already declared in this scope.
 //   var field = "2nd";
 //       ^^^^^
-// pkg/front_end/testcases/duplicated_declarations.dart:34:7: Context: Previous declaration of 'field'.
+// pkg/front_end/testcases/duplicated_declarations.dart:42:7: Context: Previous declaration of 'field'.
 //   var field = "1st";
 //       ^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:42:3: Error: 'm' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:50:3: Error: 'm' is already declared in this scope.
 //   m() {
 //   ^
-// pkg/front_end/testcases/duplicated_declarations.dart:38:3: Context: Previous declaration of 'm'.
+// pkg/front_end/testcases/duplicated_declarations.dart:46:3: Context: Previous declaration of 'm'.
 //   m() {
 //   ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:50:10: Error: 's' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:58:10: Error: 's' is already declared in this scope.
 //   static s() {
 //          ^
-// pkg/front_end/testcases/duplicated_declarations.dart:46:10: Context: Previous declaration of 's'.
+// pkg/front_end/testcases/duplicated_declarations.dart:54:10: Context: Previous declaration of 's'.
 //   static s() {
 //          ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:62:7: Error: 'C' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:70:7: Error: 'C' is already declared in this scope.
 // class C {
 //       ^
-// pkg/front_end/testcases/duplicated_declarations.dart:31:7: Context: Previous declaration of 'C'.
+// pkg/front_end/testcases/duplicated_declarations.dart:39:7: Context: Previous declaration of 'C'.
 // class C {
 //       ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:67:3: Error: Name of enum constant 'Enum' can't be the same as the enum's own name.
+// pkg/front_end/testcases/duplicated_declarations.dart:75:3: Error: Name of enum constant 'Enum' can't be the same as the enum's own name.
 //   Enum,
 //   ^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:69:3: Error: 'a' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:77:3: Error: 'a' is already declared in this scope.
 //   a,
 //   ^
-// pkg/front_end/testcases/duplicated_declarations.dart:68:3: Context: Previous declaration of 'a'.
+// pkg/front_end/testcases/duplicated_declarations.dart:76:3: Context: Previous declaration of 'a'.
 //   a,
 //   ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:73:6: Error: 'Enum' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:81:6: Error: 'Enum' is already declared in this scope.
 // enum Enum {
 //      ^^^^
-// pkg/front_end/testcases/duplicated_declarations.dart:66:6: Context: Previous declaration of 'Enum'.
+// pkg/front_end/testcases/duplicated_declarations.dart:74:6: Context: Previous declaration of 'Enum'.
 // enum Enum {
 //      ^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:83:3: Error: '_name' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:91:3: Error: '_name' is already declared in this scope.
 //   _name,
 //   ^^^^^
-// pkg/front_end/testcases/duplicated_declarations.dart:79:6: Context: Previous declaration of '_name' is implied by this definition.
+// pkg/front_end/testcases/duplicated_declarations.dart:87:6: Context: Previous declaration of '_name' is implied by this definition.
 // enum AnotherEnum {
 //      ^^^^^^^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:84:3: Error: 'index' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:92:3: Error: 'index' is already declared in this scope.
 //   index,
 //   ^^^^^
-// pkg/front_end/testcases/duplicated_declarations.dart:79:6: Context: Previous declaration of 'index' is implied by this definition.
+// pkg/front_end/testcases/duplicated_declarations.dart:87:6: Context: Previous declaration of 'index' is implied by this definition.
 // enum AnotherEnum {
 //      ^^^^^^^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:85:3: Error: 'toString' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:93:3: Error: 'toString' is already declared in this scope.
 //   toString,
 //   ^^^^^^^^
-// pkg/front_end/testcases/duplicated_declarations.dart:79:6: Context: Previous declaration of 'toString' is implied by this definition.
+// pkg/front_end/testcases/duplicated_declarations.dart:87:6: Context: Previous declaration of 'toString' is implied by this definition.
 // enum AnotherEnum {
 //      ^^^^^^^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:86:3: Error: 'values' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:94:3: Error: 'values' is already declared in this scope.
 //   values,
 //   ^^^^^^
-// pkg/front_end/testcases/duplicated_declarations.dart:79:6: Context: Previous declaration of 'values' is implied by this definition.
+// pkg/front_end/testcases/duplicated_declarations.dart:87:6: Context: Previous declaration of 'values' is implied by this definition.
 // enum AnotherEnum {
 //      ^^^^^^^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:57:19: Error: 'C' isn't a type.
+// pkg/front_end/testcases/duplicated_declarations_part.dart:7:1: Error: The part-of directive must be the only directive in a part.
+// Try removing the other directives, or moving them to the library for which this is a part.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+// ^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:9:1: Error: The part-of directive must be the only directive in a part.
+// Try removing the other directives, or moving them to the library for which this is a part.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+// ^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:13:9: Error: 'Typedef' is already declared in this scope.
+// typedef Typedef = Object Function();
+//         ^^^^^^^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:11:9: Context: Previous declaration of 'Typedef'.
+// typedef Typedef = void Function();
+//         ^^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:15:1: Error: The part-of directive must be the only directive in a part.
+// Try removing the other directives, or moving them to the library for which this is a part.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+// ^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:19:16: Error: 'OldTypedef' is already declared in this scope.
+// typedef Object OldTypedef();
+//                ^^^^^^^^^^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:17:14: Context: Previous declaration of 'OldTypedef'.
+// typedef void OldTypedef();
+//              ^^^^^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:23:5: Error: 'field' is already declared in this scope.
+// var field = 4;
+//     ^^^^^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:21:5: Context: Previous declaration of 'field'.
+// var field = "3rd";
+//     ^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:25:5: Error: 'field' is already declared in this scope.
+// var field = 5.0;
+//     ^^^^^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:23:5: Context: Previous declaration of 'field'.
+// var field = 4;
+//     ^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:31:1: Error: 'main' is already declared in this scope.
+// main() {
+// ^^^^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:27:1: Context: Previous declaration of 'main'.
+// main() {
+// ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:35:1: Error: 'main' is already declared in this scope.
+// main() {
+// ^^^^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:31:1: Context: Previous declaration of 'main'.
+// main() {
+// ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:41:3: Error: 'C' is already declared in this scope.
+//   C(a, b);
+//   ^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:40:3: Context: Previous declaration of 'C'.
+//   C(a);
+//   ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:44:7: Error: 'field' is already declared in this scope.
+//   var field = "2nd";
+//       ^^^^^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:42:7: Context: Previous declaration of 'field'.
+//   var field = "1st";
+//       ^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:50:3: Error: 'm' is already declared in this scope.
+//   m() {
+//   ^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:46:3: Context: Previous declaration of 'm'.
+//   m() {
+//   ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:58:10: Error: 's' is already declared in this scope.
+//   static s() {
+//          ^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:54:10: Context: Previous declaration of 's'.
+//   static s() {
+//          ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:65:7: Error: 'C' is already declared in this scope.
+// class C {
+//       ^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:39:7: Context: Previous declaration of 'C'.
+// class C {
+//       ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:69:7: Error: 'C' is already declared in this scope.
+// class C {
+//       ^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:65:7: Context: Previous declaration of 'C'.
+// class C {
+//       ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:74:3: Error: Name of enum constant 'Enum' can't be the same as the enum's own name.
+//   Enum,
+//   ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:76:3: Error: 'a' is already declared in this scope.
+//   a,
+//   ^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:75:3: Context: Previous declaration of 'a'.
+//   a,
+//   ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:80:6: Error: 'Enum' is already declared in this scope.
+// enum Enum {
+//      ^^^^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:73:6: Context: Previous declaration of 'Enum'.
+// enum Enum {
+//      ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:86:6: Error: 'Enum' is already declared in this scope.
+// enum Enum {
+//      ^^^^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:80:6: Context: Previous declaration of 'Enum'.
+// enum Enum {
+//      ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:11:9: Error: 'Typedef' is already declared in this scope.
+// typedef Typedef = void Function();
+//         ^^^^^^^
+// pkg/front_end/testcases/duplicated_declarations.dart:13:9: Context: Previous declaration of 'Typedef'.
+// typedef Typedef = Object Function();
+//         ^^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:17:14: Error: 'OldTypedef' is already declared in this scope.
+// typedef void OldTypedef();
+//              ^^^^^^^^^^
+// pkg/front_end/testcases/duplicated_declarations.dart:19:16: Context: Previous declaration of 'OldTypedef'.
+// typedef Object OldTypedef();
+//                ^^^^^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:21:5: Error: 'field' is already declared in this scope.
+// var field = "3rd";
+//     ^^^^^
+// pkg/front_end/testcases/duplicated_declarations.dart:23:5: Context: Previous declaration of 'field'.
+// var field = "2nd";
+//     ^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:27:1: Error: 'main' is already declared in this scope.
+// main() {
+// ^^^^
+// pkg/front_end/testcases/duplicated_declarations.dart:29:1: Context: Previous declaration of 'main'.
+// main() {
+// ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:39:7: Error: 'C' is already declared in this scope.
+// class C {
+//       ^
+// pkg/front_end/testcases/duplicated_declarations.dart:70:7: Context: Previous declaration of 'C'.
+// class C {
+//       ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:73:6: Error: 'Enum' is already declared in this scope.
+// enum Enum {
+//      ^^^^
+// pkg/front_end/testcases/duplicated_declarations.dart:81:6: Context: Previous declaration of 'Enum'.
+// enum Enum {
+//      ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations.dart:7:46: Error: 'Typedef' is already declared in this scope.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+//                                              ^^^^^^^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:13:9: Context: Previous declaration of 'Typedef'.
+// typedef Typedef = Object Function();
+//         ^^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations.dart:65:19: Error: 'C' isn't a type.
 // class Sub extends C {
 //                   ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:26:3: Error: Can't use 'main' because it is declared more than once.
+// pkg/front_end/testcases/duplicated_declarations.dart:34:3: Error: Can't use 'main' because it is declared more than once.
 //   main();
 //   ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:27:9: Error: Can't use 'field' because it is declared more than once.
+// pkg/front_end/testcases/duplicated_declarations.dart:35:9: Error: Can't use 'field' because it is declared more than once.
 //   print(field);
 //         ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:28:3: Error: Can't use 'C' because it is declared more than once.
+// pkg/front_end/testcases/duplicated_declarations.dart:36:3: Error: Can't use 'C' because it is declared more than once.
 //   C.s();
 //   ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:54:17: Error: Can't use 's' because it is declared more than once.
+// pkg/front_end/testcases/duplicated_declarations.dart:62:17: Error: Can't use 's' because it is declared more than once.
 //   static f() => s;
 //                 ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:58:16: Warning: Too many positional arguments: 0 allowed, but 1 found.
+// pkg/front_end/testcases/duplicated_declarations.dart:66:16: Warning: Too many positional arguments: 0 allowed, but 1 found.
 // Try removing the extra positional arguments.
 //   Sub() : super(null);
 //                ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:59:16: Warning: Superclass has no method named 'm'.
+// pkg/front_end/testcases/duplicated_declarations.dart:67:16: Warning: Superclass has no method named 'm'.
 //   m() => super.m();
 //                ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:94:38: Error: Can't use '_name' because it is declared more than once.
+// pkg/front_end/testcases/duplicated_declarations.dart:102:38: Error: Can't use '_name' because it is declared more than once.
 //     "AnotherEnum._name": AnotherEnum._name,
 //                                      ^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:95:38: Error: Can't use 'index' because it is declared more than once.
+// pkg/front_end/testcases/duplicated_declarations.dart:103:38: Error: Can't use 'index' because it is declared more than once.
 //     "AnotherEnum.index": AnotherEnum.index,
 //                                      ^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:96:41: Error: Can't use 'toString' because it is declared more than once.
+// pkg/front_end/testcases/duplicated_declarations.dart:104:41: Error: Can't use 'toString' because it is declared more than once.
 //     "AnotherEnum.toString": AnotherEnum.toString,
 //                                         ^^^^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:97:39: Error: Can't use 'values' because it is declared more than once.
+// pkg/front_end/testcases/duplicated_declarations.dart:105:39: Error: Can't use 'values' because it is declared more than once.
 //     "AnotherEnum.values": AnotherEnum.values,
 //                                       ^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:62:17: Error: Can't use 's' because it is declared more than once.
+//   static f() => s;
+//                 ^
 
 // Unhandled errors:
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:7:9: Error: 'Typedef' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:7:1: Error: Import directives must preceed part directives.
+// Try moving the import directives before the part directives.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+// ^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations.dart:9:1: Error: Import directives must preceed part directives.
+// Try moving the import directives before the part directives.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+// ^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations.dart:13:9: Error: 'Typedef' is already declared in this scope.
 // typedef Typedef = Object Function();
 //         ^^^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:11:16: Error: 'OldTypedef' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:15:1: Error: Directives must appear before any declarations.
+// Try moving the directive before any declarations.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+// ^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations.dart:19:16: Error: 'OldTypedef' is already declared in this scope.
 // typedef Object OldTypedef();
 //                ^^^^^^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:15:5: Error: 'field' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:23:5: Error: 'field' is already declared in this scope.
 // var field = "2nd";
 //     ^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:21:1: Error: 'main' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:29:1: Error: 'main' is already declared in this scope.
 // main() {
 // ^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:33:3: Error: 'C' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:41:3: Error: 'C' is already declared in this scope.
 //   C(a, b);
 //   ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:36:7: Error: 'field' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:44:7: Error: 'field' is already declared in this scope.
 //   var field = "2nd";
 //       ^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:42:3: Error: 'm' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:50:3: Error: 'm' is already declared in this scope.
 //   m() {
 //   ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:50:10: Error: 's' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:58:10: Error: 's' is already declared in this scope.
 //   static s() {
 //          ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:62:7: Error: 'C' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:70:7: Error: 'C' is already declared in this scope.
 // class C {
 //       ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:67:3: Error: Name of enum constant 'Enum' can't be the same as the enum's own name.
+// pkg/front_end/testcases/duplicated_declarations.dart:75:3: Error: Name of enum constant 'Enum' can't be the same as the enum's own name.
 //   Enum,
 //   ^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:69:3: Error: 'a' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:77:3: Error: 'a' is already declared in this scope.
 //   a,
 //   ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:73:6: Error: 'Enum' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:81:6: Error: 'Enum' is already declared in this scope.
 // enum Enum {
 //      ^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:83:3: Error: '_name' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:91:3: Error: '_name' is already declared in this scope.
 //   _name,
 //   ^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:84:3: Error: 'index' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:92:3: Error: 'index' is already declared in this scope.
 //   index,
 //   ^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:85:3: Error: 'toString' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:93:3: Error: 'toString' is already declared in this scope.
 //   toString,
 //   ^^^^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:86:3: Error: 'values' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:94:3: Error: 'values' is already declared in this scope.
 //   values,
 //   ^^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:57:19: Error: 'C' isn't a type.
+// pkg/front_end/testcases/duplicated_declarations_part.dart:7:1: Error: The part-of directive must be the only directive in a part.
+// Try removing the other directives, or moving them to the library for which this is a part.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+// ^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:9:1: Error: The part-of directive must be the only directive in a part.
+// Try removing the other directives, or moving them to the library for which this is a part.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+// ^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:13:9: Error: 'Typedef' is already declared in this scope.
+// typedef Typedef = Object Function();
+//         ^^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:15:1: Error: The part-of directive must be the only directive in a part.
+// Try removing the other directives, or moving them to the library for which this is a part.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+// ^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:19:16: Error: 'OldTypedef' is already declared in this scope.
+// typedef Object OldTypedef();
+//                ^^^^^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:23:5: Error: 'field' is already declared in this scope.
+// var field = 4;
+//     ^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:25:5: Error: 'field' is already declared in this scope.
+// var field = 5.0;
+//     ^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:31:1: Error: 'main' is already declared in this scope.
+// main() {
+// ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:35:1: Error: 'main' is already declared in this scope.
+// main() {
+// ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:41:3: Error: 'C' is already declared in this scope.
+//   C(a, b);
+//   ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:44:7: Error: 'field' is already declared in this scope.
+//   var field = "2nd";
+//       ^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:50:3: Error: 'm' is already declared in this scope.
+//   m() {
+//   ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:58:10: Error: 's' is already declared in this scope.
+//   static s() {
+//          ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:65:7: Error: 'C' is already declared in this scope.
+// class C {
+//       ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:69:7: Error: 'C' is already declared in this scope.
+// class C {
+//       ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:74:3: Error: Name of enum constant 'Enum' can't be the same as the enum's own name.
+//   Enum,
+//   ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:76:3: Error: 'a' is already declared in this scope.
+//   a,
+//   ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:80:6: Error: 'Enum' is already declared in this scope.
+// enum Enum {
+//      ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:86:6: Error: 'Enum' is already declared in this scope.
+// enum Enum {
+//      ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:11:9: Error: 'Typedef' is already declared in this scope.
+// typedef Typedef = void Function();
+//         ^^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:17:14: Error: 'OldTypedef' is already declared in this scope.
+// typedef void OldTypedef();
+//              ^^^^^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:21:5: Error: 'field' is already declared in this scope.
+// var field = "3rd";
+//     ^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:27:1: Error: 'main' is already declared in this scope.
+// main() {
+// ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:39:7: Error: 'C' is already declared in this scope.
+// class C {
+//       ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:73:6: Error: 'Enum' is already declared in this scope.
+// enum Enum {
+//      ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations.dart:7:46: Error: 'Typedef' is already declared in this scope.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+//                                              ^^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations.dart:65:19: Error: 'C' isn't a type.
 // class Sub extends C {
 //                   ^
 
@@ -230,13 +544,39 @@
 
 typedef Typedef = () → void;
 typedef OldTypedef = () → void;
+class C#4 extends core::Object { // from org-dartlang-testcase:///duplicated_declarations_part.dart
+  constructor _() → self::C#4
+    : super core::Object::•()
+    ;
+}
+class C#3 extends core::Object { // from org-dartlang-testcase:///duplicated_declarations_part.dart
+  constructor _() → self::C#3
+    : super core::Object::•()
+    ;
+}
+class C#2 extends core::Object { // from org-dartlang-testcase:///duplicated_declarations_part.dart
+  field dynamic field = null;
+  constructor •(dynamic a) → self::C#2
+    : super core::Object::•()
+    ;
+  method m() → dynamic {
+    "1st";
+  }
+  static method s() → dynamic {
+    "1st";
+  }
+  static method f() → dynamic
+    return invalid-expression "pkg/front_end/testcases/duplicated_declarations_part.dart:62:17: Error: Can't use 's' because it is declared more than once.
+  static f() => s;
+                ^";
+}
 class C#1 extends core::Object {
   constructor _() → self::C#1
     : super core::Object::•()
     ;
 }
 class C extends core::Object {
-  field dynamic field;
+  field dynamic field = null;
   constructor •(dynamic a) → self::C
     : super core::Object::•()
     ;
@@ -247,7 +587,7 @@
     "1st";
   }
   static method f() → dynamic
-    return invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:54:17: Error: Can't use 's' because it is declared more than once.
+    return invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:62:17: Error: Can't use 's' because it is declared more than once.
   static f() => s;
                 ^";
 }
@@ -258,6 +598,43 @@
   method m() → dynamic
     return super.m();
 }
+class Enum#4 extends core::Object { // from org-dartlang-testcase:///duplicated_declarations_part.dart
+  final field core::int index;
+  final field core::String _name;
+  static const field core::List<self::Enum#4> values = const <self::Enum#4>[self::Enum#4::a];
+  static const field self::Enum#4 a = const self::Enum#4::•(0, "Enum.a");
+  const constructor •(core::int index, core::String _name) → self::Enum#4
+    : self::Enum#4::index = index, self::Enum#4::_name = _name, super core::Object::•()
+    ;
+  method toString() → core::String
+    return this.{=self::Enum#4::_name};
+}
+class Enum#3 extends core::Object { // from org-dartlang-testcase:///duplicated_declarations_part.dart
+  final field core::int index;
+  final field core::String _name;
+  static const field core::List<self::Enum#3> values = const <self::Enum#3>[self::Enum#3::a, self::Enum#3::b, self::Enum#3::c];
+  static const field self::Enum#3 a = const self::Enum#3::•(0, "Enum.a");
+  static const field self::Enum#3 b = const self::Enum#3::•(1, "Enum.b");
+  static const field self::Enum#3 c = const self::Enum#3::•(2, "Enum.c");
+  const constructor •(core::int index, core::String _name) → self::Enum#3
+    : self::Enum#3::index = index, self::Enum#3::_name = _name, super core::Object::•()
+    ;
+  method toString() → core::String
+    return this.{=self::Enum#3::_name};
+}
+class Enum#2 extends core::Object { // from org-dartlang-testcase:///duplicated_declarations_part.dart
+  final field core::int index;
+  final field core::String _name;
+  static const field core::List<self::Enum#2> values = const <self::Enum#2>[self::Enum#2::Enum, self::Enum#2::a, self::Enum#2::b];
+  static const field self::Enum#2 Enum = const self::Enum#2::•(0, "Enum.Enum");
+  static const field self::Enum#2 a = const self::Enum#2::•(1, "Enum.a");
+  static const field self::Enum#2 b = const self::Enum#2::•(2, "Enum.b");
+  const constructor •(core::int index, core::String _name) → self::Enum#2
+    : self::Enum#2::index = index, self::Enum#2::_name = _name, super core::Object::•()
+    ;
+  method toString() → core::String
+    return this.{=self::Enum#2::_name};
+}
 class Enum#1 extends core::Object {
   final field core::int index;
   final field core::String _name;
@@ -302,24 +679,24 @@
   "1st";
 }
 static method foo() → dynamic {
-  invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:26:3: Error: Can't use 'main' because it is declared more than once.
+  invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:34:3: Error: Can't use 'main' because it is declared more than once.
   main();
   ^".call();
-  core::print(invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:27:9: Error: Can't use 'field' because it is declared more than once.
+  core::print(invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:35:9: Error: Can't use 'field' because it is declared more than once.
   print(field);
         ^");
-  invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:28:3: Error: Can't use 'C' because it is declared more than once.
+  invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:36:3: Error: Can't use 'C' because it is declared more than once.
   C.s();
   ^".s();
 }
 static method useAnotherEnum() → dynamic {
-  <core::String, core::Object>{"AnotherEnum.a": self::AnotherEnum::a, "AnotherEnum.b": self::AnotherEnum::b, "AnotherEnum.c": self::AnotherEnum::c, "AnotherEnum._name": invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:94:38: Error: Can't use '_name' because it is declared more than once.
+  <core::String, core::Object>{"AnotherEnum.a": self::AnotherEnum::a, "AnotherEnum.b": self::AnotherEnum::b, "AnotherEnum.c": self::AnotherEnum::c, "AnotherEnum._name": invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:102:38: Error: Can't use '_name' because it is declared more than once.
     \"AnotherEnum._name\": AnotherEnum._name,
-                                     ^^^^^", "AnotherEnum.index": invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:95:38: Error: Can't use 'index' because it is declared more than once.
+                                     ^^^^^", "AnotherEnum.index": invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:103:38: Error: Can't use 'index' because it is declared more than once.
     \"AnotherEnum.index\": AnotherEnum.index,
-                                     ^^^^^", "AnotherEnum.toString": invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:96:41: Error: Can't use 'toString' because it is declared more than once.
+                                     ^^^^^", "AnotherEnum.toString": invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:104:41: Error: Can't use 'toString' because it is declared more than once.
     \"AnotherEnum.toString\": AnotherEnum.toString,
-                                        ^^^^^^^^", "AnotherEnum.values": invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:97:39: Error: Can't use 'values' because it is declared more than once.
+                                        ^^^^^^^^", "AnotherEnum.values": invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:105:39: Error: Can't use 'values' because it is declared more than once.
     \"AnotherEnum.values\": AnotherEnum.values,
                                       ^^^^^^"};
 }
diff --git a/pkg/front_end/testcases/duplicated_declarations.dart.legacy.transformed.expect b/pkg/front_end/testcases/duplicated_declarations.dart.legacy.transformed.expect
index 9782b0f..d522e1e 100644
--- a/pkg/front_end/testcases/duplicated_declarations.dart.legacy.transformed.expect
+++ b/pkg/front_end/testcases/duplicated_declarations.dart.legacy.transformed.expect
@@ -1,70 +1,192 @@
 // Unhandled errors:
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:7:9: Error: 'Typedef' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:7:1: Error: Import directives must preceed part directives.
+// Try moving the import directives before the part directives.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+// ^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations.dart:9:1: Error: Import directives must preceed part directives.
+// Try moving the import directives before the part directives.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+// ^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations.dart:13:9: Error: 'Typedef' is already declared in this scope.
 // typedef Typedef = Object Function();
 //         ^^^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:11:16: Error: 'OldTypedef' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:15:1: Error: Directives must appear before any declarations.
+// Try moving the directive before any declarations.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+// ^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations.dart:19:16: Error: 'OldTypedef' is already declared in this scope.
 // typedef Object OldTypedef();
 //                ^^^^^^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:15:5: Error: 'field' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:23:5: Error: 'field' is already declared in this scope.
 // var field = "2nd";
 //     ^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:21:1: Error: 'main' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:29:1: Error: 'main' is already declared in this scope.
 // main() {
 // ^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:33:3: Error: 'C' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:41:3: Error: 'C' is already declared in this scope.
 //   C(a, b);
 //   ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:36:7: Error: 'field' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:44:7: Error: 'field' is already declared in this scope.
 //   var field = "2nd";
 //       ^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:42:3: Error: 'm' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:50:3: Error: 'm' is already declared in this scope.
 //   m() {
 //   ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:50:10: Error: 's' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:58:10: Error: 's' is already declared in this scope.
 //   static s() {
 //          ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:62:7: Error: 'C' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:70:7: Error: 'C' is already declared in this scope.
 // class C {
 //       ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:67:3: Error: Name of enum constant 'Enum' can't be the same as the enum's own name.
+// pkg/front_end/testcases/duplicated_declarations.dart:75:3: Error: Name of enum constant 'Enum' can't be the same as the enum's own name.
 //   Enum,
 //   ^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:69:3: Error: 'a' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:77:3: Error: 'a' is already declared in this scope.
 //   a,
 //   ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:73:6: Error: 'Enum' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:81:6: Error: 'Enum' is already declared in this scope.
 // enum Enum {
 //      ^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:83:3: Error: '_name' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:91:3: Error: '_name' is already declared in this scope.
 //   _name,
 //   ^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:84:3: Error: 'index' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:92:3: Error: 'index' is already declared in this scope.
 //   index,
 //   ^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:85:3: Error: 'toString' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:93:3: Error: 'toString' is already declared in this scope.
 //   toString,
 //   ^^^^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:86:3: Error: 'values' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:94:3: Error: 'values' is already declared in this scope.
 //   values,
 //   ^^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:57:19: Error: 'C' isn't a type.
+// pkg/front_end/testcases/duplicated_declarations_part.dart:7:1: Error: The part-of directive must be the only directive in a part.
+// Try removing the other directives, or moving them to the library for which this is a part.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+// ^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:9:1: Error: The part-of directive must be the only directive in a part.
+// Try removing the other directives, or moving them to the library for which this is a part.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+// ^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:13:9: Error: 'Typedef' is already declared in this scope.
+// typedef Typedef = Object Function();
+//         ^^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:15:1: Error: The part-of directive must be the only directive in a part.
+// Try removing the other directives, or moving them to the library for which this is a part.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+// ^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:19:16: Error: 'OldTypedef' is already declared in this scope.
+// typedef Object OldTypedef();
+//                ^^^^^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:23:5: Error: 'field' is already declared in this scope.
+// var field = 4;
+//     ^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:25:5: Error: 'field' is already declared in this scope.
+// var field = 5.0;
+//     ^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:31:1: Error: 'main' is already declared in this scope.
+// main() {
+// ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:35:1: Error: 'main' is already declared in this scope.
+// main() {
+// ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:41:3: Error: 'C' is already declared in this scope.
+//   C(a, b);
+//   ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:44:7: Error: 'field' is already declared in this scope.
+//   var field = "2nd";
+//       ^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:50:3: Error: 'm' is already declared in this scope.
+//   m() {
+//   ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:58:10: Error: 's' is already declared in this scope.
+//   static s() {
+//          ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:65:7: Error: 'C' is already declared in this scope.
+// class C {
+//       ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:69:7: Error: 'C' is already declared in this scope.
+// class C {
+//       ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:74:3: Error: Name of enum constant 'Enum' can't be the same as the enum's own name.
+//   Enum,
+//   ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:76:3: Error: 'a' is already declared in this scope.
+//   a,
+//   ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:80:6: Error: 'Enum' is already declared in this scope.
+// enum Enum {
+//      ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:86:6: Error: 'Enum' is already declared in this scope.
+// enum Enum {
+//      ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:11:9: Error: 'Typedef' is already declared in this scope.
+// typedef Typedef = void Function();
+//         ^^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:17:14: Error: 'OldTypedef' is already declared in this scope.
+// typedef void OldTypedef();
+//              ^^^^^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:21:5: Error: 'field' is already declared in this scope.
+// var field = "3rd";
+//     ^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:27:1: Error: 'main' is already declared in this scope.
+// main() {
+// ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:39:7: Error: 'C' is already declared in this scope.
+// class C {
+//       ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:73:6: Error: 'Enum' is already declared in this scope.
+// enum Enum {
+//      ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations.dart:7:46: Error: 'Typedef' is already declared in this scope.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+//                                              ^^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations.dart:65:19: Error: 'C' isn't a type.
 // class Sub extends C {
 //                   ^
 
@@ -74,13 +196,39 @@
 
 typedef Typedef = () → void;
 typedef OldTypedef = () → void;
+class C#4 extends core::Object { // from org-dartlang-testcase:///duplicated_declarations_part.dart
+  constructor _() → self::C#4
+    : super core::Object::•()
+    ;
+}
+class C#3 extends core::Object { // from org-dartlang-testcase:///duplicated_declarations_part.dart
+  constructor _() → self::C#3
+    : super core::Object::•()
+    ;
+}
+class C#2 extends core::Object { // from org-dartlang-testcase:///duplicated_declarations_part.dart
+  field dynamic field = null;
+  constructor •(dynamic a) → self::C#2
+    : super core::Object::•()
+    ;
+  method m() → dynamic {
+    "1st";
+  }
+  static method s() → dynamic {
+    "1st";
+  }
+  static method f() → dynamic
+    return invalid-expression "pkg/front_end/testcases/duplicated_declarations_part.dart:62:17: Error: Can't use 's' because it is declared more than once.
+  static f() => s;
+                ^";
+}
 class C#1 extends core::Object {
   constructor _() → self::C#1
     : super core::Object::•()
     ;
 }
 class C extends core::Object {
-  field dynamic field;
+  field dynamic field = null;
   constructor •(dynamic a) → self::C
     : super core::Object::•()
     ;
@@ -91,7 +239,7 @@
     "1st";
   }
   static method f() → dynamic
-    return invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:54:17: Error: Can't use 's' because it is declared more than once.
+    return invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:62:17: Error: Can't use 's' because it is declared more than once.
   static f() => s;
                 ^";
 }
@@ -102,6 +250,43 @@
   method m() → dynamic
     return super.m();
 }
+class Enum#4 extends core::Object { // from org-dartlang-testcase:///duplicated_declarations_part.dart
+  final field core::int index;
+  final field core::String _name;
+  static const field core::List<self::Enum#4> values = const <self::Enum#4>[self::Enum#4::a];
+  static const field self::Enum#4 a = const self::Enum#4::•(0, "Enum.a");
+  const constructor •(core::int index, core::String _name) → self::Enum#4
+    : self::Enum#4::index = index, self::Enum#4::_name = _name, super core::Object::•()
+    ;
+  method toString() → core::String
+    return this.{=self::Enum#4::_name};
+}
+class Enum#3 extends core::Object { // from org-dartlang-testcase:///duplicated_declarations_part.dart
+  final field core::int index;
+  final field core::String _name;
+  static const field core::List<self::Enum#3> values = const <self::Enum#3>[self::Enum#3::a, self::Enum#3::b, self::Enum#3::c];
+  static const field self::Enum#3 a = const self::Enum#3::•(0, "Enum.a");
+  static const field self::Enum#3 b = const self::Enum#3::•(1, "Enum.b");
+  static const field self::Enum#3 c = const self::Enum#3::•(2, "Enum.c");
+  const constructor •(core::int index, core::String _name) → self::Enum#3
+    : self::Enum#3::index = index, self::Enum#3::_name = _name, super core::Object::•()
+    ;
+  method toString() → core::String
+    return this.{=self::Enum#3::_name};
+}
+class Enum#2 extends core::Object { // from org-dartlang-testcase:///duplicated_declarations_part.dart
+  final field core::int index;
+  final field core::String _name;
+  static const field core::List<self::Enum#2> values = const <self::Enum#2>[self::Enum#2::Enum, self::Enum#2::a, self::Enum#2::b];
+  static const field self::Enum#2 Enum = const self::Enum#2::•(0, "Enum.Enum");
+  static const field self::Enum#2 a = const self::Enum#2::•(1, "Enum.a");
+  static const field self::Enum#2 b = const self::Enum#2::•(2, "Enum.b");
+  const constructor •(core::int index, core::String _name) → self::Enum#2
+    : self::Enum#2::index = index, self::Enum#2::_name = _name, super core::Object::•()
+    ;
+  method toString() → core::String
+    return this.{=self::Enum#2::_name};
+}
 class Enum#1 extends core::Object {
   final field core::int index;
   final field core::String _name;
@@ -146,24 +331,24 @@
   "1st";
 }
 static method foo() → dynamic {
-  invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:26:3: Error: Can't use 'main' because it is declared more than once.
+  invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:34:3: Error: Can't use 'main' because it is declared more than once.
   main();
   ^".call();
-  core::print(invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:27:9: Error: Can't use 'field' because it is declared more than once.
+  core::print(invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:35:9: Error: Can't use 'field' because it is declared more than once.
   print(field);
         ^");
-  invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:28:3: Error: Can't use 'C' because it is declared more than once.
+  invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:36:3: Error: Can't use 'C' because it is declared more than once.
   C.s();
   ^".s();
 }
 static method useAnotherEnum() → dynamic {
-  <core::String, core::Object>{"AnotherEnum.a": self::AnotherEnum::a, "AnotherEnum.b": self::AnotherEnum::b, "AnotherEnum.c": self::AnotherEnum::c, "AnotherEnum._name": invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:94:38: Error: Can't use '_name' because it is declared more than once.
+  <core::String, core::Object>{"AnotherEnum.a": self::AnotherEnum::a, "AnotherEnum.b": self::AnotherEnum::b, "AnotherEnum.c": self::AnotherEnum::c, "AnotherEnum._name": invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:102:38: Error: Can't use '_name' because it is declared more than once.
     \"AnotherEnum._name\": AnotherEnum._name,
-                                     ^^^^^", "AnotherEnum.index": invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:95:38: Error: Can't use 'index' because it is declared more than once.
+                                     ^^^^^", "AnotherEnum.index": invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:103:38: Error: Can't use 'index' because it is declared more than once.
     \"AnotherEnum.index\": AnotherEnum.index,
-                                     ^^^^^", "AnotherEnum.toString": invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:96:41: Error: Can't use 'toString' because it is declared more than once.
+                                     ^^^^^", "AnotherEnum.toString": invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:104:41: Error: Can't use 'toString' because it is declared more than once.
     \"AnotherEnum.toString\": AnotherEnum.toString,
-                                        ^^^^^^^^", "AnotherEnum.values": invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:97:39: Error: Can't use 'values' because it is declared more than once.
+                                        ^^^^^^^^", "AnotherEnum.values": invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:105:39: Error: Can't use 'values' because it is declared more than once.
     \"AnotherEnum.values\": AnotherEnum.values,
                                       ^^^^^^"};
 }
diff --git a/pkg/front_end/testcases/duplicated_declarations.dart.outline.expect b/pkg/front_end/testcases/duplicated_declarations.dart.outline.expect
index b143219..4aebbb6 100644
--- a/pkg/front_end/testcases/duplicated_declarations.dart.outline.expect
+++ b/pkg/front_end/testcases/duplicated_declarations.dart.outline.expect
@@ -1,115 +1,303 @@
 // Formatted problems:
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:7:9: Error: 'Typedef' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:7:1: Error: Import directives must preceed part directives.
+// Try moving the import directives before the part directives.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+// ^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations.dart:9:1: Error: Import directives must preceed part directives.
+// Try moving the import directives before the part directives.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+// ^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations.dart:13:9: Error: 'Typedef' is already declared in this scope.
 // typedef Typedef = Object Function();
 //         ^^^^^^^
-// pkg/front_end/testcases/duplicated_declarations.dart:5:9: Context: Previous declaration of 'Typedef'.
+// pkg/front_end/testcases/duplicated_declarations.dart:11:9: Context: Previous declaration of 'Typedef'.
 // typedef Typedef = void Function();
 //         ^^^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:11:16: Error: 'OldTypedef' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:15:1: Error: Directives must appear before any declarations.
+// Try moving the directive before any declarations.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+// ^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations.dart:19:16: Error: 'OldTypedef' is already declared in this scope.
 // typedef Object OldTypedef();
 //                ^^^^^^^^^^
-// pkg/front_end/testcases/duplicated_declarations.dart:9:14: Context: Previous declaration of 'OldTypedef'.
+// pkg/front_end/testcases/duplicated_declarations.dart:17:14: Context: Previous declaration of 'OldTypedef'.
 // typedef void OldTypedef();
 //              ^^^^^^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:15:5: Error: 'field' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:23:5: Error: 'field' is already declared in this scope.
 // var field = "2nd";
 //     ^^^^^
-// pkg/front_end/testcases/duplicated_declarations.dart:13:5: Context: Previous declaration of 'field'.
+// pkg/front_end/testcases/duplicated_declarations.dart:21:5: Context: Previous declaration of 'field'.
 // var field = "1st";
 //     ^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:21:1: Error: 'main' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:29:1: Error: 'main' is already declared in this scope.
 // main() {
 // ^^^^
-// pkg/front_end/testcases/duplicated_declarations.dart:17:1: Context: Previous declaration of 'main'.
+// pkg/front_end/testcases/duplicated_declarations.dart:25:1: Context: Previous declaration of 'main'.
 // main() {
 // ^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:33:3: Error: 'C' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:41:3: Error: 'C' is already declared in this scope.
 //   C(a, b);
 //   ^
-// pkg/front_end/testcases/duplicated_declarations.dart:32:3: Context: Previous declaration of 'C'.
+// pkg/front_end/testcases/duplicated_declarations.dart:40:3: Context: Previous declaration of 'C'.
 //   C(a);
 //   ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:36:7: Error: 'field' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:44:7: Error: 'field' is already declared in this scope.
 //   var field = "2nd";
 //       ^^^^^
-// pkg/front_end/testcases/duplicated_declarations.dart:34:7: Context: Previous declaration of 'field'.
+// pkg/front_end/testcases/duplicated_declarations.dart:42:7: Context: Previous declaration of 'field'.
 //   var field = "1st";
 //       ^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:42:3: Error: 'm' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:50:3: Error: 'm' is already declared in this scope.
 //   m() {
 //   ^
-// pkg/front_end/testcases/duplicated_declarations.dart:38:3: Context: Previous declaration of 'm'.
+// pkg/front_end/testcases/duplicated_declarations.dart:46:3: Context: Previous declaration of 'm'.
 //   m() {
 //   ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:50:10: Error: 's' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:58:10: Error: 's' is already declared in this scope.
 //   static s() {
 //          ^
-// pkg/front_end/testcases/duplicated_declarations.dart:46:10: Context: Previous declaration of 's'.
+// pkg/front_end/testcases/duplicated_declarations.dart:54:10: Context: Previous declaration of 's'.
 //   static s() {
 //          ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:62:7: Error: 'C' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:70:7: Error: 'C' is already declared in this scope.
 // class C {
 //       ^
-// pkg/front_end/testcases/duplicated_declarations.dart:31:7: Context: Previous declaration of 'C'.
+// pkg/front_end/testcases/duplicated_declarations.dart:39:7: Context: Previous declaration of 'C'.
 // class C {
 //       ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:67:3: Error: Name of enum constant 'Enum' can't be the same as the enum's own name.
+// pkg/front_end/testcases/duplicated_declarations.dart:75:3: Error: Name of enum constant 'Enum' can't be the same as the enum's own name.
 //   Enum,
 //   ^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:69:3: Error: 'a' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:77:3: Error: 'a' is already declared in this scope.
 //   a,
 //   ^
-// pkg/front_end/testcases/duplicated_declarations.dart:68:3: Context: Previous declaration of 'a'.
+// pkg/front_end/testcases/duplicated_declarations.dart:76:3: Context: Previous declaration of 'a'.
 //   a,
 //   ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:73:6: Error: 'Enum' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:81:6: Error: 'Enum' is already declared in this scope.
 // enum Enum {
 //      ^^^^
-// pkg/front_end/testcases/duplicated_declarations.dart:66:6: Context: Previous declaration of 'Enum'.
+// pkg/front_end/testcases/duplicated_declarations.dart:74:6: Context: Previous declaration of 'Enum'.
 // enum Enum {
 //      ^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:83:3: Error: '_name' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:91:3: Error: '_name' is already declared in this scope.
 //   _name,
 //   ^^^^^
-// pkg/front_end/testcases/duplicated_declarations.dart:79:6: Context: Previous declaration of '_name' is implied by this definition.
+// pkg/front_end/testcases/duplicated_declarations.dart:87:6: Context: Previous declaration of '_name' is implied by this definition.
 // enum AnotherEnum {
 //      ^^^^^^^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:84:3: Error: 'index' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:92:3: Error: 'index' is already declared in this scope.
 //   index,
 //   ^^^^^
-// pkg/front_end/testcases/duplicated_declarations.dart:79:6: Context: Previous declaration of 'index' is implied by this definition.
+// pkg/front_end/testcases/duplicated_declarations.dart:87:6: Context: Previous declaration of 'index' is implied by this definition.
 // enum AnotherEnum {
 //      ^^^^^^^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:85:3: Error: 'toString' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:93:3: Error: 'toString' is already declared in this scope.
 //   toString,
 //   ^^^^^^^^
-// pkg/front_end/testcases/duplicated_declarations.dart:79:6: Context: Previous declaration of 'toString' is implied by this definition.
+// pkg/front_end/testcases/duplicated_declarations.dart:87:6: Context: Previous declaration of 'toString' is implied by this definition.
 // enum AnotherEnum {
 //      ^^^^^^^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:86:3: Error: 'values' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:94:3: Error: 'values' is already declared in this scope.
 //   values,
 //   ^^^^^^
-// pkg/front_end/testcases/duplicated_declarations.dart:79:6: Context: Previous declaration of 'values' is implied by this definition.
+// pkg/front_end/testcases/duplicated_declarations.dart:87:6: Context: Previous declaration of 'values' is implied by this definition.
 // enum AnotherEnum {
 //      ^^^^^^^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:57:19: Error: 'C' isn't a type.
+// pkg/front_end/testcases/duplicated_declarations_part.dart:7:1: Error: The part-of directive must be the only directive in a part.
+// Try removing the other directives, or moving them to the library for which this is a part.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+// ^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:9:1: Error: The part-of directive must be the only directive in a part.
+// Try removing the other directives, or moving them to the library for which this is a part.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+// ^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:13:9: Error: 'Typedef' is already declared in this scope.
+// typedef Typedef = Object Function();
+//         ^^^^^^^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:11:9: Context: Previous declaration of 'Typedef'.
+// typedef Typedef = void Function();
+//         ^^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:15:1: Error: The part-of directive must be the only directive in a part.
+// Try removing the other directives, or moving them to the library for which this is a part.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+// ^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:19:16: Error: 'OldTypedef' is already declared in this scope.
+// typedef Object OldTypedef();
+//                ^^^^^^^^^^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:17:14: Context: Previous declaration of 'OldTypedef'.
+// typedef void OldTypedef();
+//              ^^^^^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:23:5: Error: 'field' is already declared in this scope.
+// var field = 4;
+//     ^^^^^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:21:5: Context: Previous declaration of 'field'.
+// var field = "3rd";
+//     ^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:25:5: Error: 'field' is already declared in this scope.
+// var field = 5.0;
+//     ^^^^^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:23:5: Context: Previous declaration of 'field'.
+// var field = 4;
+//     ^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:31:1: Error: 'main' is already declared in this scope.
+// main() {
+// ^^^^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:27:1: Context: Previous declaration of 'main'.
+// main() {
+// ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:35:1: Error: 'main' is already declared in this scope.
+// main() {
+// ^^^^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:31:1: Context: Previous declaration of 'main'.
+// main() {
+// ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:41:3: Error: 'C' is already declared in this scope.
+//   C(a, b);
+//   ^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:40:3: Context: Previous declaration of 'C'.
+//   C(a);
+//   ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:44:7: Error: 'field' is already declared in this scope.
+//   var field = "2nd";
+//       ^^^^^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:42:7: Context: Previous declaration of 'field'.
+//   var field = "1st";
+//       ^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:50:3: Error: 'm' is already declared in this scope.
+//   m() {
+//   ^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:46:3: Context: Previous declaration of 'm'.
+//   m() {
+//   ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:58:10: Error: 's' is already declared in this scope.
+//   static s() {
+//          ^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:54:10: Context: Previous declaration of 's'.
+//   static s() {
+//          ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:65:7: Error: 'C' is already declared in this scope.
+// class C {
+//       ^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:39:7: Context: Previous declaration of 'C'.
+// class C {
+//       ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:69:7: Error: 'C' is already declared in this scope.
+// class C {
+//       ^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:65:7: Context: Previous declaration of 'C'.
+// class C {
+//       ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:74:3: Error: Name of enum constant 'Enum' can't be the same as the enum's own name.
+//   Enum,
+//   ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:76:3: Error: 'a' is already declared in this scope.
+//   a,
+//   ^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:75:3: Context: Previous declaration of 'a'.
+//   a,
+//   ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:80:6: Error: 'Enum' is already declared in this scope.
+// enum Enum {
+//      ^^^^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:73:6: Context: Previous declaration of 'Enum'.
+// enum Enum {
+//      ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:86:6: Error: 'Enum' is already declared in this scope.
+// enum Enum {
+//      ^^^^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:80:6: Context: Previous declaration of 'Enum'.
+// enum Enum {
+//      ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:11:9: Error: 'Typedef' is already declared in this scope.
+// typedef Typedef = void Function();
+//         ^^^^^^^
+// pkg/front_end/testcases/duplicated_declarations.dart:13:9: Context: Previous declaration of 'Typedef'.
+// typedef Typedef = Object Function();
+//         ^^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:17:14: Error: 'OldTypedef' is already declared in this scope.
+// typedef void OldTypedef();
+//              ^^^^^^^^^^
+// pkg/front_end/testcases/duplicated_declarations.dart:19:16: Context: Previous declaration of 'OldTypedef'.
+// typedef Object OldTypedef();
+//                ^^^^^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:21:5: Error: 'field' is already declared in this scope.
+// var field = "3rd";
+//     ^^^^^
+// pkg/front_end/testcases/duplicated_declarations.dart:23:5: Context: Previous declaration of 'field'.
+// var field = "2nd";
+//     ^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:27:1: Error: 'main' is already declared in this scope.
+// main() {
+// ^^^^
+// pkg/front_end/testcases/duplicated_declarations.dart:29:1: Context: Previous declaration of 'main'.
+// main() {
+// ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:39:7: Error: 'C' is already declared in this scope.
+// class C {
+//       ^
+// pkg/front_end/testcases/duplicated_declarations.dart:70:7: Context: Previous declaration of 'C'.
+// class C {
+//       ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:73:6: Error: 'Enum' is already declared in this scope.
+// enum Enum {
+//      ^^^^
+// pkg/front_end/testcases/duplicated_declarations.dart:81:6: Context: Previous declaration of 'Enum'.
+// enum Enum {
+//      ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations.dart:7:46: Error: 'Typedef' is already declared in this scope.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+//                                              ^^^^^^^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:13:9: Context: Previous declaration of 'Typedef'.
+// typedef Typedef = Object Function();
+//         ^^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations.dart:65:19: Error: 'C' isn't a type.
 // class Sub extends C {
 //                   ^
 
@@ -119,6 +307,25 @@
 
 typedef Typedef = () → void;
 typedef OldTypedef = () → void;
+class C#4 extends core::Object { // from org-dartlang-testcase:///duplicated_declarations_part.dart
+  constructor _() → self::C#4
+    ;
+}
+class C#3 extends core::Object { // from org-dartlang-testcase:///duplicated_declarations_part.dart
+  constructor _() → self::C#3
+    ;
+}
+class C#2 extends core::Object { // from org-dartlang-testcase:///duplicated_declarations_part.dart
+  field dynamic field;
+  constructor •(dynamic a) → self::C#2
+    ;
+  method m() → dynamic
+    ;
+  static method s() → dynamic
+    ;
+  static method f() → dynamic
+    ;
+}
 class C#1 extends core::Object {
   constructor _() → self::C#1
     ;
@@ -140,6 +347,43 @@
   method m() → dynamic
     ;
 }
+class Enum#4 extends core::Object { // from org-dartlang-testcase:///duplicated_declarations_part.dart
+  final field core::int index;
+  final field core::String _name;
+  static const field core::List<self::Enum#4> values = const <self::Enum#4>[self::Enum#4::a];
+  static const field self::Enum#4 a = const self::Enum#4::•(0, "Enum.a");
+  const constructor •(core::int index, core::String _name) → self::Enum#4
+    : self::Enum#4::index = index, self::Enum#4::_name = _name, super core::Object::•()
+    ;
+  method toString() → core::String
+    return this.{=self::Enum#4::_name};
+}
+class Enum#3 extends core::Object { // from org-dartlang-testcase:///duplicated_declarations_part.dart
+  final field core::int index;
+  final field core::String _name;
+  static const field core::List<self::Enum#3> values = const <self::Enum#3>[self::Enum#3::a, self::Enum#3::b, self::Enum#3::c];
+  static const field self::Enum#3 a = const self::Enum#3::•(0, "Enum.a");
+  static const field self::Enum#3 b = const self::Enum#3::•(1, "Enum.b");
+  static const field self::Enum#3 c = const self::Enum#3::•(2, "Enum.c");
+  const constructor •(core::int index, core::String _name) → self::Enum#3
+    : self::Enum#3::index = index, self::Enum#3::_name = _name, super core::Object::•()
+    ;
+  method toString() → core::String
+    return this.{=self::Enum#3::_name};
+}
+class Enum#2 extends core::Object { // from org-dartlang-testcase:///duplicated_declarations_part.dart
+  final field core::int index;
+  final field core::String _name;
+  static const field core::List<self::Enum#2> values = const <self::Enum#2>[self::Enum#2::Enum, self::Enum#2::a, self::Enum#2::b];
+  static const field self::Enum#2 Enum = const self::Enum#2::•(0, "Enum.Enum");
+  static const field self::Enum#2 a = const self::Enum#2::•(1, "Enum.a");
+  static const field self::Enum#2 b = const self::Enum#2::•(2, "Enum.b");
+  const constructor •(core::int index, core::String _name) → self::Enum#2
+    : self::Enum#2::index = index, self::Enum#2::_name = _name, super core::Object::•()
+    ;
+  method toString() → core::String
+    return this.{=self::Enum#2::_name};
+}
 class Enum#1 extends core::Object {
   final field core::int index;
   final field core::String _name;
diff --git a/pkg/front_end/testcases/duplicated_declarations.dart.strong.expect b/pkg/front_end/testcases/duplicated_declarations.dart.strong.expect
index 0efb977..2805d79 100644
--- a/pkg/front_end/testcases/duplicated_declarations.dart.strong.expect
+++ b/pkg/front_end/testcases/duplicated_declarations.dart.strong.expect
@@ -1,230 +1,544 @@
 // Formatted problems:
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:7:9: Error: 'Typedef' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:7:1: Error: Import directives must preceed part directives.
+// Try moving the import directives before the part directives.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+// ^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations.dart:9:1: Error: Import directives must preceed part directives.
+// Try moving the import directives before the part directives.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+// ^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations.dart:13:9: Error: 'Typedef' is already declared in this scope.
 // typedef Typedef = Object Function();
 //         ^^^^^^^
-// pkg/front_end/testcases/duplicated_declarations.dart:5:9: Context: Previous declaration of 'Typedef'.
+// pkg/front_end/testcases/duplicated_declarations.dart:11:9: Context: Previous declaration of 'Typedef'.
 // typedef Typedef = void Function();
 //         ^^^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:11:16: Error: 'OldTypedef' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:15:1: Error: Directives must appear before any declarations.
+// Try moving the directive before any declarations.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+// ^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations.dart:19:16: Error: 'OldTypedef' is already declared in this scope.
 // typedef Object OldTypedef();
 //                ^^^^^^^^^^
-// pkg/front_end/testcases/duplicated_declarations.dart:9:14: Context: Previous declaration of 'OldTypedef'.
+// pkg/front_end/testcases/duplicated_declarations.dart:17:14: Context: Previous declaration of 'OldTypedef'.
 // typedef void OldTypedef();
 //              ^^^^^^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:15:5: Error: 'field' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:23:5: Error: 'field' is already declared in this scope.
 // var field = "2nd";
 //     ^^^^^
-// pkg/front_end/testcases/duplicated_declarations.dart:13:5: Context: Previous declaration of 'field'.
+// pkg/front_end/testcases/duplicated_declarations.dart:21:5: Context: Previous declaration of 'field'.
 // var field = "1st";
 //     ^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:21:1: Error: 'main' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:29:1: Error: 'main' is already declared in this scope.
 // main() {
 // ^^^^
-// pkg/front_end/testcases/duplicated_declarations.dart:17:1: Context: Previous declaration of 'main'.
+// pkg/front_end/testcases/duplicated_declarations.dart:25:1: Context: Previous declaration of 'main'.
 // main() {
 // ^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:33:3: Error: 'C' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:41:3: Error: 'C' is already declared in this scope.
 //   C(a, b);
 //   ^
-// pkg/front_end/testcases/duplicated_declarations.dart:32:3: Context: Previous declaration of 'C'.
+// pkg/front_end/testcases/duplicated_declarations.dart:40:3: Context: Previous declaration of 'C'.
 //   C(a);
 //   ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:36:7: Error: 'field' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:44:7: Error: 'field' is already declared in this scope.
 //   var field = "2nd";
 //       ^^^^^
-// pkg/front_end/testcases/duplicated_declarations.dart:34:7: Context: Previous declaration of 'field'.
+// pkg/front_end/testcases/duplicated_declarations.dart:42:7: Context: Previous declaration of 'field'.
 //   var field = "1st";
 //       ^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:42:3: Error: 'm' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:50:3: Error: 'm' is already declared in this scope.
 //   m() {
 //   ^
-// pkg/front_end/testcases/duplicated_declarations.dart:38:3: Context: Previous declaration of 'm'.
+// pkg/front_end/testcases/duplicated_declarations.dart:46:3: Context: Previous declaration of 'm'.
 //   m() {
 //   ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:50:10: Error: 's' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:58:10: Error: 's' is already declared in this scope.
 //   static s() {
 //          ^
-// pkg/front_end/testcases/duplicated_declarations.dart:46:10: Context: Previous declaration of 's'.
+// pkg/front_end/testcases/duplicated_declarations.dart:54:10: Context: Previous declaration of 's'.
 //   static s() {
 //          ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:62:7: Error: 'C' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:70:7: Error: 'C' is already declared in this scope.
 // class C {
 //       ^
-// pkg/front_end/testcases/duplicated_declarations.dart:31:7: Context: Previous declaration of 'C'.
+// pkg/front_end/testcases/duplicated_declarations.dart:39:7: Context: Previous declaration of 'C'.
 // class C {
 //       ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:67:3: Error: Name of enum constant 'Enum' can't be the same as the enum's own name.
+// pkg/front_end/testcases/duplicated_declarations.dart:75:3: Error: Name of enum constant 'Enum' can't be the same as the enum's own name.
 //   Enum,
 //   ^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:69:3: Error: 'a' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:77:3: Error: 'a' is already declared in this scope.
 //   a,
 //   ^
-// pkg/front_end/testcases/duplicated_declarations.dart:68:3: Context: Previous declaration of 'a'.
+// pkg/front_end/testcases/duplicated_declarations.dart:76:3: Context: Previous declaration of 'a'.
 //   a,
 //   ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:73:6: Error: 'Enum' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:81:6: Error: 'Enum' is already declared in this scope.
 // enum Enum {
 //      ^^^^
-// pkg/front_end/testcases/duplicated_declarations.dart:66:6: Context: Previous declaration of 'Enum'.
+// pkg/front_end/testcases/duplicated_declarations.dart:74:6: Context: Previous declaration of 'Enum'.
 // enum Enum {
 //      ^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:83:3: Error: '_name' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:91:3: Error: '_name' is already declared in this scope.
 //   _name,
 //   ^^^^^
-// pkg/front_end/testcases/duplicated_declarations.dart:79:6: Context: Previous declaration of '_name' is implied by this definition.
+// pkg/front_end/testcases/duplicated_declarations.dart:87:6: Context: Previous declaration of '_name' is implied by this definition.
 // enum AnotherEnum {
 //      ^^^^^^^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:84:3: Error: 'index' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:92:3: Error: 'index' is already declared in this scope.
 //   index,
 //   ^^^^^
-// pkg/front_end/testcases/duplicated_declarations.dart:79:6: Context: Previous declaration of 'index' is implied by this definition.
+// pkg/front_end/testcases/duplicated_declarations.dart:87:6: Context: Previous declaration of 'index' is implied by this definition.
 // enum AnotherEnum {
 //      ^^^^^^^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:85:3: Error: 'toString' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:93:3: Error: 'toString' is already declared in this scope.
 //   toString,
 //   ^^^^^^^^
-// pkg/front_end/testcases/duplicated_declarations.dart:79:6: Context: Previous declaration of 'toString' is implied by this definition.
+// pkg/front_end/testcases/duplicated_declarations.dart:87:6: Context: Previous declaration of 'toString' is implied by this definition.
 // enum AnotherEnum {
 //      ^^^^^^^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:86:3: Error: 'values' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:94:3: Error: 'values' is already declared in this scope.
 //   values,
 //   ^^^^^^
-// pkg/front_end/testcases/duplicated_declarations.dart:79:6: Context: Previous declaration of 'values' is implied by this definition.
+// pkg/front_end/testcases/duplicated_declarations.dart:87:6: Context: Previous declaration of 'values' is implied by this definition.
 // enum AnotherEnum {
 //      ^^^^^^^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:57:19: Error: 'C' isn't a type.
+// pkg/front_end/testcases/duplicated_declarations_part.dart:7:1: Error: The part-of directive must be the only directive in a part.
+// Try removing the other directives, or moving them to the library for which this is a part.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+// ^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:9:1: Error: The part-of directive must be the only directive in a part.
+// Try removing the other directives, or moving them to the library for which this is a part.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+// ^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:13:9: Error: 'Typedef' is already declared in this scope.
+// typedef Typedef = Object Function();
+//         ^^^^^^^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:11:9: Context: Previous declaration of 'Typedef'.
+// typedef Typedef = void Function();
+//         ^^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:15:1: Error: The part-of directive must be the only directive in a part.
+// Try removing the other directives, or moving them to the library for which this is a part.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+// ^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:19:16: Error: 'OldTypedef' is already declared in this scope.
+// typedef Object OldTypedef();
+//                ^^^^^^^^^^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:17:14: Context: Previous declaration of 'OldTypedef'.
+// typedef void OldTypedef();
+//              ^^^^^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:23:5: Error: 'field' is already declared in this scope.
+// var field = 4;
+//     ^^^^^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:21:5: Context: Previous declaration of 'field'.
+// var field = "3rd";
+//     ^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:25:5: Error: 'field' is already declared in this scope.
+// var field = 5.0;
+//     ^^^^^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:23:5: Context: Previous declaration of 'field'.
+// var field = 4;
+//     ^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:31:1: Error: 'main' is already declared in this scope.
+// main() {
+// ^^^^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:27:1: Context: Previous declaration of 'main'.
+// main() {
+// ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:35:1: Error: 'main' is already declared in this scope.
+// main() {
+// ^^^^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:31:1: Context: Previous declaration of 'main'.
+// main() {
+// ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:41:3: Error: 'C' is already declared in this scope.
+//   C(a, b);
+//   ^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:40:3: Context: Previous declaration of 'C'.
+//   C(a);
+//   ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:44:7: Error: 'field' is already declared in this scope.
+//   var field = "2nd";
+//       ^^^^^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:42:7: Context: Previous declaration of 'field'.
+//   var field = "1st";
+//       ^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:50:3: Error: 'm' is already declared in this scope.
+//   m() {
+//   ^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:46:3: Context: Previous declaration of 'm'.
+//   m() {
+//   ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:58:10: Error: 's' is already declared in this scope.
+//   static s() {
+//          ^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:54:10: Context: Previous declaration of 's'.
+//   static s() {
+//          ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:65:7: Error: 'C' is already declared in this scope.
+// class C {
+//       ^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:39:7: Context: Previous declaration of 'C'.
+// class C {
+//       ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:69:7: Error: 'C' is already declared in this scope.
+// class C {
+//       ^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:65:7: Context: Previous declaration of 'C'.
+// class C {
+//       ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:74:3: Error: Name of enum constant 'Enum' can't be the same as the enum's own name.
+//   Enum,
+//   ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:76:3: Error: 'a' is already declared in this scope.
+//   a,
+//   ^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:75:3: Context: Previous declaration of 'a'.
+//   a,
+//   ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:80:6: Error: 'Enum' is already declared in this scope.
+// enum Enum {
+//      ^^^^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:73:6: Context: Previous declaration of 'Enum'.
+// enum Enum {
+//      ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:86:6: Error: 'Enum' is already declared in this scope.
+// enum Enum {
+//      ^^^^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:80:6: Context: Previous declaration of 'Enum'.
+// enum Enum {
+//      ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:11:9: Error: 'Typedef' is already declared in this scope.
+// typedef Typedef = void Function();
+//         ^^^^^^^
+// pkg/front_end/testcases/duplicated_declarations.dart:13:9: Context: Previous declaration of 'Typedef'.
+// typedef Typedef = Object Function();
+//         ^^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:17:14: Error: 'OldTypedef' is already declared in this scope.
+// typedef void OldTypedef();
+//              ^^^^^^^^^^
+// pkg/front_end/testcases/duplicated_declarations.dart:19:16: Context: Previous declaration of 'OldTypedef'.
+// typedef Object OldTypedef();
+//                ^^^^^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:21:5: Error: 'field' is already declared in this scope.
+// var field = "3rd";
+//     ^^^^^
+// pkg/front_end/testcases/duplicated_declarations.dart:23:5: Context: Previous declaration of 'field'.
+// var field = "2nd";
+//     ^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:27:1: Error: 'main' is already declared in this scope.
+// main() {
+// ^^^^
+// pkg/front_end/testcases/duplicated_declarations.dart:29:1: Context: Previous declaration of 'main'.
+// main() {
+// ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:39:7: Error: 'C' is already declared in this scope.
+// class C {
+//       ^
+// pkg/front_end/testcases/duplicated_declarations.dart:70:7: Context: Previous declaration of 'C'.
+// class C {
+//       ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:73:6: Error: 'Enum' is already declared in this scope.
+// enum Enum {
+//      ^^^^
+// pkg/front_end/testcases/duplicated_declarations.dart:81:6: Context: Previous declaration of 'Enum'.
+// enum Enum {
+//      ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations.dart:7:46: Error: 'Typedef' is already declared in this scope.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+//                                              ^^^^^^^
+// pkg/front_end/testcases/duplicated_declarations_part.dart:13:9: Context: Previous declaration of 'Typedef'.
+// typedef Typedef = Object Function();
+//         ^^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations.dart:65:19: Error: 'C' isn't a type.
 // class Sub extends C {
 //                   ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:26:3: Error: Can't use 'main' because it is declared more than once.
+// pkg/front_end/testcases/duplicated_declarations.dart:34:3: Error: Can't use 'main' because it is declared more than once.
 //   main();
 //   ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:27:9: Error: Can't use 'field' because it is declared more than once.
+// pkg/front_end/testcases/duplicated_declarations.dart:35:9: Error: Can't use 'field' because it is declared more than once.
 //   print(field);
 //         ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:28:3: Error: Can't use 'C' because it is declared more than once.
+// pkg/front_end/testcases/duplicated_declarations.dart:36:3: Error: Can't use 'C' because it is declared more than once.
 //   C.s();
 //   ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:54:17: Error: Can't use 's' because it is declared more than once.
+// pkg/front_end/testcases/duplicated_declarations.dart:62:17: Error: Can't use 's' because it is declared more than once.
 //   static f() => s;
 //                 ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:58:16: Error: Too many positional arguments: 0 allowed, but 1 found.
+// pkg/front_end/testcases/duplicated_declarations.dart:66:16: Error: Too many positional arguments: 0 allowed, but 1 found.
 // Try removing the extra positional arguments.
 //   Sub() : super(null);
 //                ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:59:16: Error: Superclass has no method named 'm'.
+// pkg/front_end/testcases/duplicated_declarations.dart:67:16: Error: Superclass has no method named 'm'.
 //   m() => super.m();
 //                ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:94:38: Error: Can't use '_name' because it is declared more than once.
+// pkg/front_end/testcases/duplicated_declarations.dart:102:38: Error: Can't use '_name' because it is declared more than once.
 //     "AnotherEnum._name": AnotherEnum._name,
 //                                      ^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:95:38: Error: Can't use 'index' because it is declared more than once.
+// pkg/front_end/testcases/duplicated_declarations.dart:103:38: Error: Can't use 'index' because it is declared more than once.
 //     "AnotherEnum.index": AnotherEnum.index,
 //                                      ^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:96:41: Error: Can't use 'toString' because it is declared more than once.
+// pkg/front_end/testcases/duplicated_declarations.dart:104:41: Error: Can't use 'toString' because it is declared more than once.
 //     "AnotherEnum.toString": AnotherEnum.toString,
 //                                         ^^^^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:97:39: Error: Can't use 'values' because it is declared more than once.
+// pkg/front_end/testcases/duplicated_declarations.dart:105:39: Error: Can't use 'values' because it is declared more than once.
 //     "AnotherEnum.values": AnotherEnum.values,
 //                                       ^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:62:17: Error: Can't use 's' because it is declared more than once.
+//   static f() => s;
+//                 ^
 
 // Unhandled errors:
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:7:9: Error: 'Typedef' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:7:1: Error: Import directives must preceed part directives.
+// Try moving the import directives before the part directives.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+// ^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations.dart:9:1: Error: Import directives must preceed part directives.
+// Try moving the import directives before the part directives.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+// ^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations.dart:13:9: Error: 'Typedef' is already declared in this scope.
 // typedef Typedef = Object Function();
 //         ^^^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:11:16: Error: 'OldTypedef' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:15:1: Error: Directives must appear before any declarations.
+// Try moving the directive before any declarations.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+// ^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations.dart:19:16: Error: 'OldTypedef' is already declared in this scope.
 // typedef Object OldTypedef();
 //                ^^^^^^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:15:5: Error: 'field' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:23:5: Error: 'field' is already declared in this scope.
 // var field = "2nd";
 //     ^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:21:1: Error: 'main' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:29:1: Error: 'main' is already declared in this scope.
 // main() {
 // ^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:33:3: Error: 'C' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:41:3: Error: 'C' is already declared in this scope.
 //   C(a, b);
 //   ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:36:7: Error: 'field' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:44:7: Error: 'field' is already declared in this scope.
 //   var field = "2nd";
 //       ^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:42:3: Error: 'm' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:50:3: Error: 'm' is already declared in this scope.
 //   m() {
 //   ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:50:10: Error: 's' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:58:10: Error: 's' is already declared in this scope.
 //   static s() {
 //          ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:62:7: Error: 'C' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:70:7: Error: 'C' is already declared in this scope.
 // class C {
 //       ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:67:3: Error: Name of enum constant 'Enum' can't be the same as the enum's own name.
+// pkg/front_end/testcases/duplicated_declarations.dart:75:3: Error: Name of enum constant 'Enum' can't be the same as the enum's own name.
 //   Enum,
 //   ^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:69:3: Error: 'a' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:77:3: Error: 'a' is already declared in this scope.
 //   a,
 //   ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:73:6: Error: 'Enum' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:81:6: Error: 'Enum' is already declared in this scope.
 // enum Enum {
 //      ^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:83:3: Error: '_name' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:91:3: Error: '_name' is already declared in this scope.
 //   _name,
 //   ^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:84:3: Error: 'index' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:92:3: Error: 'index' is already declared in this scope.
 //   index,
 //   ^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:85:3: Error: 'toString' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:93:3: Error: 'toString' is already declared in this scope.
 //   toString,
 //   ^^^^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:86:3: Error: 'values' is already declared in this scope.
+// pkg/front_end/testcases/duplicated_declarations.dart:94:3: Error: 'values' is already declared in this scope.
 //   values,
 //   ^^^^^^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:57:19: Error: 'C' isn't a type.
+// pkg/front_end/testcases/duplicated_declarations_part.dart:7:1: Error: The part-of directive must be the only directive in a part.
+// Try removing the other directives, or moving them to the library for which this is a part.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+// ^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:9:1: Error: The part-of directive must be the only directive in a part.
+// Try removing the other directives, or moving them to the library for which this is a part.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+// ^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:13:9: Error: 'Typedef' is already declared in this scope.
+// typedef Typedef = Object Function();
+//         ^^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:15:1: Error: The part-of directive must be the only directive in a part.
+// Try removing the other directives, or moving them to the library for which this is a part.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+// ^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:19:16: Error: 'OldTypedef' is already declared in this scope.
+// typedef Object OldTypedef();
+//                ^^^^^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:23:5: Error: 'field' is already declared in this scope.
+// var field = 4;
+//     ^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:25:5: Error: 'field' is already declared in this scope.
+// var field = 5.0;
+//     ^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:31:1: Error: 'main' is already declared in this scope.
+// main() {
+// ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:35:1: Error: 'main' is already declared in this scope.
+// main() {
+// ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:41:3: Error: 'C' is already declared in this scope.
+//   C(a, b);
+//   ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:44:7: Error: 'field' is already declared in this scope.
+//   var field = "2nd";
+//       ^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:50:3: Error: 'm' is already declared in this scope.
+//   m() {
+//   ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:58:10: Error: 's' is already declared in this scope.
+//   static s() {
+//          ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:65:7: Error: 'C' is already declared in this scope.
+// class C {
+//       ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:69:7: Error: 'C' is already declared in this scope.
+// class C {
+//       ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:74:3: Error: Name of enum constant 'Enum' can't be the same as the enum's own name.
+//   Enum,
+//   ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:76:3: Error: 'a' is already declared in this scope.
+//   a,
+//   ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:80:6: Error: 'Enum' is already declared in this scope.
+// enum Enum {
+//      ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:86:6: Error: 'Enum' is already declared in this scope.
+// enum Enum {
+//      ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:11:9: Error: 'Typedef' is already declared in this scope.
+// typedef Typedef = void Function();
+//         ^^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:17:14: Error: 'OldTypedef' is already declared in this scope.
+// typedef void OldTypedef();
+//              ^^^^^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:21:5: Error: 'field' is already declared in this scope.
+// var field = "3rd";
+//     ^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:27:1: Error: 'main' is already declared in this scope.
+// main() {
+// ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:39:7: Error: 'C' is already declared in this scope.
+// class C {
+//       ^
+//
+// pkg/front_end/testcases/duplicated_declarations_part.dart:73:6: Error: 'Enum' is already declared in this scope.
+// enum Enum {
+//      ^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations.dart:7:46: Error: 'Typedef' is already declared in this scope.
+// import 'duplicated_declarations_lib.dart' as Typedef;
+//                                              ^^^^^^^
+//
+// pkg/front_end/testcases/duplicated_declarations.dart:65:19: Error: 'C' isn't a type.
 // class Sub extends C {
 //                   ^
 //
-// pkg/front_end/testcases/duplicated_declarations.dart:59:16: Error: Superclass has no method named 'm'.
+// pkg/front_end/testcases/duplicated_declarations.dart:67:16: Error: Superclass has no method named 'm'.
 //   m() => super.m();
 //                ^
 
@@ -234,13 +548,39 @@
 
 typedef Typedef = () → void;
 typedef OldTypedef = () → void;
+class C#4 extends core::Object { // from org-dartlang-testcase:///duplicated_declarations_part.dart
+  constructor _() → self::C#4
+    : super core::Object::•()
+    ;
+}
+class C#3 extends core::Object { // from org-dartlang-testcase:///duplicated_declarations_part.dart
+  constructor _() → self::C#3
+    : super core::Object::•()
+    ;
+}
+class C#2 extends core::Object { // from org-dartlang-testcase:///duplicated_declarations_part.dart
+  field dynamic field = null;
+  constructor •(dynamic a) → self::C#2
+    : super core::Object::•()
+    ;
+  method m() → dynamic {
+    "1st";
+  }
+  static method s() → dynamic {
+    "1st";
+  }
+  static method f() → dynamic
+    return invalid-expression "pkg/front_end/testcases/duplicated_declarations_part.dart:62:17: Error: Can't use 's' because it is declared more than once.
+  static f() => s;
+                ^";
+}
 class C#1 extends core::Object {
   constructor _() → self::C#1
     : super core::Object::•()
     ;
 }
 class C extends core::Object {
-  field dynamic field;
+  field dynamic field = null;
   constructor •(dynamic a) → self::C
     : super core::Object::•()
     ;
@@ -251,13 +591,13 @@
     "1st";
   }
   static method f() → dynamic
-    return invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:54:17: Error: Can't use 's' because it is declared more than once.
+    return invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:62:17: Error: Can't use 's' because it is declared more than once.
   static f() => s;
                 ^";
 }
 class Sub extends core::Object {
   constructor •() → self::Sub
-    : final dynamic #t1 = invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:58:16: Error: Too many positional arguments: 0 allowed, but 1 found.
+    : final dynamic #t1 = invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:66:16: Error: Too many positional arguments: 0 allowed, but 1 found.
 Try removing the extra positional arguments.
   Sub() : super(null);
                ^"
@@ -265,6 +605,43 @@
   method m() → dynamic
     return super.m();
 }
+class Enum#4 extends core::Object { // from org-dartlang-testcase:///duplicated_declarations_part.dart
+  final field core::int index;
+  final field core::String _name;
+  static const field core::List<self::Enum#4> values = const <self::Enum#4>[self::Enum#4::a];
+  static const field self::Enum#4 a = const self::Enum#4::•(0, "Enum.a");
+  const constructor •(core::int index, core::String _name) → self::Enum#4
+    : self::Enum#4::index = index, self::Enum#4::_name = _name, super core::Object::•()
+    ;
+  method toString() → core::String
+    return this.{=self::Enum#4::_name};
+}
+class Enum#3 extends core::Object { // from org-dartlang-testcase:///duplicated_declarations_part.dart
+  final field core::int index;
+  final field core::String _name;
+  static const field core::List<self::Enum#3> values = const <self::Enum#3>[self::Enum#3::a, self::Enum#3::b, self::Enum#3::c];
+  static const field self::Enum#3 a = const self::Enum#3::•(0, "Enum.a");
+  static const field self::Enum#3 b = const self::Enum#3::•(1, "Enum.b");
+  static const field self::Enum#3 c = const self::Enum#3::•(2, "Enum.c");
+  const constructor •(core::int index, core::String _name) → self::Enum#3
+    : self::Enum#3::index = index, self::Enum#3::_name = _name, super core::Object::•()
+    ;
+  method toString() → core::String
+    return this.{=self::Enum#3::_name};
+}
+class Enum#2 extends core::Object { // from org-dartlang-testcase:///duplicated_declarations_part.dart
+  final field core::int index;
+  final field core::String _name;
+  static const field core::List<self::Enum#2> values = const <self::Enum#2>[self::Enum#2::Enum, self::Enum#2::a, self::Enum#2::b];
+  static const field self::Enum#2 Enum = const self::Enum#2::•(0, "Enum.Enum");
+  static const field self::Enum#2 a = const self::Enum#2::•(1, "Enum.a");
+  static const field self::Enum#2 b = const self::Enum#2::•(2, "Enum.b");
+  const constructor •(core::int index, core::String _name) → self::Enum#2
+    : self::Enum#2::index = index, self::Enum#2::_name = _name, super core::Object::•()
+    ;
+  method toString() → core::String
+    return this.{=self::Enum#2::_name};
+}
 class Enum#1 extends core::Object {
   final field core::int index;
   final field core::String _name;
@@ -304,29 +681,29 @@
   method toString() → core::String
     return this.{=self::AnotherEnum::_name};
 }
-static field dynamic field;
+static field core::String field;
 static method main() → dynamic {
   "1st";
 }
 static method foo() → dynamic {
-  invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:26:3: Error: Can't use 'main' because it is declared more than once.
+  invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:34:3: Error: Can't use 'main' because it is declared more than once.
   main();
   ^".call();
-  core::print(invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:27:9: Error: Can't use 'field' because it is declared more than once.
+  core::print(invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:35:9: Error: Can't use 'field' because it is declared more than once.
   print(field);
         ^");
-  invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:28:3: Error: Can't use 'C' because it is declared more than once.
+  invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:36:3: Error: Can't use 'C' because it is declared more than once.
   C.s();
   ^".s();
 }
 static method useAnotherEnum() → dynamic {
-  <core::String, core::Object>{"AnotherEnum.a": self::AnotherEnum::a, "AnotherEnum.b": self::AnotherEnum::b, "AnotherEnum.c": self::AnotherEnum::c, "AnotherEnum._name": invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:94:38: Error: Can't use '_name' because it is declared more than once.
+  <core::String, core::Object>{"AnotherEnum.a": self::AnotherEnum::a, "AnotherEnum.b": self::AnotherEnum::b, "AnotherEnum.c": self::AnotherEnum::c, "AnotherEnum._name": invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:102:38: Error: Can't use '_name' because it is declared more than once.
     \"AnotherEnum._name\": AnotherEnum._name,
-                                     ^^^^^", "AnotherEnum.index": invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:95:38: Error: Can't use 'index' because it is declared more than once.
+                                     ^^^^^", "AnotherEnum.index": invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:103:38: Error: Can't use 'index' because it is declared more than once.
     \"AnotherEnum.index\": AnotherEnum.index,
-                                     ^^^^^", "AnotherEnum.toString": invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:96:41: Error: Can't use 'toString' because it is declared more than once.
+                                     ^^^^^", "AnotherEnum.toString": invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:104:41: Error: Can't use 'toString' because it is declared more than once.
     \"AnotherEnum.toString\": AnotherEnum.toString,
-                                        ^^^^^^^^", "AnotherEnum.values": invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:97:39: Error: Can't use 'values' because it is declared more than once.
+                                        ^^^^^^^^", "AnotherEnum.values": invalid-expression "pkg/front_end/testcases/duplicated_declarations.dart:105:39: Error: Can't use 'values' because it is declared more than once.
     \"AnotherEnum.values\": AnotherEnum.values,
                                       ^^^^^^"};
 }
diff --git a/pkg/front_end/testcases/duplicated_declarations_lib.dart b/pkg/front_end/testcases/duplicated_declarations_lib.dart
new file mode 100644
index 0000000..87869b0
--- /dev/null
+++ b/pkg/front_end/testcases/duplicated_declarations_lib.dart
@@ -0,0 +1,3 @@
+// Copyright (c) 2018, the Dart project authors.  Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
diff --git a/pkg/front_end/testcases/duplicated_declarations_part.dart b/pkg/front_end/testcases/duplicated_declarations_part.dart
new file mode 100644
index 0000000..a31f772
--- /dev/null
+++ b/pkg/front_end/testcases/duplicated_declarations_part.dart
@@ -0,0 +1,88 @@
+// Copyright (c) 2018, the Dart project authors.  Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+part of "duplicated_declarations.dart";
+
+import 'duplicated_declarations_lib.dart' as Typedef;
+
+import 'duplicated_declarations_lib.dart' as Typedef;
+
+typedef Typedef = void Function();
+
+typedef Typedef = Object Function();
+
+import 'duplicated_declarations_lib.dart' as Typedef;
+
+typedef void OldTypedef();
+
+typedef Object OldTypedef();
+
+var field = "3rd";
+
+var field = 4;
+
+var field = 5.0;
+
+main() {
+  "3rd";
+}
+
+main() {
+  "4th";
+}
+
+main() {
+  "5th";
+}
+
+class C {
+  C(a);
+  C(a, b);
+  var field = "1st";
+
+  var field = "2nd";
+
+  m() {
+    "1st";
+  }
+
+  m() {
+    "2nd";
+  }
+
+  static s() {
+    "1st";
+  }
+
+  static s() {
+    "2nd";
+  }
+
+  static f() => s;
+}
+
+class C {
+  C._();
+}
+
+class C {
+  C._();
+}
+
+enum Enum {
+  Enum,
+  a,
+  a,
+  b,
+}
+
+enum Enum {
+  a,
+  b,
+  c,
+}
+
+enum Enum {
+  a,
+}