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
IterableExtension sortedBy doesn't permit sorting by int without workaround #271
Comments
Closing as a duplicate of dart-lang/sdk#43763 I don't think there is anything we can do from the package side. |
I think simply documenting this in the sortedBy docs would go a long way. :) |
Why |
No good reason. Was mostly trying to avoid "perfect being the enemy of the good" by documenting the one method through which myself and two other colleagues had independently encountered this error. 🤣 Happy to see something more systemic, just was trying to be helpful. I've personally not used any of the 4 other methods, but I have no data to say which are more/less common. |
I think if we do decide to address this with a note in the doc comment we can easily enough make it a template and repeat it in each impacted method. Once we hear back from the analyzer team on the feasibility for making the diagnostic more informative we can make a choice on landing the PR. |
yields
sorting by an
int
is a pretty important use case.the problem seems to be that
sortedBy
insists that its generic paramK
extendComparable<K>
and
int
doesn't extendComparable<int>
. rather, it extendsComparable<num>
.workaround:
the workaround doesn't seem like it should be the end of this story.
i feel like the first example should just work. perhaps one could see this as a problem with the type inference system,
as in, why can't it figure out that
K
perhaps should be bound to a super class (num
) of the exact type (int
)returned by the
keyOf
function?The text was updated successfully, but these errors were encountered: