在Scala中,"应该启用结构类型成员方法的反射访问......"警告是什么意思?

Iva*_*van 17 scala scala-2.10

切换到Scala 2.10后,我收到了大量的警告:

结构类型成员方法的反射访问...应该通过使隐式值language.reflectiveCalls可见来启用

这是什么意思?

Eug*_*ako 17

该警告实际上告诉您在文档中查找解释的位置:

Test.scala:9: warning: reflective access of structural type member method y should be enabled
by making the implicit value language.reflectiveCalls visible.
This can be achieved by adding the import clause 'import scala.language.reflectiveCalls'
or by setting the compiler option -language:reflectiveCalls.
See the Scala docs for value scala.language.reflectiveCalls for a discussion
why the feature should be explicitly enabled.
Run Code Online (Sandbox Code Playgroud)

引用Scaladoc条目(确保单击左侧的|>箭头以展开文档条目).

  • 如果您可以发布代码的一些片段,将会很有帮助 (3认同)
  • 现在死链接,这通常是为什么SO鼓励提供**答案的摘要**而不是仅仅链接到其他地方. (3认同)
  • 您可以与我共享代码,如果它是github或将存档发送到我的电子邮件(在个人资料中) (2认同)