Skip to content

proposal: avoid_nullable_equals_parameter #58753

@natebosch

Description

@natebosch

Description

"The null value will never be passed to operator ==. Use a non-nullable Object parameter"

Details

A definition like bool operator ==(Object? other) causes other classes which override the interface to also accept a nullable argument, even though null will never be passed.

Kind

Style

Good Examples

  @override
  bool operator ==(Object other) =>

Bad Examples

  @override
  bool operator ==(Object? other) =>

Discussion

Mockito codegen currently fails to generate fakes for classes with a nullable argument to operator ==.

The main motivator is that the code is misleading - null can't show up so it's not worth making it look like it can.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions