Skip to content

Initial draft of enhanced constructors proposal.#4245

Merged
stereotype441 merged 1 commit intodart-lang:mainfrom
stereotype441:enhanced_constructors-2
Jan 31, 2025
Merged

Initial draft of enhanced constructors proposal.#4245
stereotype441 merged 1 commit intodart-lang:mainfrom
stereotype441:enhanced_constructors-2

Conversation

@stereotype441
Copy link
Member

This proposal extends the set of actions that can be performed in the body of a non-redirecting generative constructor to include writing to non-late final fields and explicitly invoking super constructors.

This makes constructors more flexible, avoids the need for constructor initializer lists, and allows constructor augmentations to behave more consistently with function augmentations.

To preserve soundness, flow analysis is enhanced to ensure that a reference to this cannot escape from a constructor body before the object has been completely constructed.

Once this change has landed I will create the appropriate "feature" issue.


  • I’ve reviewed the contributor guide and applied the relevant portions to this PR.
Contribution guidelines:

Note that many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback.

@stereotype441 stereotype441 merged commit ebdb887 into dart-lang:main Jan 31, 2025
2 of 3 checks passed
@stereotype441 stereotype441 deleted the enhanced_constructors-2 branch January 31, 2025 19:12
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.

1 participant