我使用 scala 2.11.2。这是我的功能的一部分:
import scala.reflect.runtime.universe._
p => p.filter(p => typeOf[p.type] != typeOf[Nothing]).flatMap {
case Some(profile) => {
...
env.userService.save(profile.copy(passwordInfo = Some(hashed)),...) //<---------error here
}
case _ => ...
}
编译错误是:</p>
PasswordReset.scala:120: value copy is not a member of Nothing
[error] env.userService.save(profile.copy(passwordI
nfo = Some(hashed)), SaveMode.PasswordChange);
[error] ^
我想我使用过滤器相位过滤了 Nothing 类型,但为什么它仍然给我类型 Nothing 错误。我不想:
profile.getDefault().copy(...)
因为我真的需要复制配置文件而不是复制默认值,所以如果配置文件是 Nothing 就删除它。怎么做?