diff --git a/pkg/analyzer/lib/src/utilities/extensions/library_element.dart b/pkg/analyzer/lib/src/utilities/extensions/library_element.dart index d8d8fc29522..45f8f13032c 100644 --- a/pkg/analyzer/lib/src/utilities/extensions/library_element.dart +++ b/pkg/analyzer/lib/src/utilities/extensions/library_element.dart @@ -21,9 +21,7 @@ extension _ElementExtension on Element { /// is a match up to [thisIndex]. Element? _locateElement(ElementLocation location, int thisIndex) { final components = location.components; - // TODO(paulberry): once the analyzer's pubspec specifies a minimum SDK - // version that supports [IndexError.check], switch to using that instead. - RangeError.checkValidIndex(thisIndex, components); + IndexError.check(thisIndex, components.length, indexable: components); final nextIndex = thisIndex + 1; if (nextIndex == components.length) {