Order.fromComparable Method Signature Change to Allow java.sql.Date#4734
Conversation
|
Hi @ikeyan , thank you for the PR, it can be helpful indeed! |
|
@satorg I added a test in OrderSuite.scala |
satorg
left a comment
There was a problem hiding this comment.
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.
seems to me like this should be implicit potentially, perhaps at a lower priority.
There was a problem hiding this comment.
@johnynek if an implicit parameter is added, would that break binary compatibility?
There was a problem hiding this comment.
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.fromComparablemethod signature inOrder.scalahas been modified to allow it to acceptjava.sql.Date.This change enables the method to work with types such as
java.sql.Dateand other subtypes ofjava.util.Datewhich implementsComparable<java.util.Date>.