Look into superclassConstraints while searching for a member in interfaces.
R=brianwilkerson@google.com, paulberry@google.com
Bug: https://github.com/dart-lang/sdk/issues/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>
diff --git a/pkg/analyzer/lib/src/dart/element/type.dart b/pkg/analyzer/lib/src/dart/element/type.dart
index 178000f..7207be9 100644
--- a/pkg/analyzer/lib/src/dart/element/type.dart
+++ b/pkg/analyzer/lib/src/dart/element/type.dart
@@ -1508,9 +1508,11 @@
//
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.
@@ -2394,6 +2396,13 @@
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);
diff --git a/pkg/analyzer/test/src/dart/resolution/mixin_test.dart b/pkg/analyzer/test/src/dart/resolution/mixin_test.dart
index 0375fc2..0361250 100644
--- a/pkg/analyzer/test/src/dart/resolution/mixin_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/mixin_test.dart
@@ -1579,6 +1579,30 @@
]);
}
+ 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;