[L] Change in dart/sdk[main]: [analyzer] Dot shorthands: Remove error when a constructor conflicts ...

0 views
Skip to first unread message

Kallen Tu (Gerrit)

unread,
Dec 10, 2025, 3:32:32 PM12/10/25
to Paul Berry, Commit Queue, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Paul Berry

Kallen Tu added 1 comment

Patchset-level comments
File-level comment, Patchset 7:
Kallen Tu . resolved

PTAL. I tried to be thorough with thinking through the testing for this. LMK if you see any gaps. We'll be hotfixing this into stable.

Open in Gerrit

Related details

Attention is currently required from:
  • Paul Berry
Submit Requirements:
  • requirement is not 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: Icc6b66a95cfc79312891453b6f277f1347e059bc
Gerrit-Change-Number: 467261
Gerrit-PatchSet: 9
Gerrit-Owner: Kallen Tu <kall...@google.com>
Gerrit-Reviewer: Kallen Tu <kall...@google.com>
Gerrit-Reviewer: Paul Berry <paul...@google.com>
Gerrit-Attention: Paul Berry <paul...@google.com>
Gerrit-Comment-Date: Wed, 10 Dec 2025 20:32:29 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
unsatisfied_requirement
open
diffy

Paul Berry (Gerrit)

unread,
Dec 10, 2025, 6:55:36 PM12/10/25
to Kallen Tu, Commit Queue, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Kallen Tu

Paul Berry voted and added 1 comment

Votes added by Paul Berry

Code-Review+1

1 comment

Patchset-level comments
Open in Gerrit

Related details

Attention is currently required from:
  • Kallen Tu
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: Icc6b66a95cfc79312891453b6f277f1347e059bc
Gerrit-Change-Number: 467261
Gerrit-PatchSet: 9
Gerrit-Owner: Kallen Tu <kall...@google.com>
Gerrit-Reviewer: Kallen Tu <kall...@google.com>
Gerrit-Reviewer: Paul Berry <paul...@google.com>
Gerrit-Attention: Kallen Tu <kall...@google.com>
Gerrit-Comment-Date: Wed, 10 Dec 2025 23:55:33 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
open
diffy

Kallen Tu (Gerrit)

unread,
Dec 11, 2025, 12:29:30 PM12/11/25
to Paul Berry, Commit Queue, dart-analys...@google.com, rev...@dartlang.org

Kallen Tu voted Commit-Queue+2

Commit-Queue+2
Open in Gerrit

Related details

Attention set is empty
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: Icc6b66a95cfc79312891453b6f277f1347e059bc
Gerrit-Change-Number: 467261
Gerrit-PatchSet: 9
Gerrit-Owner: Kallen Tu <kall...@google.com>
Gerrit-Reviewer: Kallen Tu <kall...@google.com>
Gerrit-Reviewer: Paul Berry <paul...@google.com>
Gerrit-Comment-Date: Thu, 11 Dec 2025 17:29:27 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
open
diffy

Commit Queue (Gerrit)

unread,
Dec 11, 2025, 12:29:44 PM12/11/25
to Kallen Tu, Paul Berry, dart-analys...@google.com, rev...@dartlang.org

Commit Queue submitted the change

Change information

Commit message:
[analyzer] Dot shorthands: Remove error when a constructor conflicts with a non-static member.

Users are getting an extra error when a constructor and an instance method/getter have the same name.
In the implementation, we produce an error once we see that the retrieved dot shorthand element isn't static. Instead, we should be falling through to check for constructor elements of that name.

This CL makes the necessary changes.

Testing:
`element != null && element is InternalExecutableElement && element.isStatic` is tested by existing tests.

`element != null && element is InternalExecutableElement && !element.isStatic` is tested in the `test_conflict_instance_*` unit tests. This is the behavior with the bug.

`element != null && element is! InternalExecutableElement` should not
exist since the `_resolveElement only returns `ExecutableElement`s or
`null`. (There's definitely something we can refactor here, but I'll leave it for a future CL.)

If we can't find a static method/field of that name, we should be
checking if it's the name of a constructor for both of the above cases.

`element == null` occurs when we can't find any method/getter of a given
name. If there's a setter of the given name, this will be `true` as well. This is well tested by prior unit tests.
Change-Id: Icc6b66a95cfc79312891453b6f277f1347e059bc
Commit-Queue: Kallen Tu <kall...@google.com>
Reviewed-by: Paul Berry <paul...@google.com>
Files:
  • M pkg/analyzer/lib/src/dart/resolver/method_invocation_resolver.dart
  • M pkg/analyzer/test/src/dart/resolution/dot_shorthand_constructor_invocation_test.dart
  • A tests/language/dot_shorthands/constructor/constructor_name_conflict_test.dart
  • M tests/language/dot_shorthands/constructor/constructor_test.dart
Change size: L
Delta: 4 files changed, 216 insertions(+), 37 deletions(-)
Branch: refs/heads/main
Submit Requirements:
  • requirement satisfiedCode-Review: +1 by Paul Berry
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: Icc6b66a95cfc79312891453b6f277f1347e059bc
Gerrit-Change-Number: 467261
Gerrit-PatchSet: 10
Gerrit-Owner: Kallen Tu <kall...@google.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages