Skip to content

Commit

Permalink
Add InterfaceType.allSupertypes.
Browse files Browse the repository at this point in the history
R=brianwilkerson@google.com

Change-Id: I9c5058091b1a4473a2535ba792aa6bbfac35793c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153945
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
  • Loading branch information
scheglov authored and commit-bot@chromium.org committed Jul 10, 2020
1 parent b09dd47 commit c367b48
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/analyzer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand Down
4 changes: 4 additions & 0 deletions pkg/analyzer/lib/dart/element/type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ abstract class InterfaceType implements ParameterizedType {
/// declared in this type.
List<PropertyAccessorElement> get accessors;

/// Return all the super-interfaces implemented by this interface. This
/// includes superclasses, mixins, interfaces, and superclass constraints.
List<InterfaceType> get allSupertypes;

/// Return a list containing all of the constructors declared in this type.
List<ConstructorElement> get constructors;

Expand Down
6 changes: 6 additions & 0 deletions pkg/analyzer/lib/src/dart/element/type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,12 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
return _accessors;
}

@override
List<InterfaceType> get allSupertypes {
var substitution = Substitution.fromInterfaceType(this);
return element.allSupertypes.map(substitution.substituteType).toList();
}

@override
List<ConstructorElement> get constructors {
if (_constructors == null) {
Expand Down

0 comments on commit c367b48

Please sign in to comment.