From c367b488ee69f871b381d85afb6d2fb94a7d1fdb Mon Sep 17 00:00:00 2001 From: Konstantin Shcheglov Date: Fri, 10 Jul 2020 16:23:07 +0000 Subject: [PATCH] Add InterfaceType.allSupertypes. R=brianwilkerson@google.com Change-Id: I9c5058091b1a4473a2535ba792aa6bbfac35793c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153945 Reviewed-by: Brian Wilkerson Commit-Queue: Konstantin Shcheglov --- pkg/analyzer/CHANGELOG.md | 1 + pkg/analyzer/lib/dart/element/type.dart | 4 ++++ pkg/analyzer/lib/src/dart/element/type.dart | 6 ++++++ 3 files changed, 11 insertions(+) diff --git a/pkg/analyzer/CHANGELOG.md b/pkg/analyzer/CHANGELOG.md index 8879a0e1485a..3c8f5a7bae56 100644 --- a/pkg/analyzer/CHANGELOG.md +++ b/pkg/analyzer/CHANGELOG.md @@ -3,6 +3,7 @@ * Added `DynamicType`, `NeverType`, and `VoidType` interfaces. * Added `TypeVisitor` and `DartType.accept(TypeVisitor)`. * Changed `ConstructorElement.returnType` to `InterfaceType`. +* Added `InterfaceType.allSupertypes`. * Added `InterfaceType.asInstanceOf(ClassElement)`. * Removed deprecated internal `bogus-disabled` and `bogus-enabled`. diff --git a/pkg/analyzer/lib/dart/element/type.dart b/pkg/analyzer/lib/dart/element/type.dart index f0cabe3fcee2..4e5d82192457 100644 --- a/pkg/analyzer/lib/dart/element/type.dart +++ b/pkg/analyzer/lib/dart/element/type.dart @@ -261,6 +261,10 @@ abstract class InterfaceType implements ParameterizedType { /// declared in this type. List get accessors; + /// Return all the super-interfaces implemented by this interface. This + /// includes superclasses, mixins, interfaces, and superclass constraints. + List get allSupertypes; + /// Return a list containing all of the constructors declared in this type. List get constructors; diff --git a/pkg/analyzer/lib/src/dart/element/type.dart b/pkg/analyzer/lib/src/dart/element/type.dart index d5e26cc83e07..08c095ed6506 100644 --- a/pkg/analyzer/lib/src/dart/element/type.dart +++ b/pkg/analyzer/lib/src/dart/element/type.dart @@ -716,6 +716,12 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType { return _accessors; } + @override + List get allSupertypes { + var substitution = Substitution.fromInterfaceType(this); + return element.allSupertypes.map(substitution.substituteType).toList(); + } + @override List get constructors { if (_constructors == null) {