gpt4 book ai didi

scala:无法检查匹配是否无法访问

转载 作者:行者123 更新时间:2023-12-04 23:25:31 25 4
gpt4 key购买 nike

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

知道有什么问题吗?

最佳答案

也许 this?

如果添加会发生什么

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 操作系统。

关于scala:无法检查匹配是否无法访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13474107/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com