Skip to content

Don't use XyzElementImpl and XyzElementImpl2 from the analyzer #4039

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
scheglov opened this issue Apr 28, 2025 · 8 comments
Closed

Don't use XyzElementImpl and XyzElementImpl2 from the analyzer #4039

scheglov opened this issue Apr 28, 2025 · 8 comments

Comments

@scheglov
Copy link
Contributor

This does not let us rename these classes in the analyzer.

@srawlins
Copy link
Member

srawlins commented Apr 28, 2025

Here is the list of code locations where such elements are used:

git grep -n 'ElementImpl' lib
lib/src/model/canonicalization.dart:94:      if (ancestor is! ElementImpl2) {
lib/src/model/canonicalization.dart:98:          throw Exception('${ancestor.runtimeType} is not an ElementImpl2');
lib/src/model/constructor.dart:33:        (element.firstFragment as ConstructorElementImpl).typeNameOffset;
lib/src/model/extension.dart:57:        element: otherType.element3 as InterfaceElementImpl2,

@srawlins
Copy link
Member

If you have the new names of these (ElementImpl2, ConstructoElementImpl, InterfaceElementImpl2), we can push a branch that uses those names, and then you can sync that branch into the Dart SDK in the same CL as the renames.

@scheglov
Copy link
Contributor Author

Is there a reason to use implementation classes at all?

@srawlins
Copy link
Member

I'm not sure. Maybe not.

@srawlins
Copy link
Member

How does one instantiate an interface to bounds? TypeSystem provides instantiateInterfaceToBounds, but that is forbidden, as it accepts an InterfaceElement. TypeSystemImpl, a forbidden class, offers instantiateToBounds2, which requires a forbidden parameter type, InterfaceElementImpl2.

@scheglov
Copy link
Contributor Author

Analyzer 7.4.4 has TypeSystem.instantiateInterfaceToBounds2.

  /// Instantiate the given [element] with default type arguments.
  @experimental
  InterfaceType instantiateInterfaceToBounds2({
    required InterfaceElement2 element,
    required NullabilitySuffix nullabilitySuffix,
  });

Ignore @experimental.

@srawlins
Copy link
Member

I believe this is fixed with #4040, #4041, and #4042.

@scheglov
Copy link
Contributor Author

Thank you! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants