Skip to content

Commit

Permalink
Resolve types from the class header earlier
Browse files Browse the repository at this point in the history
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 <[email protected]>
Commit-Queue: Peter von der Ahé <[email protected]>
Auto-Submit: Kevin Millikin <[email protected]>
Reviewed-by: Peter von der Ahé <[email protected]>
  • Loading branch information
Kevin Millikin authored and [email protected] committed Oct 22, 2018
1 parent 1515d4f commit 393fe44
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/front_end/lib/src/fasta/source/outline_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,16 @@ class OutlineBuilder extends StackListener {
..typeVariables = typeVariables;
}

@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) {
Expand Down
13 changes: 13 additions & 0 deletions tests/language_2/issue34870_test.dart
Original file line number Diff line number Diff line change
@@ -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() {}

0 comments on commit 393fe44

Please sign in to comment.