Skip to content

Commit

Permalink
Elements. Use TypeImpl in exhaustiveness.dart, remove a cast.
Browse files Browse the repository at this point in the history
Change-Id: Iefe63fef5e1f94bcc194ec442e88c054f8106844
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/412187
Commit-Queue: Konstantin Shcheglov <[email protected]>
Reviewed-by: Paul Berry <[email protected]>
  • Loading branch information
scheglov authored and Commit Queue committed Feb 26, 2025
1 parent 27cc757 commit c496fea
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 118 deletions.
15 changes: 8 additions & 7 deletions pkg/analyzer/lib/src/dart/element/type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
List<PropertyAccessorElement>? _accessors;

/// Cached [MethodElement]s - members or raw elements.
List<MethodElement>? _methods;
List<MethodElementOrMember>? _methods;

factory InterfaceTypeImpl({
required InterfaceElementImpl2 element,
Expand Down Expand Up @@ -686,10 +686,11 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
InterfaceElementImpl get element => element3.asElement;

@override
List<GetterElement> get getters => accessors
List<GetterElement2OrMember> get getters => accessors
.where((accessor) => accessor.isGetter)
.map((fragment) => switch (fragment) {
GetterFragment(:var element) => element as GetterElement,
PropertyAccessorElementImpl(:var element) =>
element as GetterElement2OrMember,
GetterMember() => fragment,
_ => throw StateError(
'unexpected fragment type: ${fragment.runtimeType}',
Expand Down Expand Up @@ -794,10 +795,10 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
}

@override
List<MethodElement> get methods {
List<MethodElementOrMember> get methods {
if (_methods == null) {
List<MethodElement> methods = element.methods;
var members = <MethodElement>[];
var members = <MethodElementOrMember>[];
var methods = element.methods;
for (int i = 0; i < methods.length; i++) {
members.add(MethodMember.from(methods[i], this)!);
}
Expand All @@ -807,7 +808,7 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
}

@override
List<MethodElement2> get methods2 =>
List<MethodElement2OrMember> get methods2 =>
methods.map((e) => e.asElement2).toList();

@override
Expand Down
Loading

0 comments on commit c496fea

Please sign in to comment.