如何不要求导入 scala.language.relectiveCalls
How not to require the import of scala.language.relectiveCalls
我将 org.scalatest.FlatSpec
子类化以将实用工具添加到 FlatTest。但是在我使用这个子类的任何地方,我都必须导入 scala.language.reflectiveClass
否则我会得到
reflective access of structural type member method test should be enabled
by making the implicit value scala.language.reflectiveCalls visible.
有问题的方法 test
等同于标准 FlatSpec 中的 should
:
it should "do some stuff" in { ...}
为什么不需要导入 reflectiveCalls 来使用 flatSpec should
但对于我的 test
方法是必需的,我该如何避免?
您收到此警告的原因是您在 test
方法的某处有结构类型引用或 new {...}
调用。
遗憾的是,除了显式 scala.language.reflectiveClass
导入或重写您的代码外,没有其他方法可以关闭该警告。
我将 org.scalatest.FlatSpec
子类化以将实用工具添加到 FlatTest。但是在我使用这个子类的任何地方,我都必须导入 scala.language.reflectiveClass
否则我会得到
reflective access of structural type member method test should be enabled
by making the implicit value scala.language.reflectiveCalls visible.
有问题的方法 test
等同于标准 FlatSpec 中的 should
:
it should "do some stuff" in { ...}
为什么不需要导入 reflectiveCalls 来使用 flatSpec should
但对于我的 test
方法是必需的,我该如何避免?
您收到此警告的原因是您在 test
方法的某处有结构类型引用或 new {...}
调用。
遗憾的是,除了显式 scala.language.reflectiveClass
导入或重写您的代码外,没有其他方法可以关闭该警告。