[L] Change in dart/sdk[main]: Add a lint to flag local variables created to promote `this`.

1 view
Skip to first unread message

Brian Wilkerson (Gerrit)

unread,
Jul 24, 2026, 9:38:38 AM (13 days ago) Jul 24
to Brian Wilkerson, Paul Berry, dart-...@luci-project-accounts.iam.gserviceaccount.com, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Paul Berry

New activity on the change

Open in Gerrit

Related details

Attention is currently required from:
  • 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: I21d1156e7d54a0944a7e3b1982b9fb54cc3d9032
Gerrit-Change-Number: 527400
Gerrit-PatchSet: 2
Gerrit-Owner: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Paul Berry <paul...@google.com>
Gerrit-Attention: Paul Berry <paul...@google.com>
Gerrit-Comment-Date: Fri, 24 Jul 2026 13:38:33 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Paul Berry (Gerrit)

unread,
Jul 27, 2026, 2:00:24 PM (10 days ago) Jul 27
to Brian Wilkerson, dart-...@luci-project-accounts.iam.gserviceaccount.com, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Brian Wilkerson

Paul Berry voted and added 2 comments

Votes added by Paul Berry

Code-Review+1

2 comments

Patchset-level comments
File pkg/linter/lib/src/rules/unnecessary_this_alias.dart
Line 63, Patchset 2 (Latest): IsExpression(:var expression) => expression == expr,
Paul Berry . unresolved

I thought of a few other expressions that can promote too:

  • `self?.property` (e.g., `self?.x = self.y`)
  • `self?.method(...)` (e.g., `self?.f(self.x)`)
  • `self?[...]` (e.g., `self?[self.x]` or `self?[self.x] = self.y`
  • `self?..cascadeSections`
  • Anonymous method syntax (assuming anonymous methods are enabled): `self.{...}`, `self.(...) {...}`, `self.=> ...`, `self.(...) => ...`
  • `self ?? ...` (e.g., `self ?? (throw ...)` promotes `self` to non-nullable in the code that follows)

Not sure how important it is to detect all of these (the `self ?? (throw ...)` case is particularly obscure), so your call whether to add more checks.

Open in Gerrit

Related details

Attention is currently required from:
  • Brian Wilkerson
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: I21d1156e7d54a0944a7e3b1982b9fb54cc3d9032
Gerrit-Change-Number: 527400
Gerrit-PatchSet: 2
Gerrit-Owner: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Paul Berry <paul...@google.com>
Gerrit-Attention: Brian Wilkerson <brianwi...@google.com>
Gerrit-Comment-Date: Mon, 27 Jul 2026 18:00:21 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
open
diffy

Brian Wilkerson (Gerrit)

unread,
Jul 27, 2026, 2:08:14 PM (10 days ago) Jul 27
to Brian Wilkerson, Paul Berry, dart-...@luci-project-accounts.iam.gserviceaccount.com, dart-analys...@google.com, rev...@dartlang.org

Brian Wilkerson 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: I21d1156e7d54a0944a7e3b1982b9fb54cc3d9032
Gerrit-Change-Number: 527400
Gerrit-PatchSet: 2
Gerrit-Owner: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Paul Berry <paul...@google.com>
Gerrit-Comment-Date: Mon, 27 Jul 2026 18:08:10 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
open
diffy

dart-scoped@luci-project-accounts.iam.gserviceaccount.com (Gerrit)

unread,
Jul 27, 2026, 2:41:08 PM (10 days ago) Jul 27
to Brian Wilkerson, Paul Berry, dart-analys...@google.com, rev...@dartlang.org

dart-...@luci-project-accounts.iam.gserviceaccount.com submitted the change

Change information

Commit message:
Add a lint to flag local variables created to promote `this`.

I think this covers the behavior outlined in the doc, but please check
to see whether I missed any cases that either should or shouldn't be
reported.
Change-Id: I21d1156e7d54a0944a7e3b1982b9fb54cc3d9032
Commit-Queue: Brian Wilkerson <brianwi...@google.com>
Reviewed-by: Paul Berry <paul...@google.com>
Files:
  • M pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml
  • M pkg/linter/lib/src/diagnostic.g.dart
  • M pkg/linter/lib/src/lint_names.g.dart
  • M pkg/linter/lib/src/rules.dart
  • A pkg/linter/lib/src/rules/unnecessary_this_alias.dart
  • M pkg/linter/messages.yaml
  • M pkg/linter/test/rules/all.dart
  • A pkg/linter/test/rules/unnecessary_this_alias_test.dart
Change size: L
Delta: 8 files changed, 468 insertions(+), 0 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: I21d1156e7d54a0944a7e3b1982b9fb54cc3d9032
Gerrit-Change-Number: 527400
Gerrit-PatchSet: 3
Gerrit-Owner: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Paul Berry <paul...@google.com>
open
diffy
satisfied_requirement

Brian Wilkerson (Gerrit)

unread,
Aug 5, 2026, 7:53:40 PM (8 hours ago) Aug 5
to Brian Wilkerson, dart-...@luci-project-accounts.iam.gserviceaccount.com, Paul Berry, dart-analys...@google.com, rev...@dartlang.org

Brian Wilkerson added 1 comment

File pkg/linter/lib/src/rules/unnecessary_this_alias.dart
Line 63, Patchset 2: IsExpression(:var expression) => expression == expr,
Paul Berry . resolved

I thought of a few other expressions that can promote too:

  • `self?.property` (e.g., `self?.x = self.y`)
  • `self?.method(...)` (e.g., `self?.f(self.x)`)
  • `self?[...]` (e.g., `self?[self.x]` or `self?[self.x] = self.y`
  • `self?..cascadeSections`
  • Anonymous method syntax (assuming anonymous methods are enabled): `self.{...}`, `self.(...) {...}`, `self.=> ...`, `self.(...) => ...`
  • `self ?? ...` (e.g., `self ?? (throw ...)` promotes `self` to non-nullable in the code that follows)

Not sure how important it is to detect all of these (the `self ?? (throw ...)` case is particularly obscure), so your call whether to add more checks.

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: I21d1156e7d54a0944a7e3b1982b9fb54cc3d9032
Gerrit-Change-Number: 527400
Gerrit-PatchSet: 3
Gerrit-Owner: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Paul Berry <paul...@google.com>
Gerrit-Comment-Date: Wed, 05 Aug 2026 23:53:37 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Paul Berry <paul...@google.com>
satisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages