Skip to content

dart fix with always_declare_return_types and annotate_overrides produces code that doesn't compile #61301

@ValentinVignal

Description

@ValentinVignal

Running dart fix --apply on

abstract class A {
  void foo();
}

class B extends A {
  foo() {
    // Implementation.
  }
}

with the rule always_declare_return_types and annotate_overrides produces:

class B extends A {
  void @override
  void foo() {
    // Implementation.
  }
}

which doesn't compile.

I'm using Macos

dart info

If providing this information as part of reporting a bug, please review the information
below to ensure it only contains things you're comfortable posting publicly.

#### General info

- Dart 3.8.1 (stable) (Wed May 28 00:47:25 2025 -0700) on "macos_x64"
- on macos / Version 15.4.1 (Build 24E263)
- locale is en-US

#### Project info

- sdk constraint: '^3.7.0'
- dependencies: cupertino_icons, flutter
- dev_dependencies: alchemist, flutter_lints, flutter_test

#### Process info

| Memory |  CPU | Elapsed time | Command line                                                                     |
| -----: | ---: | -----------: | -------------------------------------------------------------------------------- |
|  53 MB | 0.0% |        11:08 | dart devtools --machine --allow-embedding --dtd-uri ws:<path>/ZouYGXe-F0Q=       |
| 414 MB | 0.0% |        11:09 | dart language-server --protocol=lsp --client-id=VS-Code --client-version=3.116.0 |
|  93 MB | 0.1% |        11:09 | flutter_tools.snapshot daemon                                                    |

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2A bug or feature request we're likely to work onarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-bulk-fixtype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions