规格的隐式转换冲突,我在我的代码是类型别名,像这样:使用Scala PREDEF
type Time = Double
而且我经常在这两个试验和应用传递长值,使用这种类型的功能。例如:
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
后似乎规格测试框架的一部分(我的测试规格1)。我试着运行代码来获取解释器中的错误,并且在测试的一侧完成了。
有什么办法可以以某种方式消除模糊性,所以我可以将Long传递给Double/Time函数的值?为什么Specs在Scala已经提供这个功能时尝试创建自己的LongToDouble转换?
这似乎不起作用。 NumericBaseMatchers是一个特点。导入抱怨说没有伴侣对象? – seadowg 2012-01-29 18:07:09