Che cosa significa questo avviso significa:avvertimento circa l'accesso riflettente di membro di tipo strutturale a Scala
accesso riflettente di tipo metodo membro getMap strutturale dovrebbe essere abilitata
L'avviso include un riferimento alla Scala documenti ma non capisco come il mio codice sia correlato alla spiegazione. (In particolare la spiegazione menziona riflessione ... come è il mio codice utilizzando la riflessione?)
ho questo: (Scala 2.11.2)
object getMap {
implicit def fromOptionToConvertedVal[T](o:Option[T]) = new {
def getMap[R] (doWithSomeVal:(T) => R) = new {
def orElse(handleNone: => R) = o match {
case Some(value) => doWithSomeVal(value)
case None => handleNone
}
}
}
}
import getMap._
val i:Option[Int] = Some(5)
val x = i getMap (_*2) orElse 1
Questo genera l'avviso di seguito:
[warn] /Users/Greg/git/Favorites-Demo/src/main/scala/com/rs/server/ThriftServer.scala:34: reflective access of structural type member method getMap should be enabled
[warn] by making the implicit value scala.language.reflectiveCalls visible.
[warn] This can be achieved by adding the import clause 'import scala.language.reflectiveCalls'
[warn] or by setting the compiler option -language:reflectiveCalls.
[warn] See the Scala docs for value scala.language.reflectiveCalls for a discussion
[warn] why the feature should be explicitly enabled.
[warn] val x = i getMap (_*2) orElse 1
[warn] ^
[warn] /Users/Greg/git/Favorites-Demo/src/main/scala/com/rs/server/ThriftServer.scala:34: reflective access of structural type member method orElse should be enabled
[warn] by making the implicit value scala.language.reflectiveCalls visible.
[warn] val x = i getMap (_*2) orElse 1
[warn] ^