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

Strong mode complains about Equality default constructor params. #30

Closed
har79 opened this issue May 12, 2016 · 8 comments
Closed

Strong mode complains about Equality default constructor params. #30

har79 opened this issue May 12, 2016 · 8 comments
Labels
closed-duplicate Closed in favor of an existing report

Comments

@har79
Copy link

har79 commented May 12, 2016

E.g., "const ListEquality()" causes the following warnings:

[INFO] The object type 'DefaultEquality' cannot be assigned to the field '_elementEquality', which has type 'Equality' [CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH]
[INFO] The object type 'DefaultEquality' cannot be assigned to a parameter of type 'Equality' [CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH]

This is because of the type mismatch in ListEquality's default constructor parameters:
final Equality _elementEquality;
const ListEquality([Equality elementEquality = const DefaultEquality()])
: _elementEquality = elementEquality;

and can be fixed by adding the generic type. I'll send a pull request for this and similar classes.

@har79
Copy link
Author

har79 commented May 12, 2016

Looks like this isn't actually possible in Dart right now due to dart-lang/sdk#22329.

@nex3
Copy link
Member

nex3 commented May 12, 2016

What version of collection are you using? I don't see any strong-mode errors with the most recent version.

@nex3 nex3 added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) status-needs-info labels May 12, 2016
@har79
Copy link
Author

har79 commented May 12, 2016

1.6.0

@har79
Copy link
Author

har79 commented May 12, 2016

The full line of code that produced the warnings was:
static const _titleEquality = const ListEquality();

I was able to remove the warnings by changing it to:
static const _titleEquality = const ListEquality(const DefaultEquality());

@nex3
Copy link
Member

nex3 commented May 12, 2016

What version of Dart are you using? I don't see any strong-mode messages when running the 1.16 analyzer on collection 1.6.0.

@har79
Copy link
Author

har79 commented May 18, 2016

It's v1_17_0_dev_2_0; I can ping you a test link if that helps.

@nex3
Copy link
Member

nex3 commented May 18, 2016

I can't reproduce this at all.

$ git co 1.6.0
Note: checking out '1.6.0'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b <new-branch-name>

HEAD is now at e3a6fca... Add GroupSet and SetGroup classes.
$ dartanalyzer-1.17.0-dev.2.0 --version
dartanalyzer version 1.17.0-dev.2.0
$ dartanalyzer-1.17.0-dev.2.0 lib/collection.dart 
Analyzing [lib/collection.dart]...
No issues found

I can only guess that you're somehow using a different version of collection or of dartanalyzer than you think you are.

@nex3 nex3 closed this as completed May 18, 2016
@nex3 nex3 added closed-cannot-reproduce Closed as we were unable to reproduce the reported issue and removed type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) status-needs-info labels May 18, 2016
@nex3
Copy link
Member

nex3 commented May 19, 2016

I understand what's happening now; this was hidden when analyzing the libraries themselves due to dart-lang/sdk#26141. It's actually a duplicate of #27.

@nex3 nex3 added closed-duplicate Closed in favor of an existing report and removed closed-cannot-reproduce Closed as we were unable to reproduce the reported issue labels May 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-duplicate Closed in favor of an existing report
Projects
None yet
Development

No branches or pull requests

2 participants