scala-time
scala-time copied to clipboard
Conflict with specs2
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