[M] Change in dart/sdk[main]: [analyzer] Implement static extension getters

0 views
Skip to first unread message

Chloe Stefantsova (Gerrit)

unread,
Oct 27, 2025, 12:27:53 PM (7 days ago) Oct 27
to Chloe Stefantsova, Paul Berry, Konstantin Shcheglov, Commit Queue, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Konstantin Shcheglov and Paul Berry

New activity on the change

Open in Gerrit

Related details

Attention is currently required from:
  • Konstantin Shcheglov
  • Paul Berry
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I6006c86d53e8ca5d20859481e7ab77840a63a1c2
Gerrit-Change-Number: 457024
Gerrit-PatchSet: 4
Gerrit-Owner: Chloe Stefantsova <cstefa...@google.com>
Gerrit-Reviewer: Chloe Stefantsova <cstefa...@google.com>
Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
Gerrit-Reviewer: Paul Berry <paul...@google.com>
Gerrit-Attention: Paul Berry <paul...@google.com>
Gerrit-Attention: Konstantin Shcheglov <sche...@google.com>
Gerrit-Comment-Date: Mon, 27 Oct 2025 16:27:47 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Konstantin Shcheglov (Gerrit)

unread,
Oct 27, 2025, 3:49:37 PM (7 days ago) Oct 27
to Chloe Stefantsova, Paul Berry, Commit Queue, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Chloe Stefantsova and Paul Berry

Konstantin Shcheglov added 4 comments

File pkg/analyzer/lib/src/dart/resolver/applicable_extensions.dart
Line 274, Patchset 4 (Latest): required LibraryElement targetLibrary,
Konstantin Shcheglov . unresolved

It looks that we don't use it.

Line 279, Patchset 4 (Latest): if (extension.extension.extendedType.element == declaration) extension,
Konstantin Shcheglov . unresolved

This is not exactly what the specification uses. I see following: "let M be the set containing each accessible extension whose on-declaration is D, and whose static members include one with the name m, or which declares a constructor named C.m."

And there is definition of "on-declaration" somewhere above, with some exceptions. I think we should have `InterfaceElementImpl get onDeclaration` in `ExtensionElementImpl`.

File pkg/analyzer/lib/src/dart/resolver/extension_member_resolver.dart
Line 156, Patchset 4 (Latest): .havingMemberWithBaseName(name, isStatic: true)
Konstantin Shcheglov . unresolved

This is not exactly what the specification uses. I see following: "In the case where D does not declare any static members whose basename is the basename of m, and D does not declare any constructors named C.m2 where m2 is the basename of m, let M be the set containing each accessible extension whose on-declaration is D, and whose static members include one with the name m, or which declares a constructor named C.m."

Note, it says "with the name m", not `m2` or "basename of m".

I think we implementation would be most clear, if we followed the specification as close as possible. Naming the same `M` is of course not necessary, but semantically it should be what the specification says. Otherwise later it would be very hard to match the code and the specification.

We can freely add new classes as we need to express this new semantics, we don't have to fit into existing classes, if it does not fit :-)

