4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

nscala-time と specs2 で `1.day` などの変換に失敗する

Posted at

原因は両方共に implicit conversion があるからです。

type mismatch;
[error]  found   : Int(1)
[error]  required: ?{def day: ?}
[error] Note that implicit conversions are not applicable because they are ambiguous:
[error]  both method richInt in trait IntImplicits of type (n: Int)com.github.nscala_time.time.RichInt
[error]  and method intToRichLong in trait TimeConversions of type (v: Int)TimeRangeSpec.this.longAsTime
[error]  are possible conversion functions from Int(1) to ?{def day: ?}
[error]         1.day
[error]         ^
[error] one error found
[error] (redshift/test:compile) Compilation failed
[error] Total time: 3 s, completed May 22, 2014 8:33:52 PM

Specs2 は NoTimeConversions という trait を用意しているので、 mixin することで specs2 側の implicit を無効にできる。

import org.specs2.mutable.Specification
class FooSpec extends Specification with NoTimeConversions
4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?