Skip to content

Lint to warn about incorrect types in overrides in a mixed mode null safety setting #58884

@nshahan

Description

@nshahan

This request is motivated by a breakage I found in google3, and the potential for many more as null safety migrations continue.

Would it be possible to create a lint to trigger when:

  1. An API is defined in a null safe library.
  2. The API is implemented in a null safe library.
  3. The API definition and implementation are only related through a library that is not yet null safe.

In this example a method signature is defined in a null safe mixin and returns int. The implementation is in a null safe library and returns int?. There is no direct relation between the definition and the implementation so there are no errors. They are brought together by another class that has not yet been migrated to null safety, so still no errors even though we know that the implementation is invalid for the method signature defined by the mixin.

file1.dart (not migrated to null safety)

class C extends B with M {}

file2.dart (migrated to null safety)

class B {
  int? fn() => null;
}

file3.dart (migrated to null safety)

mixin M {
  int fn();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-linterIssues with the analyzer's support for the linter packagelinter-lint-proposaltype-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions