私のコードには次のようなタイプエイリアスがあります:
type Time = Double
そして、私はテストとアプリケーションの両方で、このタイプを使用する関数にLong値を渡すことがよくあります。例えば:
def at(time : Time) : T = {
// Do Something
}
at(System.currentTimeMillis)
このコードは、次のエラーが発生するテストで実行しない限り、正常に機能します。
found : Long
required: com.github.oetzi.echo.Echo.Time
Note that implicit conversions are not applicable because they are ambiguous:
both method long2double in object Predef of type (x: Long)Double
and method longToDouble in trait NumericBaseMatchers of type (s: Long)Double
are possible conversion functions from Long to com.github.oetzi.echo.Echo.Time
調べてみるNumericBaseMatchers
と、それはSpecsテストフレームワークの一部のようです(私のテストはSpecs 1で書かれています)。インタープリターでエラーを取得するためにコードを実行しようとしましたが、テスト以外では問題ありませんでした。
どういうわけかあいまいさを取り除き、LongをDouble / Time関数の値に渡すことができる方法はありますか?Scalaがすでにこれを提供しているのに、Specsが独自のLongToDouble変換を作成しようとするのはなぜですか?