Scala 冲突的继承方法名称
我正在尝试编写一些代码来测试数据库模型。测试框架和数据库框架都使用“===”运算符,并且优先考虑测试框架。我如何明确地使用一种方法或另一种方法?
示例:
import org.scalatest.FunSuite
class TestDBModels extends FunSuite{
test("Test DoublePropertyEntry with a few new values") {
Schemas.doubleProperties.deleteWhere(p => (p.id === p.id)))
}
}
错误:
type mismatch;
found : Option[String]
required: org.squeryl.dsl.ast.LogicalBoolean
Schemas.doubleProperties.deleteWhere(p => (p.===(p.id, p.id)))
I am trying to write some code to test a database model. Both the test framework and the database framework use the "===" operator, and the test framework's is being given preference. How can I explicitly use one method or the other?
Example:
import org.scalatest.FunSuite
class TestDBModels extends FunSuite{
test("Test DoublePropertyEntry with a few new values") {
Schemas.doubleProperties.deleteWhere(p => (p.id === p.id)))
}
}
Error:
type mismatch;
found : Option[String]
required: org.squeryl.dsl.ast.LogicalBoolean
Schemas.doubleProperties.deleteWhere(p => (p.===(p.id, p.id)))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您有多种选择。第一个也是最简单的方法是使用显式方法调用而不是隐式转换。例如,要显式使用 scalatest ===:
如果这太长,您可以缩短名称:
convertToEqualizer 是 scalatest 的隐式转换方法。另一种选择是将 ConvertToEqualizer 重写为非隐式方法:
这会阻止这种特定隐式转换的发生。请参阅 Assertions 对象的 scalatest 文档 和 关于 scalatest-users 的相同问题邮件列表。
You have a number of options. The first and easiest is to use an explicit method call instead of the implicit conversion. For example, to explicitly use the scalatest ===:
If this is too long, you could shorten the name:
convertToEqualizer is the implicit conversion method for scalatest. One other option is to override convertToEqualizer as a non-implicit method:
This stops this particular implicit conversion happening. See the scalatest documentation for Assertions object and the same question on the scalatest-users mailing list.