Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

-Xdisable-assertions and -Xelide-below not turning off asserts

I'm currently working on a Scala project, that is using SBT, and I'm trying to produce production build settings in which one of the conditions are all asserts are turned off. I simply added the line, to my build.sbt:

scalacOptions ++= Seq(..., "-Xdisable-assertions")

I'm running the logLevel at debug and I see the options being passed to the compiler, but when I run our program(its long running program analysis), I encounter an assert. Though by all signs all asserts should be compiled away. I've tried this with both diable-assertions, and elide-below, without results. If anyone could give me some pointers on what I'm doing wrong, that would be great. I've written a lot of Scala, but haven't used SBT much beyond some basic projects.

like image 418
jroesch Avatar asked Oct 27 '25 05:10

jroesch


1 Answers

Do you run "reload" in sbt after editing build.sbt? Because I tried building a small project, and all assertions are happily compiled away. For the record, I'm using sbt 0.12.0.


Here is the sample project I used:

btest/
├── [  86]  build.sbt
└── [  45]  Main.scala

build.sbt:

scalacOptions ++= Seq("-deprecation", "-unchecked", "-Xlint", "-Xdisable-assertions")

Main.scala:

object Main extends App {
  assert(1 != 1)
}
like image 138
Rogach Avatar answered Oct 29 '25 22:10

Rogach



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!