Skip to content

Commit 6811e7f

Browse files
scheglovCommit Queue
authored andcommitted
Elements. Remove the type parameter from thisOrAncestorMatching2().
It was only used for unconditional cast. Change-Id: I9330015c48d25e91ac1c1ade7b332f5d68d08ed0 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/390942 Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Phil Quitslund <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent aff1786 commit 6811e7f

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

pkg/analyzer/lib/dart/element/element2.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ abstract class Element2 {
447447
/// for which the [predicate] returns `true`.
448448
///
449449
/// Returns `null` if there is no such element.
450-
E? thisOrAncestorMatching2<E extends Element2>(
450+
Element2? thisOrAncestorMatching2(
451451
bool Function(Element2) predicate,
452452
);
453453

pkg/analyzer/lib/src/dart/element/element.dart

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3038,14 +3038,14 @@ abstract class ElementImpl implements Element, Element2 {
30383038
}
30393039

30403040
@override
3041-
E? thisOrAncestorMatching2<E extends Element2>(
3041+
Element2? thisOrAncestorMatching2(
30423042
bool Function(Element2) predicate,
30433043
) {
30443044
Element2? element = this;
30453045
while (element != null && !predicate(element)) {
30463046
element = element.enclosingElement2;
30473047
}
3048-
return element as E?;
3048+
return element;
30493049
}
30503050

30513051
@override
@@ -3224,13 +3224,12 @@ abstract class ElementImpl2 implements Element2 {
32243224
}
32253225

32263226
@override
3227-
E? thisOrAncestorMatching2<E extends Element2>(
3228-
bool Function(Element2 p1) predicate) {
3227+
Element2? thisOrAncestorMatching2(bool Function(Element2 p1) predicate) {
32293228
Element2? element = this;
32303229
while (element != null && !predicate(element)) {
32313230
element = element.enclosingElement2;
32323231
}
3233-
return element as E?;
3232+
return element;
32343233
}
32353234

32363235
@override
@@ -7138,11 +7137,11 @@ mixin MaybeAugmentedInstanceElementMixin
71387137
}
71397138

71407139
@override
7141-
E? thisOrAncestorMatching2<E extends Element2>(
7140+
Element2? thisOrAncestorMatching2(
71427141
bool Function(Element2) predicate,
71437142
) {
71447143
if (predicate(this)) {
7145-
return this as E;
7144+
return this;
71467145
}
71477146
return library2.thisOrAncestorMatching2(predicate);
71487147
}
@@ -8347,7 +8346,7 @@ class MultiplyDefinedElementImpl implements MultiplyDefinedElement, Element2 {
83478346
}
83488347

83498348
@override
8350-
E? thisOrAncestorMatching2<E extends Element2>(
8349+
Element2? thisOrAncestorMatching2(
83518350
bool Function(Element2 p1) predicate,
83528351
) {
83538352
return null;

pkg/analyzer/lib/src/dart/element/member.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,7 @@ abstract class ExecutableMember extends Member
333333
_element2.isAccessibleIn2(library);
334334

335335
@override
336-
E? thisOrAncestorMatching2<E extends Element2>(
337-
bool Function(Element2 p1) predicate) =>
336+
Element2? thisOrAncestorMatching2(bool Function(Element2 p1) predicate) =>
338337
_element2.thisOrAncestorMatching2(predicate);
339338

340339
@override
@@ -610,8 +609,7 @@ class FieldMember extends VariableMember
610609
}
611610

612611
@override
613-
E? thisOrAncestorMatching2<E extends Element2>(
614-
bool Function(Element2 e) predicate) {
612+
Element2? thisOrAncestorMatching2(bool Function(Element2 e) predicate) {
615613
return _element2.thisOrAncestorMatching2(predicate);
616614
}
617615

0 commit comments

Comments
 (0)