-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Order.fromComparable
Method Signature Change to Allow java.sql.Date
#4734
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
Conversation
Hi @ikeyan , thank you for the PR, it can be helpful indeed! |
@satorg I added a test in OrderSuite.scala |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thanks!
def fromComparable[A <: Comparable[A]]: Order[A] = _ compareTo _ | ||
private type ContravariantComparable[A] = Comparable[? >: A] | ||
|
||
def fromComparable[A <: ContravariantComparable[A]]: Order[A] = _ compareTo _ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems to me like this should be implicit potentially, perhaps at a lower priority.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@johnynek if an implicit parameter is added, would that break binary compatibility?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't mean an implicit parameter, I mean implicit def from comparable...
This won't break JVM binary compatibility. But maybe we need to lower the priority of this implicit by putting it in a trait and extending here.
The
Order.fromComparable
method signature inOrder.scala
has been modified to allow it to acceptjava.sql.Date
.This change enables the method to work with types such as
java.sql.Date
and other subtypes ofjava.util.Date
which implementsComparable<java.util.Date>
.