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

Add implicit Ordering[RichDate] #1512

Merged
merged 1 commit into from Feb 11, 2016
Merged

Add implicit Ordering[RichDate] #1512

merged 1 commit into from Feb 11, 2016

Conversation

johnynek
Copy link
Collaborator

see scala design issue: https://issues.scala-lang.org/browse/SI-8541
that causes the following for tuples with RichDate:

/Users/oscar/oss/scalding/scalding-date/src/test/scala/com/twitter/scalding/DateTest.scala:139:
diverging implicit expansion for type ((String, com.twitter.scalding.RichDate)) =>
Comparable[(String, com.twitter.scalding.RichDate)]
[error] starting with method $conforms in object Predef
[error]       implicitly[Ordering[(String, RichDate)]]
[error]                 ^
[error] one error found
[error] (scalding-date/test:compileIncremental) Compilation failed
[error] Total time: 5 s, completed Feb 10, 2016 2:27:14 PM

see scala design issue: https://issues.scala-lang.org/browse/SI-8541
that causes the following for tuples with RichDate:

/Users/oscar/oss/scalding/scalding-date/src/test/scala/com/twitter/scalding/DateTest.scala:139:
diverging implicit expansion for type ((String, com.twitter.scalding.RichDate)) =>
Comparable[(String, com.twitter.scalding.RichDate)]
[error] starting with method $conforms in object Predef
[error]       implicitly[Ordering[(String, RichDate)]]
[error]                 ^
[error] one error found
[error] (scalding-date/test:compileIncremental) Compilation failed
[error] Total time: 5 s, completed Feb 10, 2016 2:27:14 PM
@Gabriella439
Copy link
Contributor

+1

johnynek added a commit that referenced this pull request Feb 11, 2016
Add implicit Ordering[RichDate]
@johnynek johnynek merged commit ad44b63 into develop Feb 11, 2016
@johnynek johnynek deleted the oscar/add-rd-ord branch February 11, 2016 01:59
@@ -61,6 +61,10 @@ object RichDate {
}

def now: RichDate = RichDate(System.currentTimeMillis())

implicit def richDateOrdering: Ordering[RichDate] = new Ordering[RichDate] {
def compare(a: RichDate, b: RichDate) = java.lang.Long.compare(a.timestamp, b.timestamp)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we call the compare function inside the richdate's instead? just so as we avoid any potential future drift.

(Curious I didn't think defining both Ordered and Ordering would get around the bug totally, but good!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants