Skip to content

Fix #4652: allow augmenting setters to choose parameter name - #4663

Open
Darkildo wants to merge 1 commit into
dart-lang:mainfrom
Darkildo:fix-4652-augmenting-setter-parameter-name
Open

Fix #4652: allow augmenting setters to choose parameter name#4663
Darkildo wants to merge 1 commit into
dart-lang:mainfrom
Darkildo:fix-4652-augmenting-setter-parameter-name

Conversation

@Darkildo

Copy link
Copy Markdown

This PR updates the augmentations specification so that the implicit setter
induced by a variable declaration no longer has a fixed parameter name _.

Previously, the spec said that for augmentation purposes a non-final variable
(or a late variable without an initializer) implicitly defines a setter with a
parameter named _. After the recent changes around _, this made it
impossible for an augmenting setter declaration to choose its own parameter
name.

This PR changes that wording so that the implicit setter is specified only in
terms of its shape and type:

  • it has a single required positional parameter
  • the parameter type is the type of the variable
  • the variable declaration does not determine the parameter name

This restores the intended ability for an augmenting setter declaration to use a
source-level parameter name such as:

augment set i(myName) {
  _i = myName;
}

@google-cla

google-cla Bot commented Mar 17, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@munificent
munificent requested a review from eernstg May 7, 2026 22:26

@eernstg eernstg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but I do think it would be slightly better to not do this. ;-)

type is the type of the variable.
declaration also implicitly defines a setter with a single required positional
parameter whose type is the type of the variable. The variable declaration does
not determine the name of that parameter.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you may have been OOO at the time, but the ability to use a parameter declaration whose name is specified as _ to mean "I don't care" was reintroduced with #4669 and #4670. It should not be necessary to introduce the notion of "does not determine the name" for a parameter declaration.

I don't think it actually creates any problems with the specification to rely on "does not determine the name", but it seems simpler to rely on the ability of _ to do the same thing, now that this feature has been restored.

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

Successfully merging this pull request may close these issues.

2 participants