From e4eb2437b8f5adb471303400da181a169b3fc3f0 Mon Sep 17 00:00:00 2001 From: Konstantin Shcheglov Date: Mon, 24 Sep 2018 22:12:14 +0000 Subject: [PATCH] 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 Reviewed-by: Paul Berry Reviewed-by: Brian Wilkerson --- pkg/analyzer/lib/src/dart/element/type.dart | 15 +++++++++--- .../test/src/dart/resolution/mixin_test.dart | 24 +++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/pkg/analyzer/lib/src/dart/element/type.dart b/pkg/analyzer/lib/src/dart/element/type.dart index 178000f43719..7207be9c120c 100644 --- a/pkg/analyzer/lib/src/dart/element/type.dart +++ b/pkg/analyzer/lib/src/dart/element/type.dart @@ -1508,9 +1508,11 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType { // List jArgs = j.typeArguments; List 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 @@ 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); diff --git a/pkg/analyzer/test/src/dart/resolution/mixin_test.dart b/pkg/analyzer/test/src/dart/resolution/mixin_test.dart index 0375fc22e73b..0361250b934d 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 @@ 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;