[L] Change in dart/sdk[main]: Add a refactor to remove a name from a constructor

0 views
Skip to first unread message

Brian Wilkerson (Gerrit)

unread,
Mar 27, 2026, 5:19:18 PM (3 days ago) Mar 27
to Brian Wilkerson, Samuel Rawlins, Commit Queue, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Samuel Rawlins

New activity on the change

Open in Gerrit

Related details

Attention is currently required from:
  • Samuel Rawlins
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: I067f7f98eee6080f7b15d79b52f1d0adad0a77e0
Gerrit-Change-Number: 490941
Gerrit-PatchSet: 3
Gerrit-Owner: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
Gerrit-Comment-Date: Fri, 27 Mar 2026 21:19:15 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Danny Tuppeny (Gerrit)

unread,
Mar 29, 2026, 7:56:56 AM (yesterday) Mar 29
to Brian Wilkerson, Samuel Rawlins, Commit Queue, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Brian Wilkerson and Samuel Rawlins

Danny Tuppeny added 6 comments

Patchset-level comments
File-level comment, Patchset 4 (Latest):
Danny Tuppeny . resolved

Some drive-by nits :-)

File pkg/analysis_server/test/lsp/request_helpers_mixin.dart
Line 933, Patchset 4 (Latest): Future<ResponseMessage> sendExecuteCommand(
Danny Tuppeny . unresolved

I think this is unused now

File pkg/analysis_server/test/lsp/server_abstract.dart
Line 1443, Patchset 4 (Latest): Future<ResponseMessage> sendExecuteCommand(
Danny Tuppeny . unresolved

I think this is unused now

File pkg/analysis_server/test/src/services/refactoring/remove_constructor_name_test.dart
Line 32, Patchset 4 (Latest):void f() {
C();
}
Danny Tuppeny . unresolved

I think this code probably isn't necessary in the failure cases?

Line 66, Patchset 4 (Latest): C.name();
Danny Tuppeny . unresolved

Is there value in testing a tear-off too?

Line 466, Patchset 4 (Latest): String? failureMessage,
Danny Tuppeny . unresolved

It doesn't look like anything passes this - should it? (or should we add a default `= "There's already a default constructor."`? Since this message us shown to the user, it might be worth validating.

Open in Gerrit

Related details

Attention is currently required from:
  • Brian Wilkerson
  • Samuel Rawlins
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: I067f7f98eee6080f7b15d79b52f1d0adad0a77e0
Gerrit-Change-Number: 490941
Gerrit-PatchSet: 4
Gerrit-Owner: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
Gerrit-CC: Danny Tuppeny <da...@tuppeny.com>
Gerrit-Attention: Brian Wilkerson <brianwi...@google.com>
Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
Gerrit-Comment-Date: Sun, 29 Mar 2026 11:56:52 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Brian Wilkerson (Gerrit)

unread,
Mar 29, 2026, 11:56:31 AM (yesterday) Mar 29
to Brian Wilkerson, Danny Tuppeny, Samuel Rawlins, Commit Queue, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Danny Tuppeny and Samuel Rawlins

Brian Wilkerson voted and added 6 comments

Votes added by Brian Wilkerson

Commit-Queue+1

6 comments

Patchset-level comments
File-level comment, Patchset 4:
Brian Wilkerson . resolved

Thanks for he review.

File pkg/analysis_server/test/lsp/request_helpers_mixin.dart
Line 933, Patchset 4: Future<ResponseMessage> sendExecuteCommand(
Danny Tuppeny . resolved

I think this is unused now

Brian Wilkerson

Done

File pkg/analysis_server/test/lsp/server_abstract.dart
Line 1443, Patchset 4: Future<ResponseMessage> sendExecuteCommand(
Danny Tuppeny . resolved

I think this is unused now

Brian Wilkerson

Done

File pkg/analysis_server/test/src/services/refactoring/remove_constructor_name_test.dart
Line 32, Patchset 4:void f() {
C();
}
Danny Tuppeny . resolved

I think this code probably isn't necessary in the failure cases?

Brian Wilkerson

Done

Line 66, Patchset 4: C.name();
Danny Tuppeny . resolved

Is there value in testing a tear-off too?

Brian Wilkerson

Yes, thanks for catching that.

Line 466, Patchset 4: String? failureMessage,
Danny Tuppeny . unresolved

It doesn't look like anything passes this - should it? (or should we add a default `= "There's already a default constructor."`? Since this message us shown to the user, it might be worth validating.

Brian Wilkerson

Given that this is local to this test, I agree that we don't need to pass in a value. I've just hardcoded the expected value below.

Open in Gerrit

Related details

Attention is currently required from:
  • Danny Tuppeny
  • Samuel Rawlins
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: I067f7f98eee6080f7b15d79b52f1d0adad0a77e0
Gerrit-Change-Number: 490941
Gerrit-PatchSet: 5
Gerrit-Owner: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
Gerrit-CC: Danny Tuppeny <da...@tuppeny.com>
Gerrit-Attention: Danny Tuppeny <da...@tuppeny.com>
Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
Gerrit-Comment-Date: Sun, 29 Mar 2026 15:56:28 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Danny Tuppeny <da...@tuppeny.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Danny Tuppeny (Gerrit)

unread,
Mar 29, 2026, 12:11:48 PM (yesterday) Mar 29
to Brian Wilkerson, Samuel Rawlins, Commit Queue, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Brian Wilkerson and Samuel Rawlins

Danny Tuppeny added 1 comment

File pkg/analysis_server/test/src/services/refactoring/remove_constructor_name_test.dart
Line 466, Patchset 4: String? failureMessage,
Danny Tuppeny . resolved

It doesn't look like anything passes this - should it? (or should we add a default `= "There's already a default constructor."`? Since this message us shown to the user, it might be worth validating.

Brian Wilkerson

Given that this is local to this test, I agree that we don't need to pass in a value. I've just hardcoded the expected value below.

Danny Tuppeny

yeah, that makes more sense if there aren't other cases to test. Thanks!

Open in Gerrit

Related details

Attention is currently required from:
  • Brian Wilkerson
  • Samuel Rawlins
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: I067f7f98eee6080f7b15d79b52f1d0adad0a77e0
Gerrit-Change-Number: 490941
Gerrit-PatchSet: 5
Gerrit-Owner: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
Gerrit-CC: Danny Tuppeny <da...@tuppeny.com>
Gerrit-Attention: Brian Wilkerson <brianwi...@google.com>
Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
Gerrit-Comment-Date: Sun, 29 Mar 2026 16:11:44 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Brian Wilkerson <brianwi...@google.com>
Comment-In-Reply-To: Danny Tuppeny <da...@tuppeny.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Samuel Rawlins (Gerrit)

unread,
Mar 29, 2026, 4:56:42 PM (yesterday) Mar 29
to Brian Wilkerson, Danny Tuppeny, Commit Queue, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Brian Wilkerson

Samuel Rawlins voted and added 2 comments

Votes added by Samuel Rawlins

Code-Review+1

2 comments

Patchset-level comments
File-level comment, Patchset 5 (Latest):
Samuel Rawlins . resolved

Tests look very complete, thanks!

File pkg/analysis_server/lib/src/services/refactoring/remove_constructor_name.dart
Line 46, Patchset 5 (Latest): reason: "There's already a default constructor.",
Samuel Rawlins . unresolved

Should this say "unnamed constructor"? We don't know if there is a default constructor (an implicitly defined unnamed, zero-parameter constructor).

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: I067f7f98eee6080f7b15d79b52f1d0adad0a77e0
Gerrit-Change-Number: 490941
Gerrit-PatchSet: 5
Gerrit-Owner: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
Gerrit-CC: Danny Tuppeny <da...@tuppeny.com>
Gerrit-Attention: Brian Wilkerson <brianwi...@google.com>
Gerrit-Comment-Date: Sun, 29 Mar 2026 20:56:39 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
open
diffy

Brian Wilkerson (Gerrit)

unread,
Mar 29, 2026, 7:59:27 PM (yesterday) Mar 29
to Brian Wilkerson, Samuel Rawlins, Danny Tuppeny, Commit Queue, dart-analys...@google.com, rev...@dartlang.org

Brian Wilkerson voted and added 1 comment

Votes added by Brian Wilkerson

Commit-Queue+2

1 comment

File pkg/analysis_server/lib/src/services/refactoring/remove_constructor_name.dart
Line 46, Patchset 5: reason: "There's already a default constructor.",
Samuel Rawlins . resolved

Should this say "unnamed constructor"? We don't know if there is a default constructor (an implicitly defined unnamed, zero-parameter constructor).

Brian Wilkerson

Yes, that's more accurate. Thanks and done.

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: I067f7f98eee6080f7b15d79b52f1d0adad0a77e0
Gerrit-Change-Number: 490941
Gerrit-PatchSet: 6
Gerrit-Owner: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
Gerrit-CC: Danny Tuppeny <da...@tuppeny.com>
Gerrit-Comment-Date: Sun, 29 Mar 2026 23:59:24 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Samuel Rawlins <sraw...@google.com>
satisfied_requirement
open
diffy

Commit Queue (Gerrit)

unread,
Mar 29, 2026, 8:22:05 PM (yesterday) Mar 29
to Brian Wilkerson, Samuel Rawlins, Danny Tuppeny, dart-analys...@google.com, rev...@dartlang.org

Commit Queue submitted the change with unreviewed changes

Unreviewed changes

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

```
The name of the file: pkg/analysis_server/test/src/services/refactoring/remove_constructor_name_test.dart
Insertions: 1, Deletions: 1.

@@ -463,7 +463,7 @@
throwsA(
isResponseError(
ServerErrorCodes.refactoringComputeStatusFailure,
- message: "There's already a default constructor.",
+ message: "There's already an unnamed constructor.",
),
),
);
```
```
The name of the file: pkg/analysis_server/lib/src/services/refactoring/remove_constructor_name.dart
Insertions: 1, Deletions: 1.

@@ -43,7 +43,7 @@
for (var constructor in element.enclosingElement.constructors) {
if (constructor.name == 'new' || constructor.name == null) {
return ComputeStatusFailure(
- reason: "There's already a default constructor.",
+ reason: "There's already an unnamed constructor.",
);
}
}
```

Change information

Commit message:
Add a refactor to remove a name from a constructor
Change-Id: I067f7f98eee6080f7b15d79b52f1d0adad0a77e0
Commit-Queue: Brian Wilkerson <brianwi...@google.com>
Reviewed-by: Samuel Rawlins <sraw...@google.com>
Files:
  • M pkg/analysis_server/lib/src/services/refactoring/framework/refactoring_processor.dart
  • A pkg/analysis_server/lib/src/services/refactoring/remove_constructor_name.dart
  • A pkg/analysis_server/test/src/services/refactoring/remove_constructor_name_test.dart
  • M pkg/analysis_server/test/src/services/refactoring/test_all.dart
Change size: L
Delta: 4 files changed, 558 insertions(+), 0 deletions(-)
Branch: refs/heads/main
Submit Requirements:
  • requirement satisfiedCode-Review: +1 by Samuel Rawlins
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: I067f7f98eee6080f7b15d79b52f1d0adad0a77e0
Gerrit-Change-Number: 490941
Gerrit-PatchSet: 7
Gerrit-Owner: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
Gerrit-CC: Danny Tuppeny <da...@tuppeny.com>
open
diffy
satisfied_requirement

Danny Tuppeny (Gerrit)

unread,
7:29 AM (13 hours ago) 7:29 AM
to Brian Wilkerson, Commit Queue, Samuel Rawlins, dart-analys...@google.com, rev...@dartlang.org

Danny Tuppeny added 1 comment

File pkg/analysis_server/lib/src/services/refactoring/remove_constructor_name.dart
Line 46, Patchset 5: reason: "There's already a default constructor.",
Samuel Rawlins . resolved

Should this say "unnamed constructor"? We don't know if there is a default constructor (an implicitly defined unnamed, zero-parameter constructor).

Brian Wilkerson

Yes, that's more accurate. Thanks and done.

Danny Tuppeny

It might be useful to have a glossary somewhere describing some of these terms, because I've probably also used these interchangeably (I got the impression we were avoiding using "unnamed constructor" and I probably assumed "default" was an appropriate name for this and probably would've called the other one an "implicit constructor").

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: I067f7f98eee6080f7b15d79b52f1d0adad0a77e0
Gerrit-Change-Number: 490941
Gerrit-PatchSet: 7
Gerrit-Owner: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
Gerrit-CC: Danny Tuppeny <da...@tuppeny.com>
Gerrit-Comment-Date: Mon, 30 Mar 2026 11:29:05 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Brian Wilkerson <brianwi...@google.com>
Comment-In-Reply-To: Samuel Rawlins <sraw...@google.com>
satisfied_requirement
open
diffy

Brian Wilkerson (Gerrit)

unread,
10:46 AM (10 hours ago) 10:46 AM
to Brian Wilkerson, Commit Queue, Samuel Rawlins, Danny Tuppeny, dart-analys...@google.com, rev...@dartlang.org

Brian Wilkerson added 1 comment

File pkg/analysis_server/lib/src/services/refactoring/remove_constructor_name.dart
Line 46, Patchset 5: reason: "There's already a default constructor.",
Samuel Rawlins . resolved

Should this say "unnamed constructor"? We don't know if there is a default constructor (an implicitly defined unnamed, zero-parameter constructor).

Brian Wilkerson

Yes, that's more accurate. Thanks and done.

Danny Tuppeny

It might be useful to have a glossary somewhere describing some of these terms, because I've probably also used these interchangeably (I got the impression we were avoiding using "unnamed constructor" and I probably assumed "default" was an appropriate name for this and probably would've called the other one an "implicit constructor").

Brian Wilkerson

We have a glossary (https://dart.dev/resources/glossary) but it doesn't contain either of these terms.

The diagnostic messages appear to be consistent in their use of 'unnamed' to mean a constructor that doesn't have a name, but are inconsistent with the use of 'default' to sometimes mean the synthetic constructor defined when there is no explicit constructor and sometimes to mean an unnamed zero parameter constructor.

I think we should be consistent with the spec, which uses 'default' for the synthetic constructor, 'unnamed' for a constructor that has no name, and doesn't have a term for a zero parameter constructor.

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: I067f7f98eee6080f7b15d79b52f1d0adad0a77e0
Gerrit-Change-Number: 490941
Gerrit-PatchSet: 7
Gerrit-Owner: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
Gerrit-CC: Danny Tuppeny <da...@tuppeny.com>
Gerrit-Comment-Date: Mon, 30 Mar 2026 14:46:47 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Brian Wilkerson <brianwi...@google.com>
Comment-In-Reply-To: Danny Tuppeny <da...@tuppeny.com>
Comment-In-Reply-To: Samuel Rawlins <sraw...@google.com>
satisfied_requirement
open
diffy

Danny Tuppeny (Gerrit)

unread,
10:54 AM (10 hours ago) 10:54 AM
to Brian Wilkerson, Commit Queue, Samuel Rawlins, dart-analys...@google.com, rev...@dartlang.org

Danny Tuppeny added 1 comment

File pkg/analysis_server/lib/src/services/refactoring/remove_constructor_name.dart
Line 46, Patchset 5: reason: "There's already a default constructor.",
Samuel Rawlins . resolved

Should this say "unnamed constructor"? We don't know if there is a default constructor (an implicitly defined unnamed, zero-parameter constructor).

Brian Wilkerson

Yes, that's more accurate. Thanks and done.

Danny Tuppeny

It might be useful to have a glossary somewhere describing some of these terms, because I've probably also used these interchangeably (I got the impression we were avoiding using "unnamed constructor" and I probably assumed "default" was an appropriate name for this and probably would've called the other one an "implicit constructor").

Brian Wilkerson

We have a glossary (https://dart.dev/resources/glossary) but it doesn't contain either of these terms.

The diagnostic messages appear to be consistent in their use of 'unnamed' to mean a constructor that doesn't have a name, but are inconsistent with the use of 'default' to sometimes mean the synthetic constructor defined when there is no explicit constructor and sometimes to mean an unnamed zero parameter constructor.

I think we should be consistent with the spec, which uses 'default' for the synthetic constructor, 'unnamed' for a constructor that has no name, and doesn't have a term for a zero parameter constructor.

Danny Tuppeny

Thanks! This all sounds reasonable to me. I thought we had previously said not to use unnamed. I searched my email to understand where that had come from and the only thing I found that was close to this was here:

https://github.com/dart-lang/sdk/issues/62393#issuecomment-3745407315

there's no such thing as an unnamed constructor

I think there might have been some discussions at the time around what the "name" was in a constructor (eg. in MyClass.foo()`), possibly because we'd been discussing navigation (or occurrences) for these things, so some of these things may have blurred together too.


Would it be useful to have these terms (and primary + secondary?) added to https://dart.dev/resources/glossary since if we use them in diagnostics/fixes, they're going to be used by users too?

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: I067f7f98eee6080f7b15d79b52f1d0adad0a77e0
Gerrit-Change-Number: 490941
Gerrit-PatchSet: 7
Gerrit-Owner: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
Gerrit-CC: Danny Tuppeny <da...@tuppeny.com>
Gerrit-Comment-Date: Mon, 30 Mar 2026 14:54:49 +0000
satisfied_requirement
open
diffy

Brian Wilkerson (Gerrit)

unread,
11:09 AM (10 hours ago) 11:09 AM
to Brian Wilkerson, Commit Queue, Samuel Rawlins, Danny Tuppeny, dart-analys...@google.com, rev...@dartlang.org

Brian Wilkerson added 1 comment

File pkg/analysis_server/lib/src/services/refactoring/remove_constructor_name.dart
Line 46, Patchset 5: reason: "There's already a default constructor.",
Samuel Rawlins . resolved

Should this say "unnamed constructor"? We don't know if there is a default constructor (an implicitly defined unnamed, zero-parameter constructor).

Brian Wilkerson

Yes, that's more accurate. Thanks and done.

Danny Tuppeny

It might be useful to have a glossary somewhere describing some of these terms, because I've probably also used these interchangeably (I got the impression we were avoiding using "unnamed constructor" and I probably assumed "default" was an appropriate name for this and probably would've called the other one an "implicit constructor").

Brian Wilkerson

We have a glossary (https://dart.dev/resources/glossary) but it doesn't contain either of these terms.

The diagnostic messages appear to be consistent in their use of 'unnamed' to mean a constructor that doesn't have a name, but are inconsistent with the use of 'default' to sometimes mean the synthetic constructor defined when there is no explicit constructor and sometimes to mean an unnamed zero parameter constructor.

I think we should be consistent with the spec, which uses 'default' for the synthetic constructor, 'unnamed' for a constructor that has no name, and doesn't have a term for a zero parameter constructor.

Danny Tuppeny

Thanks! This all sounds reasonable to me. I thought we had previously said not to use unnamed. I searched my email to understand where that had come from and the only thing I found that was close to this was here:

https://github.com/dart-lang/sdk/issues/62393#issuecomment-3745407315

there's no such thing as an unnamed constructor

I think there might have been some discussions at the time around what the "name" was in a constructor (eg. in MyClass.foo()`), possibly because we'd been discussing navigation (or occurrences) for these things, so some of these things may have blurred together too.


Would it be useful to have these terms (and primary + secondary?) added to https://dart.dev/resources/glossary since if we use them in diagnostics/fixes, they're going to be used by users too?

Brian Wilkerson

... the only thing I found that was close to this was here ...

That is what the spec says (indirectly), but since then I've been leaning more toward using what I believe is the common meaning of the term and saying that an 'unnamed' constructor is a constructor whose name is the same as the class in which it's defined without a qualifying period and name.

Would it be useful to have these terms ...

I don't know. I think we only add entries for terms that might not be well-understood by our users, where "well-understood" is hard to quantify. It sounds like it would be a good question for the documentation team.

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: I067f7f98eee6080f7b15d79b52f1d0adad0a77e0
Gerrit-Change-Number: 490941
Gerrit-PatchSet: 7
Gerrit-Owner: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
Gerrit-CC: Danny Tuppeny <da...@tuppeny.com>
Gerrit-Comment-Date: Mon, 30 Mar 2026 15:09:02 +0000
satisfied_requirement
open
diffy

Danny Tuppeny (Gerrit)

unread,
11:47 AM (9 hours ago) 11:47 AM
to Brian Wilkerson, Commit Queue, Samuel Rawlins, dart-analys...@google.com, rev...@dartlang.org

Danny Tuppeny added 1 comment

File pkg/analysis_server/lib/src/services/refactoring/remove_constructor_name.dart
Line 46, Patchset 5: reason: "There's already a default constructor.",
Samuel Rawlins . resolved

Should this say "unnamed constructor"? We don't know if there is a default constructor (an implicitly defined unnamed, zero-parameter constructor).

Brian Wilkerson

Yes, that's more accurate. Thanks and done.

Danny Tuppeny

It might be useful to have a glossary somewhere describing some of these terms, because I've probably also used these interchangeably (I got the impression we were avoiding using "unnamed constructor" and I probably assumed "default" was an appropriate name for this and probably would've called the other one an "implicit constructor").

Brian Wilkerson

We have a glossary (https://dart.dev/resources/glossary) but it doesn't contain either of these terms.

The diagnostic messages appear to be consistent in their use of 'unnamed' to mean a constructor that doesn't have a name, but are inconsistent with the use of 'default' to sometimes mean the synthetic constructor defined when there is no explicit constructor and sometimes to mean an unnamed zero parameter constructor.

I think we should be consistent with the spec, which uses 'default' for the synthetic constructor, 'unnamed' for a constructor that has no name, and doesn't have a term for a zero parameter constructor.

Danny Tuppeny

Thanks! This all sounds reasonable to me. I thought we had previously said not to use unnamed. I searched my email to understand where that had come from and the only thing I found that was close to this was here:

https://github.com/dart-lang/sdk/issues/62393#issuecomment-3745407315

there's no such thing as an unnamed constructor

I think there might have been some discussions at the time around what the "name" was in a constructor (eg. in MyClass.foo()`), possibly because we'd been discussing navigation (or occurrences) for these things, so some of these things may have blurred together too.


Would it be useful to have these terms (and primary + secondary?) added to https://dart.dev/resources/glossary since if we use them in diagnostics/fixes, they're going to be used by users too?

Brian Wilkerson

... the only thing I found that was close to this was here ...

That is what the spec says (indirectly), but since then I've been leaning more toward using what I believe is the common meaning of the term and saying that an 'unnamed' constructor is a constructor whose name is the same as the class in which it's defined without a qualifying period and name.

Would it be useful to have these terms ...

I don't know. I think we only add entries for terms that might not be well-understood by our users, where "well-understood" is hard to quantify. It sounds like it would be a good question for the documentation team.

Danny Tuppeny

I feel like some of these might fall into that category. Seems there was an existing issue soliciting things to add to the glossary, so I've added them there for consideration. Thanks!

https://github.com/dart-lang/site-www/issues/6461#issuecomment-4156062692

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: I067f7f98eee6080f7b15d79b52f1d0adad0a77e0
Gerrit-Change-Number: 490941
Gerrit-PatchSet: 7
Gerrit-Owner: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
Gerrit-CC: Danny Tuppeny <da...@tuppeny.com>
Gerrit-Comment-Date: Mon, 30 Mar 2026 15:47:13 +0000
satisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages