Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated freezed classes expand == operator parameter to be nullable (dynamic) #1016

Closed
srawlins opened this issue Dec 7, 2023 · 1 comment · Fixed by #1017
Closed

Generated freezed classes expand == operator parameter to be nullable (dynamic) #1016

srawlins opened this issue Dec 7, 2023 · 1 comment · Fixed by #1017
Assignees
Labels
bug Something isn't working needs triage

Comments

@srawlins
Copy link
Contributor

srawlins commented Dec 7, 2023

Generated freezed classes declare an operator == override which expands the parameter type (from Object, on Object.==) to a nullable type (dynamic). For example:

  @override
  bool operator ==(dynamic other) {
    return identical(this, other) ||
        (other.runtimeType == runtimeType &&
            other is ListIndexPath &&
            const DeepCollectionEquality().equals(other.index, index));
  }

No Dart runtime passes a null value to an == implementation. Explicitly expanding the parameter type does not seem to serve a purpose, and can lead to confusion that the function will ever see a null argument value. These implementation should not have an expanded parameter type of dynamic.

To Reproduce

Generate a freezed class.

Expected behavior

The class should not expand operator =='s parameter type from Object.

@rrousselGit
Copy link
Owner

What's the downside to this exactly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants