Resolve types from the class header earlier

When building outlines, resolve unresolved types from the class
header (including superclass, mixin, and interface types) before any
methods from the body are parsed.  This ensures that they types from
the class header are not shadowed by names introduced in the body.

Change-Id: Ie842b9ab23d9b44d91609f9e1bf79c052cfce2d4
Reviewed-on: https://dart-review.googlesource.com/c/81008
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Commit-Queue: Peter von der Ahé <ahe@google.com>
Auto-Submit: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
diff --git a/pkg/front_end/lib/src/fasta/source/outline_builder.dart b/pkg/front_end/lib/src/fasta/source/outline_builder.dart
index 02319db..5b1f67f 100644
--- a/pkg/front_end/lib/src/fasta/source/outline_builder.dart
+++ b/pkg/front_end/lib/src/fasta/source/outline_builder.dart
@@ -475,6 +475,16 @@
   }
 
   @override
+  void beginClassOrMixinBody(Token token) {
+    debugEvent("beginClassOrMixinBody");
+    // Resolve unresolved types from the class header (i.e., superclass, mixins,
+    // and implemented types) before adding members from the class body which
+    // should not shadow these unresolved types.
+    library.currentDeclaration
+        .resolveTypes(library.currentDeclaration.typeVariables, library);
+  }
+
+  @override
   void beginNamedMixinApplication(
       Token begin, Token abstractToken, Token name) {
     debugEvent("beginNamedMixinApplication");
diff --git a/tests/language_2/issue34870_test.dart b/tests/language_2/issue34870_test.dart
new file mode 100644
index 0000000..750048d
--- /dev/null
+++ b/tests/language_2/issue34870_test.dart
@@ -0,0 +1,13 @@
+// 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.
+
+// Regression test: superclass is not shadowed by class members.
+
+class A extends B {
+  B() {}
+}
+
+class B {}
+
+main() {}