jorgeortiz85 / scala-time

A Scala wrapper for Joda Time

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Conflict with specs2

electricmonk opened this issue · comments

When using an int conversion from IntImplicits, for instance 2.days in the context of a specs2 test, the implicit conversion from Int to DateTime conflicts with the one from specs2's TimeConversion, giving the following compilation error:

error: type mismatch;
found : Int(2)
required: ?{val days: ?}
Note that implicit conversions are not applicable because they are ambiguous:
both method RichInt in trait IntImplicits of type (n: Int)org.scala_tools.time.RichInt
and method intToRichLong in trait TimeConversions of type (v: Int)MongoMetaSiteDaoTest.this.RichLong
are possible conversion functions from Int(2) to ?{val days: ?}
Error occurred in an application involving default arguments.
val site1 = MetaSite(originTemplateId = new ObjectId().toString, ownerUserId = user, name = "site1", dateUpdated = DateTime.now + 2.days)

Not that I have an idea how to solve this but it's a bug nonetheless :)

As far as I have read it cannot be solved because the overlapping implicit is defined by Specification. The only workaround I can figure out is to write some redundant functions to mark the target implementation like jday, joda_day or jodaDay

You can mix in the trait org.specs2.time.NoTimeConversions and then use the implicits from scala-time