4

我正在将应用程序从 play 2.0.4 迁移到 play 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)它会产生这个警告

知道有什么问题吗?

4

4 回答 4

5

也许这个?

如果添加会发生什么

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

给你的project/Build.scala

[更新/更正]

我错了scalacOptions--D选项需​​要作为 JVM 参数传递,而不是scalac. 由于sbt/play尊重JAVA_OPTS环境,变量,也许你可以尝试运行playsbt这样?

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

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

于 2012-11-20T13:44:51.457 回答
2

刚刚遇到同样的问题(但不是在 Play 中)。要获得更永久的修复,只需创建一个文件~/.sbtconfig,然后添加以下行:

#!/bin/sh
SBT_OPTS="-Dscalac.patmat.analysisBudget=off"

SBT_OPTS每次运行时都会使用此文件及其内部定义的文件sbt。根据你从哪里获得 Play,它可能与它自己的 sbt 版本捆绑在一起,并且在启动时可能不会使用这个文件。

于 2013-02-22T01:18:36.400 回答
1

对于“每个项目”的 SBT 配置,将其添加到您的.scala构建文件中。

initialize ~= { _ => sys.props("scalac.patmat.analysisBudget") = "off" }
于 2014-01-22T15:25:48.860 回答
0

对于 sbt 0.13.* 在 build.sbt 添加 -J scalac 选项对我有用:

scalacOptions ++= Seq("-Jscalac.patmat.analysisBudget=off")

或者

sbt -J-Dscalac.patmat.analysisBudget=off

或者您可以将带有“-J”的选项添加到全局选项文件:/usr/local/etc/sbtopts

于 2018-01-16T12:37:52.213 回答