File pkg/analyzer/lib/src/dart/resolver/type_property_resolver.dart
Line 284, Patchset 4 (Latest): void _lookupExtensionForDeclaration(InterfaceElement declaration) {
Konstantin Shcheglov . unresolved

It looks that we use it only once, and don't do any early returns, so can inline it.

Open in Gerrit

Related details

Attention is currently required from:
  • Chloe Stefantsova
  • Paul Berry
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I6006c86d53e8ca5d20859481e7ab77840a63a1c2
Gerrit-Change-Number: 457024
Gerrit-PatchSet: 4
Gerrit-Owner: Chloe Stefantsova <cstefa...@google.com>
Gerrit-Reviewer: Chloe Stefantsova <cstefa...@google.com>
Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
Gerrit-Reviewer: Paul Berry <paul...@google.com>
Gerrit-Attention: Paul Berry <paul...@google.com>
Gerrit-Attention: Chloe Stefantsova <cstefa...@google.com>
Gerrit-Comment-Date: Mon, 27 Oct 2025 19:49:33 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Chloe Stefantsova (Gerrit)

unread,
Oct 28, 2025, 11:02:39 AM (6 days ago) Oct 28
to Chloe Stefantsova, Paul Berry, Konstantin Shcheglov, Commit Queue, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Konstantin Shcheglov and Paul Berry

Chloe Stefantsova added 5 comments

Patchset-level comments
File-level comment, Patchset 6 (Latest):
Chloe Stefantsova . resolved

Konstantin, thank you for the review and the suggestions. I've updated the CL accordingly. PTAL.

File pkg/analyzer/lib/src/dart/resolver/applicable_extensions.dart
Line 274, Patchset 4: required LibraryElement targetLibrary,
Konstantin Shcheglov . resolved

It looks that we don't use it.

Chloe Stefantsova

Thanks for spotting this! Removed.

Line 279, Patchset 4: if (extension.extension.extendedType.element == declaration) extension,
Konstantin Shcheglov . unresolved

This is not exactly what the specification uses. I see following: "let M be the set containing each accessible extension whose on-declaration is D, and whose static members include one with the name m, or which declares a constructor named C.m."

And there is definition of "on-declaration" somewhere above, with some exceptions. I think we should have `InterfaceElementImpl get onDeclaration` in `ExtensionElementImpl`.

Chloe Stefantsova

Good idea. I've added the getter. I also added more tests to make sure the specified exceptions are covered.

File pkg/analyzer/lib/src/dart/resolver/extension_member_resolver.dart
Line 156, Patchset 4: .havingMemberWithBaseName(name, isStatic: true)
Konstantin Shcheglov . unresolved

This is not exactly what the specification uses. I see following: "In the case where D does not declare any static members whose basename is the basename of m, and D does not declare any constructors named C.m2 where m2 is the basename of m, let M be the set containing each accessible extension whose on-declaration is D, and whose static members include one with the name m, or which declares a constructor named C.m."

Note, it says "with the name m", not `m2` or "basename of m".

I think we implementation would be most clear, if we followed the specification as close as possible. Naming the same `M` is of course not necessary, but semantically it should be what the specification says. Otherwise later it would be very hard to match the code and the specification.

We can freely add new classes as we need to express this new semantics, we don't have to fit into existing classes, if it does not fit :-)

Chloe Stefantsova

It makes sense. I've updated the code to reflect the difference between the name and the basename of a member.

File pkg/analyzer/lib/src/dart/resolver/type_property_resolver.dart
Line 284, Patchset 4: void _lookupExtensionForDeclaration(InterfaceElement declaration) {
Konstantin Shcheglov . resolved

It looks that we use it only once, and don't do any early returns, so can inline it.

Chloe Stefantsova

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Konstantin Shcheglov
  • Paul Berry
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I6006c86d53e8ca5d20859481e7ab77840a63a1c2
Gerrit-Change-Number: 457024
Gerrit-PatchSet: 6
Gerrit-Owner: Chloe Stefantsova <cstefa...@google.com>
Gerrit-Reviewer: Chloe Stefantsova <cstefa...@google.com>
Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
Gerrit-Reviewer: Paul Berry <paul...@google.com>
Gerrit-Attention: Paul Berry <paul...@google.com>
Gerrit-Attention: Konstantin Shcheglov <sche...@google.com>
Gerrit-Comment-Date: Tue, 28 Oct 2025 15:02:33 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Konstantin Shcheglov <sche...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Konstantin Shcheglov (Gerrit)

unread,
Oct 28, 2025, 12:23:30 PM (6 days ago) Oct 28
to Chloe Stefantsova, Paul Berry, Commit Queue, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Chloe Stefantsova and Paul Berry

Konstantin Shcheglov added 11 comments

File pkg/analyzer/lib/src/dart/element/element.dart
Line 2334, Patchset 6 (Latest): /// In case the extension declaration doesn't have an on-time, `null` is
Konstantin Shcheglov . unresolved

What is this?

Line 2336, Patchset 6 (Latest): @trackedIncludedInId
Konstantin Shcheglov . unresolved

Please read documentation for this annotation.

Here, `onDeclaration` is `trackedIndirectly`, because its value depends only on `extendedType`, which is tracked.

Line 2361, Patchset 6 (Latest): switch (extendedType.element.kind) {
Konstantin Shcheglov . unresolved

Lets use type matching, instead of kind matching, i.e. match `case ClassElementImpl()`- this is IMHO more readable.

Line 2366, Patchset 6 (Latest): if (extendedType.isDartAsyncFutureOr) {
Konstantin Shcheglov . unresolved

I cannot find a test for this. I wonder how to test it better... Lets add a few element model tests. See `ExtensionElementTest`, add tests line `test_onDeclaration_class`, `test_onDeclaration_mixin`, etc. And one of them covering also ``FutureOr. You will need to update `_Element2Writer` to write this new property. This might affect expectations for a few tests, to update them automatically, see `NodeTextExpectationsCollector.updatingIsEnabled`

Line 2372, Patchset 6 (Latest): // * A type of the form T? or FutureOr<T>, for any type T.
Konstantin Shcheglov . unresolved

I think we did not check for this.

File pkg/analyzer/lib/src/dart/resolver/applicable_extensions.dart
Line 188, Patchset 6 (Latest): bool isStatic = false,
Konstantin Shcheglov . unresolved

We use it only for static extensions, so we can simplify this to inlining `true` in the body.

Line 199, Patchset 6 (Latest): _NotInstantiatedExtensionWithMember(
Konstantin Shcheglov . unresolved

I think re-using this class is confusing.

First, the specification says "whose static members include one with the name m". So, we are not looking for both getter and setter, but for one explicitly with this name.

And correspondingly, using `_NotInstantiatedExtensionWithMember` that has two slots is confusing. Add a new one.

And this is still not what the specification says: it also includes constructors. Although maybe this is incomplete implementation :-)

File pkg/analyzer/test/src/dart/resolution/extension_method_test.dart
Line 2909, Patchset 6 (Latest): static int get a => 0;
Konstantin Shcheglov . unresolved

Could you use the name `foo` instead of `a`? I usually prefer it for a single name, with a benefit (in addition being customary) that it is a bit longer and stands out.

Line 2912, Patchset 6 (Latest):f() {
Konstantin Shcheglov . unresolved

`void f()`

Line 2964, Patchset 6 (Latest):enum En { element; }
Konstantin Shcheglov . unresolved

Instead of inventing new name, I often just name these `A`, regardless if it is class, mixing, enum, etc.

Line 3136, Patchset 6 (Latest): test_static_getter_success_onTypedef_noTypeArguments() async {
Konstantin Shcheglov . unresolved

It is not on typedef, because typedefs get erased during building types. It is on class, but `viaTypedef` (search for it in the analyzer tests).

Open in Gerrit

Related details

Attention is currently required from:
  • Chloe Stefantsova
  • Paul Berry
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I6006c86d53e8ca5d20859481e7ab77840a63a1c2
Gerrit-Change-Number: 457024
Gerrit-PatchSet: 6
Gerrit-Owner: Chloe Stefantsova <cstefa...@google.com>
Gerrit-Reviewer: Chloe Stefantsova <cstefa...@google.com>
Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
Gerrit-Reviewer: Paul Berry <paul...@google.com>
Gerrit-Attention: Paul Berry <paul...@google.com>
Gerrit-Attention: Chloe Stefantsova <cstefa...@google.com>
Gerrit-Comment-Date: Tue, 28 Oct 2025 16:23:25 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Chloe Stefantsova (Gerrit)

unread,
Oct 29, 2025, 10:48:55 AM (5 days ago) Oct 29
to Chloe Stefantsova, Paul Berry, Konstantin Shcheglov, Commit Queue, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Konstantin Shcheglov and Paul Berry

Chloe Stefantsova added 14 comments

Patchset-level comments
File-level comment, Patchset 10 (Latest):
Chloe Stefantsova . resolved

Thank you for another round of suggestions, Konstantin. They are really helpful. I've updated the CL accordingly. PTAL.

File pkg/analyzer/lib/src/dart/element/element.dart
Line 2334, Patchset 6: /// In case the extension declaration doesn't have an on-time, `null` is
Konstantin Shcheglov . resolved

What is this?

Chloe Stefantsova

I meant to say "on-declaration". Fixed.

Line 2336, Patchset 6: @trackedIncludedInId
Konstantin Shcheglov . resolved

Please read documentation for this annotation.

Here, `onDeclaration` is `trackedIndirectly`, because its value depends only on `extendedType`, which is tracked.

Chloe Stefantsova

Done

Line 2361, Patchset 6: switch (extendedType.element.kind) {
Konstantin Shcheglov . resolved

Lets use type matching, instead of kind matching, i.e. match `case ClassElementImpl()`- this is IMHO more readable.

Chloe Stefantsova

Done

Line 2366, Patchset 6: if (extendedType.isDartAsyncFutureOr) {
Konstantin Shcheglov . resolved

I cannot find a test for this. I wonder how to test it better... Lets add a few element model tests. See `ExtensionElementTest`, add tests line `test_onDeclaration_class`, `test_onDeclaration_mixin`, etc. And one of them covering also ``FutureOr. You will need to update `_Element2Writer` to write this new property. This might affect expectations for a few tests, to update them automatically, see `NodeTextExpectationsCollector.updatingIsEnabled`

Chloe Stefantsova

In case you meant a `FutureOr` test in `pkg/analyzer/test/src/dart/resolution/extension_method_test.dart`, it's called `test_static_getter_failure_onFutureOr`.

As for the tests exposing the `onDeclaration` property in the element text, I've added those as you suggested.

Line 2372, Patchset 6: // * A type of the form T? or FutureOr<T>, for any type T.
Konstantin Shcheglov . resolved

I think we did not check for this.

Chloe Stefantsova

Good catch. I've added the check.

File pkg/analyzer/lib/src/dart/resolver/applicable_extensions.dart
Line 188, Patchset 6: bool isStatic = false,
Konstantin Shcheglov . resolved

We use it only for static extensions, so we can simplify this to inlining `true` in the body.

Chloe Stefantsova

Agreed. I've inlined the parameter and renamed the method into `havingStaticMemberWithName`.

Line 199, Patchset 6: _NotInstantiatedExtensionWithMember(
Konstantin Shcheglov . resolved

I think re-using this class is confusing.

First, the specification says "whose static members include one with the name m". So, we are not looking for both getter and setter, but for one explicitly with this name.

And correspondingly, using `_NotInstantiatedExtensionWithMember` that has two slots is confusing. Add a new one.

And this is still not what the specification says: it also includes constructors. Although maybe this is incomplete implementation :-)

Chloe Stefantsova

I agree. To address the issue I've created a specialized class `_ExtensionWithMemberWithName` for this specific use case. It has only one slot. Additionally, I created some more classes for representing results with exactly one slot: `SimpleNameResolutionResult`, `ExtensionNameResolutionResult`, `SingleExtensionNameResolutionResult`, and `ExtensionNameResolutionError`. They parallel the classes `SimpleResolutionResult`, `ExtensionResolutionResult`, `SingleExtensionResolutionResult`, and `ExtensionResolutionError`.

As for the constructors, they are intentionally excluded from the scope of this CL and from the scope of some of my future CLs due to the specification still being in flux w.r.t. constructors. For now I'm only focusing on getters, setters, and methods. Furthermore, this CL focuses exclusively on getters, and the cases of setters and methods are deliberately omitted as well.

Line 279, Patchset 4: if (extension.extension.extendedType.element == declaration) extension,
Konstantin Shcheglov . resolved

This is not exactly what the specification uses. I see following: "let M be the set containing each accessible extension whose on-declaration is D, and whose static members include one with the name m, or which declares a constructor named C.m."

And there is definition of "on-declaration" somewhere above, with some exceptions. I think we should have `InterfaceElementImpl get onDeclaration` in `ExtensionElementImpl`.

Chloe Stefantsova

Good idea. I've added the getter. I also added more tests to make sure the specified exceptions are covered.

Chloe Stefantsova

Marked as resolved.

File pkg/analyzer/lib/src/dart/resolver/extension_member_resolver.dart
Line 156, Patchset 4: .havingMemberWithBaseName(name, isStatic: true)
Konstantin Shcheglov . resolved

This is not exactly what the specification uses. I see following: "In the case where D does not declare any static members whose basename is the basename of m, and D does not declare any constructors named C.m2 where m2 is the basename of m, let M be the set containing each accessible extension whose on-declaration is D, and whose static members include one with the name m, or which declares a constructor named C.m."

Note, it says "with the name m", not `m2` or "basename of m".

I think we implementation would be most clear, if we followed the specification as close as possible. Naming the same `M` is of course not necessary, but semantically it should be what the specification says. Otherwise later it would be very hard to match the code and the specification.

We can freely add new classes as we need to express this new semantics, we don't have to fit into existing classes, if it does not fit :-)

Chloe Stefantsova

It makes sense. I've updated the code to reflect the difference between the name and the basename of a member.

Chloe Stefantsova

Marked as resolved.

File pkg/analyzer/test/src/dart/resolution/extension_method_test.dart
Line 2909, Patchset 6: static int get a => 0;
Konstantin Shcheglov . resolved

Could you use the name `foo` instead of `a`? I usually prefer it for a single name, with a benefit (in addition being customary) that it is a bit longer and stands out.

Chloe Stefantsova

Done

Line 2912, Patchset 6:f() {
Konstantin Shcheglov . resolved

`void f()`

Chloe Stefantsova

Done

Line 2964, Patchset 6:enum En { element; }
Konstantin Shcheglov . resolved

Instead of inventing new name, I often just name these `A`, regardless if it is class, mixing, enum, etc.

Chloe Stefantsova

Done

Line 3136, Patchset 6: test_static_getter_success_onTypedef_noTypeArguments() async {
Konstantin Shcheglov . resolved

It is not on typedef, because typedefs get erased during building types. It is on class, but `viaTypedef` (search for it in the analyzer tests).

Chloe Stefantsova

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Konstantin Shcheglov
  • Paul Berry
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I6006c86d53e8ca5d20859481e7ab77840a63a1c2
Gerrit-Change-Number: 457024
Gerrit-PatchSet: 10
Gerrit-Owner: Chloe Stefantsova <cstefa...@google.com>
Gerrit-Reviewer: Chloe Stefantsova <cstefa...@google.com>
Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
Gerrit-Reviewer: Paul Berry <paul...@google.com>
Gerrit-Attention: Paul Berry <paul...@google.com>
Gerrit-Attention: Konstantin Shcheglov <sche...@google.com>
Gerrit-Comment-Date: Wed, 29 Oct 2025 14:48:48 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Chloe Stefantsova <cstefa...@google.com>
Comment-In-Reply-To: Konstantin Shcheglov <sche...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Konstantin Shcheglov (Gerrit)

unread,
Oct 29, 2025, 1:44:14 PM (5 days ago) Oct 29
to Chloe Stefantsova, Paul Berry, Commit Queue, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Chloe Stefantsova and Paul Berry

Konstantin Shcheglov added 9 comments

File pkg/analyzer/lib/src/dart/element/element.dart
Line 2371, Patchset 10 (Latest): when extendedType.nullabilitySuffix != NullabilitySuffix.question &&
Konstantin Shcheglov . unresolved

This is... not ideal, to repeat this code again and again.
We could pre-filter at the top of the method.

File pkg/analyzer/lib/src/dart/resolver/applicable_extensions.dart
Line 65, Patchset 10 (Latest): final ExecutableElement? memberWithName;
Konstantin Shcheglov . unresolved

Maybe just `member`.

Line 67, Patchset 10 (Latest): _ExtensionWithMemberWithName(this.extension, {required this.memberWithName});
Konstantin Shcheglov . unresolved

Maybe both named, or both unnamed.
I usually prefer named, extra characters don't bother me :-)

Line 247, Patchset 10 (Latest): List<_ExtensionWithMemberWithName> applicableToDeclaration({
Konstantin Shcheglov . unresolved

I wonder how useful it is to have this as a separate method.
We will need something to support completion, so maybe there?
But it all operated private classes, so I'm not sure.

File pkg/analyzer/lib/src/dart/resolver/extension_member_resolver.dart
Line 150, Patchset 10 (Latest): ExtensionNameResolutionResult findExtensionForDeclaration(
Konstantin Shcheglov . unresolved

Saying "Name" here is not very useful, it is alway based on some name.
A more useful name would be IMHO `StaticExtensionResolutionResult`, and correspondingly `findStaticExtension`.

Line 171, Patchset 10 (Latest): memberWithName: extension.memberWithName as InternalExecutableElement,
Konstantin Shcheglov . unresolved

I think it would be better to use a more specific type at the source code instead of casting here. We might avoid the cast at all.

Line 521, Patchset 10 (Latest):enum ExtensionNameResolutionError implements ExtensionNameResolutionResult {
Konstantin Shcheglov . unresolved

Maybe even simplify it to a sealed hierarchy of 3 classes: none, ambiguous, single. We did not have sealed classes when we were working on extensions originally. Now we can do better! :-D

File pkg/analyzer/lib/src/dart/resolver/resolution_result.dart
Line 53, Patchset 10 (Latest):class SimpleNameResolutionResult {
Konstantin Shcheglov . unresolved

If we don't have other uses than for static extensions, I'd prefer that we used the most specific names that reflects this only use for now. This is all non-API, so we will able to rename it in the future if needed.

Line 55, Patchset 10 (Latest): final InternalExecutableElement? memberWithName;
Konstantin Shcheglov . unresolved

I would reduce this name here and everywhere to just `member`.
The fact that it has this name is kind of implied.

Open in Gerrit

Related details

Attention is currently required from:
  • Chloe Stefantsova
  • Paul Berry
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I6006c86d53e8ca5d20859481e7ab77840a63a1c2
Gerrit-Change-Number: 457024
Gerrit-PatchSet: 10
Gerrit-Owner: Chloe Stefantsova <cstefa...@google.com>
Gerrit-Reviewer: Chloe Stefantsova <cstefa...@google.com>
Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
Gerrit-Reviewer: Paul Berry <paul...@google.com>
Gerrit-Attention: Paul Berry <paul...@google.com>
Gerrit-Attention: Chloe Stefantsova <cstefa...@google.com>
Gerrit-Comment-Date: Wed, 29 Oct 2025 17:44:11 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Chloe Stefantsova (Gerrit)

unread,
Oct 30, 2025, 9:23:23 AM (4 days ago) Oct 30
to Chloe Stefantsova, Paul Berry, Konstantin Shcheglov, Commit Queue, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Konstantin Shcheglov and Paul Berry

Chloe Stefantsova added 10 comments

Patchset-level comments
File-level comment, Patchset 13 (Latest):
Chloe Stefantsova . resolved

Thank you so much for another round of suggestions, Konstantin. I've uploaded the patchsets applying them. PTAL.

File pkg/analyzer/lib/src/dart/element/element.dart
Line 2371, Patchset 10: when extendedType.nullabilitySuffix != NullabilitySuffix.question &&
Konstantin Shcheglov . resolved

This is... not ideal, to repeat this code again and again.
We could pre-filter at the top of the method.

Chloe Stefantsova

Done

File pkg/analyzer/lib/src/dart/resolver/applicable_extensions.dart
Line 65, Patchset 10: final ExecutableElement? memberWithName;
Konstantin Shcheglov . resolved

Maybe just `member`.

Chloe Stefantsova

Done

Line 67, Patchset 10: _ExtensionWithMemberWithName(this.extension, {required this.memberWithName});
Konstantin Shcheglov . resolved

Maybe both named, or both unnamed.
I usually prefer named, extra characters don't bother me :-)

Chloe Stefantsova

Done

Line 247, Patchset 10: List<_ExtensionWithMemberWithName> applicableToDeclaration({
Konstantin Shcheglov . resolved

I wonder how useful it is to have this as a separate method.
We will need something to support completion, so maybe there?
But it all operated private classes, so I'm not sure.

Chloe Stefantsova

Inlined.

File pkg/analyzer/lib/src/dart/resolver/extension_member_resolver.dart
Line 150, Patchset 10: ExtensionNameResolutionResult findExtensionForDeclaration(
Konstantin Shcheglov . resolved

Saying "Name" here is not very useful, it is alway based on some name.
A more useful name would be IMHO `StaticExtensionResolutionResult`, and correspondingly `findStaticExtension`.

Chloe Stefantsova

Done

Line 171, Patchset 10: memberWithName: extension.memberWithName as InternalExecutableElement,
Konstantin Shcheglov . resolved

I think it would be better to use a more specific type at the source code instead of casting here. We might avoid the cast at all.

Chloe Stefantsova

To address that, I used a more specific type at the source. But it lead to three more casts in other places. Specifically in `pkg/analyzer/lib/src/dart/resolver/applicable_extensions.dart` in method `havingStaticMemberWithName`: `getter as GetterElementImpl`, `setter as SetterElementImpl`, and `method as MethodElementImpl`. You can see it in the latest patchset. I'll leave it up to you to decide which casts you'd prefer.

Line 521, Patchset 10:enum ExtensionNameResolutionError implements ExtensionNameResolutionResult {
Konstantin Shcheglov . resolved

Maybe even simplify it to a sealed hierarchy of 3 classes: none, ambiguous, single. We did not have sealed classes when we were working on extensions originally. Now we can do better! :-D

Chloe Stefantsova

Done

File pkg/analyzer/lib/src/dart/resolver/resolution_result.dart
Line 53, Patchset 10:class SimpleNameResolutionResult {
Konstantin Shcheglov . resolved

If we don't have other uses than for static extensions, I'd prefer that we used the most specific names that reflects this only use for now. This is all non-API, so we will able to rename it in the future if needed.

Chloe Stefantsova

Renamed to `SimpleStaticExtensionResolutionResult`.

Line 55, Patchset 10: final InternalExecutableElement? memberWithName;
Konstantin Shcheglov . resolved

I would reduce this name here and everywhere to just `member`.
The fact that it has this name is kind of implied.

Chloe Stefantsova

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Konstantin Shcheglov
  • Paul Berry
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I6006c86d53e8ca5d20859481e7ab77840a63a1c2
Gerrit-Change-Number: 457024
Gerrit-PatchSet: 13
Gerrit-Owner: Chloe Stefantsova <cstefa...@google.com>
Gerrit-Reviewer: Chloe Stefantsova <cstefa...@google.com>
Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
Gerrit-Reviewer: Paul Berry <paul...@google.com>
Gerrit-Attention: Paul Berry <paul...@google.com>
Gerrit-Attention: Konstantin Shcheglov <sche...@google.com>
Gerrit-Comment-Date: Thu, 30 Oct 2025 13:23:14 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Konstantin Shcheglov <sche...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Konstantin Shcheglov (Gerrit)

unread,
Oct 30, 2025, 12:09:33 PM (4 days ago) Oct 30
to Chloe Stefantsova, Paul Berry, Commit Queue, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Chloe Stefantsova and Paul Berry

Konstantin Shcheglov voted and added 1 comment

Votes added by Konstantin Shcheglov

Code-Review+1

1 comment

File pkg/analyzer/lib/src/dart/resolver/extension_member_resolver.dart
Line 566, Patchset 13 (Latest):class SingleExtensionNameResolutionResult
Konstantin Shcheglov . unresolved

Would be nice to fit "static" word into here as well.

Open in Gerrit

Related details

Attention is currently required from:
  • Chloe Stefantsova
  • Paul Berry
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I6006c86d53e8ca5d20859481e7ab77840a63a1c2
Gerrit-Change-Number: 457024
Gerrit-PatchSet: 13
Gerrit-Owner: Chloe Stefantsova <cstefa...@google.com>
Gerrit-Reviewer: Chloe Stefantsova <cstefa...@google.com>
Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
Gerrit-Reviewer: Paul Berry <paul...@google.com>
Gerrit-Attention: Paul Berry <paul...@google.com>
Gerrit-Attention: Chloe Stefantsova <cstefa...@google.com>
Gerrit-Comment-Date: Thu, 30 Oct 2025 16:09:30 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
open
diffy

Chloe Stefantsova (Gerrit)

unread,
Oct 31, 2025, 3:04:12 AM (3 days ago) Oct 31
to Chloe Stefantsova, Konstantin Shcheglov, Paul Berry, Commit Queue, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Paul Berry

Chloe Stefantsova voted and added 2 comments

Votes added by Chloe Stefantsova

Commit-Queue+2

2 comments

Patchset-level comments
File-level comment, Patchset 15 (Latest):
Chloe Stefantsova . resolved

Thank you for the review, Konstantin!

File pkg/analyzer/lib/src/dart/resolver/extension_member_resolver.dart
Line 566, Patchset 13:class SingleExtensionNameResolutionResult
Konstantin Shcheglov . resolved

Would be nice to fit "static" word into here as well.

Chloe Stefantsova

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Paul Berry
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I6006c86d53e8ca5d20859481e7ab77840a63a1c2
Gerrit-Change-Number: 457024
Gerrit-PatchSet: 15
Gerrit-Owner: Chloe Stefantsova <cstefa...@google.com>
Gerrit-Reviewer: Chloe Stefantsova <cstefa...@google.com>
Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
Gerrit-Reviewer: Paul Berry <paul...@google.com>
Gerrit-Attention: Paul Berry <paul...@google.com>
Gerrit-Comment-Date: Fri, 31 Oct 2025 07:04:05 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Konstantin Shcheglov <sche...@google.com>
satisfied_requirement
open
diffy

Commit Queue (Gerrit)

unread,
Oct 31, 2025, 3:35:36 AM (3 days ago) Oct 31
to Chloe Stefantsova, Konstantin Shcheglov, Paul Berry, dart-analys...@google.com, rev...@dartlang.org

Commit Queue submitted the change with unreviewed changes

Unreviewed changes

13 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:

```
The name of the file: pkg/analyzer/lib/src/dart/resolver/extension_member_resolver.dart
Insertions: 15, Deletions: 15.

The diff is too large to show. Please review the diff.
```

Change information

Commit message:
[analyzer] Implement static extension getters

This CL adds support for static extension getters in the CFE. The
feature is observable under the `static-extensions` experimental
feature flag. Only the positive support is added; the diagnostics will
be added in follow-up CLs.

Part of https://github.com/dart-lang/sdk/issues/61487
Change-Id: I6006c86d53e8ca5d20859481e7ab77840a63a1c2
Reviewed-by: Konstantin Shcheglov <sche...@google.com>
Commit-Queue: Chloe Stefantsova <cstefa...@google.com>
Files:
  • M pkg/analyzer/lib/src/dart/element/element.dart
  • M pkg/analyzer/lib/src/dart/resolver/applicable_extensions.dart
  • M pkg/analyzer/lib/src/dart/resolver/extension_member_resolver.dart
  • M pkg/analyzer/lib/src/dart/resolver/property_element_resolver.dart
  • M pkg/analyzer/lib/src/dart/resolver/resolution_result.dart
  • M pkg/analyzer/lib/src/dart/resolver/type_property_resolver.dart
  • M pkg/analyzer/test/src/dart/resolution/extension_method_test.dart
  • M pkg/analyzer/test/src/summary/element_text.dart
  • M pkg/analyzer/test/src/summary/elements/const_test.dart
  • M pkg/analyzer/test/src/summary/elements/default_value_test.dart
  • M pkg/analyzer/test/src/summary/elements/duplicate_declaration_test.dart
  • M pkg/analyzer/test/src/summary/elements/extension_test.dart
  • M pkg/analyzer/test/src/summary/elements/metadata_test.dart
  • M pkg/analyzer/test/src/summary/elements/offsets_test.dart
  • M pkg/analyzer/test/src/summary/elements/record_type_test.dart
  • M pkg/analyzer/test/src/summary/elements/since_sdk_version_test.dart
  • M pkg/analyzer/test/src/summary/elements/top_level_variable_test.dart
  • M pkg/analyzer/test/src/summary/elements/type_inference_test.dart
Change size: XL
Delta: 18 files changed, 1109 insertions(+), 1 deletion(-)
Branch: refs/heads/main
Submit Requirements:
  • requirement satisfiedCode-Review: +1 by Konstantin Shcheglov
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I6006c86d53e8ca5d20859481e7ab77840a63a1c2
Gerrit-Change-Number: 457024
Gerrit-PatchSet: 16
Gerrit-Owner: Chloe Stefantsova <cstefa...@google.com>
Gerrit-Reviewer: Chloe Stefantsova <cstefa...@google.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages