Skip to content

Commit

Permalink
Look into superclassConstraints while searching for a member in inter…
Browse files Browse the repository at this point in the history
…faces.

R=brianwilkerson@google.com, paulberry@google.com

Bug: #34564
Change-Id: I11642d89710a89fb347106ff374ff0ea4227310c
Reviewed-on: https://dart-review.googlesource.com/76284
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
  • Loading branch information
scheglov authored and commit-bot@chromium.org committed Sep 24, 2018
1 parent 95d37b0 commit e4eb243
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
15 changes: 12 additions & 3 deletions pkg/analyzer/lib/src/dart/element/type.dart
Expand Up @@ -1508,9 +1508,11 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
//
List<DartType> jArgs = j.typeArguments;
List<DartType> jVars = jElement.type.typeArguments;
supertype = supertype.substitute2(jArgs, jVars);
if (supertype == i) {
return true;
if (supertype != null) {
supertype = supertype.substitute2(jArgs, jVars);
if (supertype == i) {
return true;
}
}
//
// I is listed in the on clause of J.
Expand Down Expand Up @@ -2394,6 +2396,13 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
return member;
}
}
for (InterfaceType constraint in targetType.superclassConstraints) {
ExecutableElement member = _lookUpMemberInInterfaces(
constraint, true, library, visitedInterfaces, getMember);
if (member != null) {
return member;
}
}
for (InterfaceType mixinType in targetType.mixins.reversed) {
ExecutableElement member = _lookUpMemberInInterfaces(
mixinType, true, library, visitedInterfaces, getMember);
Expand Down
24 changes: 24 additions & 0 deletions pkg/analyzer/test/src/dart/resolution/mixin_test.dart
Expand Up @@ -1579,6 +1579,30 @@ mixin M implements A, B {}
]);
}

test_isMoreSpecificThan() async {
addTestFile(r'''
mixin M {}
''');
await resolveTestFile();
assertNoTestErrors();

var element = findElement.mixin('M');
var type = element.type;
expect(type.isMoreSpecificThan(intType), isFalse);
}

test_lookUpMemberInInterfaces_Object() async {
addTestFile(r'''
class Foo {}
mixin UnhappyMixin on Foo {
String toString() => '$runtimeType';
}
''');
await resolveTestFile();
assertNoTestErrors();
}

test_metadata() async {
addTestFile(r'''
const a = 0;
Expand Down

0 comments on commit e4eb243

Please sign in to comment.