Skip to content

[Primary Constructors] Pre-release migrations #62590

Closed

Description

@kallentu

This issue tracks migrations and work that is needed before shipping/flipping the flag.

Context: #61525 (comment)

It used to be possible to mark formal parameters (in general, not just the ones in constructors) as final. This used to mean that the formal parameter itself was immutable. However, we decided that this feature should no longer be supported, which means that it will be an error to put final on a formal parameter of any function other than a declaring constructor

This does give rise to some inconveniences for developers who prefer to use immutable formal parameters (they're forced to change their code to not do that any more). However, final formal parameters are not common today, and it's not hard to teach dart fix to remove final in the locations where it is an error to have it.

Activity

  1. self-assigned this
    on Feb 4, 2026
  2. added
    feature-primary-constructorsImplementation of the primary constructors feature. Otherwise known as declaring constructors.
    area-google3Tracking issues for internal work. Note that this area is not triaged.
    on Feb 4, 2026
  3. lrhn commented on Feb 5, 2026

    @lrhn
    Member

    Also need to migrate any (hypothetical) parameters of the form var id.

    There was never any reason to write the var, so it's likely incredibly rare, but it has also always been valid syntax.

    If nothing else, the SDK might have tests of the syntax that should be marked as legacy tests with a language version marker.

  4. kallentu commented on Feb 5, 2026

    @kallentu
    MemberAuthor

    Also need to migrate any (hypothetical) parameters of the form var id.

    There was never any reason to write the var, so it's likely incredibly rare, but it has also always been valid syntax.

    If nothing else, the SDK might have tests of the syntax that should be marked as legacy tests with a language version marker.

    Ah good point. I'll check if there are any instances of that.

  5. eernstg commented on Feb 6, 2026

    @eernstg
    Member

    https://dart-review.googlesource.com/c/sdk/+/456740 should have removed var and final parameters from language tests. If it's important to have the old syntax (especially, var myParameter) and equip them with a language version then those old tests can be found in the commit just before that CL was landed.

  6. kallentu commented on Apr 13, 2026

    @kallentu
    MemberAuthor

    Both var_with_no_type_annotation and avoid_final_parameter lints are enabled in g3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-google3Tracking issues for internal work. Note that this area is not triaged.feature-primary-constructorsImplementation of the primary constructors feature. Otherwise known as declaring constructors.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions