4

I'm migrating an app from play 2.0.4 to play 2.1

But the following code raises this warning:

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]             ^

In play 2.0.4 (with scala 2.9.1) it worked ok, with this version (scala 2.10) it yields this warning

Any idea what could be wrong?

opensas
  • 60,462
  • 79
  • 252
  • 386
  • 2
    The error message tells you exactly what's wrong. Which part of it don't you understand? – Kim Stebel Nov 20 '12 at 13:38
  • well, I was wondering why it worked ok with play2.0.4, and where could I pass the -D... params to avoid that warning – opensas Nov 20 '12 at 13:59
  • 1
    They changed the pattern matching code in 2.10, which is why the behaviour changed. As to whats the problem, I dont know... – Ivan Meredith Nov 20 '12 at 19:17

4 Answers4

5

Maybe this?

What happens if you add

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

to your project/Build.scala?

[UPDATE / CORRECTION]

I was wrong about scalacOptions - -D options need to be passed as JVM arguments, not arguments to scalac. Since sbt/play respect the JAVA_OPTS environment, variable, maybe you could try running play or sbt like this?

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

That's assuming you are on a Unix-y OS.

Faiz
  • 16,025
  • 5
  • 48
  • 37
2

Just ran into the same issue(but not in Play). For a more permanent fix simply create a file ~/.sbtconfig, and add these lines:

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

This file and the SBT_OPTS defined inside it will be used every time you run sbt. Depending on where you got Play from it might be bundled with its own version of sbt and may not use this file at launch time.

Lyuben Todorov
  • 13,987
  • 5
  • 50
  • 69
etreworgy
  • 644
  • 6
  • 4
1

For 'per project' SBT configuration add this to your .scala build file.

initialize ~= { _ => sys.props("scalac.patmat.analysisBudget") = "off" }
agilesteel
  • 16,775
  • 6
  • 44
  • 55
0

For sbt 0.13.* adding -J scalac option in build.sbt works for me:

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

or

sbt -J-Dscalac.patmat.analysisBudget=off

or you can add the option with "-J" to the global options file: /usr/local/etc/sbtopts

Vitamon
  • 538
  • 7
  • 18