Skip to content

Implement a lint to find local variables created to allow this to be promoted #63888

Open

Description

@bwilkerson

Add a lint named unnecessary_this_alias, which will trigger if all the following conditions are met:

  • The language feature this-promotion is enabled.
  • A non-late local variable’s initializer is this.
  • The variable’s static type (inferred or explicit) is the same as the type of this.
  • The local variable is never written to.
  • At least one usage of the local variable uses a syntax that would be expected to trigger type promotion (v is T, v as T, v == null, v != null, v!, etc.)

Activity

  1. self-assigned this
    on Jul 24, 2026
  2. added
    area-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.
    feature-this-promotionImplementation of the this promotion feature.
    type-taskA well-defined stand-alone task
    on Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.feature-this-promotionImplementation of the this promotion feature.type-taskA well-defined stand-alone task

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions