Skip to content

Commit

Permalink
[analyzer] Use Impl types in TypeProviderImpl.
Browse files Browse the repository at this point in the history
Change the methods in `TypeProviderImpl` so that their return types
are all "Impl" types rather than analyzer public API types.

This doesn't change the analyzer public API; it simply ensures that
clients of `TypeProviderImpl` within the analyzer itself won't have to
perform typecasts on the returned values in order to access the Impl
classes.

This is part of a larger arc of work to change the analyzer's use of
the shared code so that the type parameters it supplies are not part
of the analyzer public API (See
#59763). This change will
reduce the number of type casts that have to be done in order to pass
`TypeImpl` types to shared code rather than `DartType` types.

Change-Id: Ia351c3e8893cf10671b04b813ee80ff2b3bda341
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/402621
Commit-Queue: Paul Berry <[email protected]>
Reviewed-by: Konstantin Shcheglov <[email protected]>
  • Loading branch information
stereotype441 authored and Commit Queue committed Jan 11, 2025
1 parent adcc212 commit bdf8c21
Show file tree
Hide file tree
Showing 4 changed files with 154 additions and 159 deletions.
10 changes: 5 additions & 5 deletions pkg/analyzer/lib/src/dart/element/element.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,7 @@ class CompilationUnitElementImpl extends UriReferencedElementImpl
}

@override
ClassElement? getClass(String className) {
ClassElementImpl? getClass(String className) {
for (var class_ in classes) {
if (class_.name == className) {
return class_;
Expand Down Expand Up @@ -5900,11 +5900,11 @@ abstract class InterfaceElementImpl extends InstanceElementImpl

/// The non-nullable instance of this element, without alias.
/// Should be used only when the element has no type parameters.
InterfaceType? _nonNullableInstance;
InterfaceTypeImpl? _nonNullableInstance;

/// The nullable instance of this element, without alias.
/// Should be used only when the element has no type parameters.
InterfaceType? _nullableInstance;
InterfaceTypeImpl? _nullableInstance;

List<ConstructorElementImpl> _constructors = _Sentinel.constructorElement;

Expand Down Expand Up @@ -6077,7 +6077,7 @@ abstract class InterfaceElementImpl extends InstanceElementImpl
}

@override
InterfaceType instantiate({
InterfaceTypeImpl instantiate({
required List<DartType> typeArguments,
required NullabilitySuffix nullabilitySuffix,
}) {
Expand Down Expand Up @@ -7090,7 +7090,7 @@ class LibraryElementImpl extends ElementImpl
}

@override
ClassElement? getClass(String name) {
ClassElementImpl? getClass(String name) {
for (var unitElement in units) {
var element = unitElement.getClass(name);
if (element != null) {
Expand Down
Loading

0 comments on commit bdf8c21

Please sign in to comment.