Skip to content

autofix for use_super_params has trouble with "final" #48698

Closed
@goderbauer

Description

@goderbauer

The autofix for use_super_params is correcting the following code...

class Base {
  Base(this.value);
  final int value;
}

class Extended extends Base {
  Extended(final int value) : super(value);
}

... to ...

class Base {
  Base(this.value);
  final int value;
}

class Extended extends Base {
  Extended(final super.value); // note the incorrect final here
}

When running this code, I get the following error:

Error: Can't have modifier 'final' here.
Try removing 'final'.
  Extended(final super.value);
           ^^^^^

The autofix should have removed the "final" here.

(And I also would have expected the analyzer to complain about the incorrectly left behind "final" - instead of just getting an error when executing the program. Filed #48699 for that.)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions