运维开发网

scala:无法检查匹配的不可达性

运维开发网 https://www.qedev.com 2020-06-22 20:07 出处:网络 作者:运维开发网整理
我正在从app 2.0.4迁移应用程序到2.1 但是下面的代码提出了这个警告: def toConditionOperator(value: String): ConditionOperator.Value = { if (value==null) { ConditionOperator.Unknown } else { value.toLowerCase match {
我正在从app 2.0.4迁移应用程序到2.1

但是下面的代码提出了这个警告:

def toConditionOperator(value: String): ConditionOperator.Value = {
  if (value==null) {
    ConditionOperator.Unknown
  } else {
    value.toLowerCase match {
      case "equal" | "=" | ":"             => ConditionOperator.Equal
      case "notequal" | "!=" | "!:" | "<>" => ConditionOperator.NotEqual
      case "greaterorequal" | ">="         => ConditionOperator.GreaterOrEqual
      case "greater" | ">"                 => ConditionOperator.Greater
      case "lessorequal" | "<="            => ConditionOperator.LessOrEqual
      case "less" | "<"                    => ConditionOperator.Less
      case "between"                       => ConditionOperator.Between
      case "in"                            => ConditionOperator.In
      case "startswith"                    => ConditionOperator.StartsWith
      case "endswith"                      => ConditionOperator.EndsWith
      case "contains" | "$"                => ConditionOperator.Contains
      case "missing" | ""                  => ConditionOperator.Missing
      case "unknown" | _                   => ConditionOperator.Unknown
    }
  }
}


[info] Compiling 98 Scala sources and 2 Java sources to /home/sas/tmp/ideas-ba/webservice/target/scala-2.10/classes...
[warn] /home/sas/tmp/ideas-ba/webservice/app/utils/query/ConditionParser.scala:203: Cannot check match for unreachability.
[warn] (The analysis required more space than allowed. Please try with scalac -Dscalac.patmat.analysisBudget=512 or -Dscalac.patmat.analysisBudget=off.)
[warn]       value.toLowerCase match {
[warn]             ^

在Play 2.0.4(使用scala 2.9.1)中它工作正常,使用此版本(scala 2.10)它会产生此警告

知道什么可能是错的吗?

也许 this?

如果你添加会发生什么

scalacOptions ++= Seq("-Dscalac.patmat.analysisBudget=1024")

你的项目/ Build.scala?

[更新/更正]

我错误的scalacOptions – -D选项需要作为JVM参数传递,而不是scalac的参数.既然sbt / play尊重JAVA_OPTS环境,变量,也许你可以尝试运行play或sbt这样吗?

JAVA_OPTS="-Dscalac.patmat.analysisBudget=off" sbt
# Or
JAVA_OPTS="-Dscalac.patmat.analysisBudget=off" play

假设您使用的是Unix-y操作系统.

0

精彩评论

暂无评论...
验证码 换一张
取 消