Questions tagged [scalac]

scalac - Compiler for the Scala 2 language

176 questions
9
votes
1 answer

Scala: The `-` [dash, minus] command is deprecated in favor of `onFailure` and will be removed in 0.14.0

When I'm doing sbt compile -feature on my Scala project I get a mysterious warnings: The `-` command is deprecated in favor of `onFailure` and will be removed in 0.14.0 I have no clue what that dash/minus command is or where it is possibly being…
scravy
  • 11,904
  • 14
  • 72
  • 127
9
votes
1 answer

How can I create a separate sbt Configuration or Task to compile with WartRemover?

WartRemover is a scalac plugin. Typically it is configured via an sbt plugin. I'd like to be able to run WartRemover on my sbt project as a separate configuration or task without affecting the usual run of compile. After adding Wartremover to my…
Leif Wickland
  • 3,693
  • 26
  • 43
9
votes
2 answers

How do I compile Scala Hello World application

I'm new to Scala, and I've never written or compiled a program in it before. I'm trying to simply run the following Hello World example, which I have saved in a file name scalaApp.scala object scalaApp extends App { def main(args: Array[String])…
Steven Edmunds
  • 315
  • 6
  • 14
8
votes
2 answers

Extract scala source code from jar

So I have a jar file that contains scala as the source code and I have lost the original code. Is there a way to convert the class files in the jar to scala functions and classes instead of the java classes the compiler makes? I have tried using a…
user3003510
  • 291
  • 1
  • 5
  • 10
8
votes
1 answer

How can I find the source file that causes a Scalac Compiler crash

I am in the process of upgrading a large project to 2.10.4 to 2.11.4. I have gotten a compiler crash, is there anyway to display the name of source file that is causing the crash? I am able to get the full trace with ' last…
BenjaminJackman
  • 1,439
  • 1
  • 10
  • 18
8
votes
3 answers

Why can't scalac optimize tail recursion in certain scenarios?

Why doesn't scalac (the Scala compiler) optimize tail recursion? Code and compiler invocations that demonstrates this: > cat foo.scala class Foo { def ifak(n: Int, acc: Int):Int = { if (n == 1) acc else ifak(n-1, n*acc) } } > scalac…
IttayD
  • 28,271
  • 28
  • 124
  • 178
7
votes
1 answer

How does the Scala compiler perform implicit conversion?

I have a custom class, A, and I have defined some operations within the class as follows: def +(that: A) = ... def -(that: A) = ... def *(that: A) = ... def +(that: Double) = ... def -(that: Double) = ... def *(that: Double) = ... In order to have…
darsnack
  • 915
  • 5
  • 10
7
votes
1 answer

Adding a library dependency via an sbt plugin - per sub-project

I am trying to add a library dependency through an sbt plugin. The dependency should be added to each sub-project per its binary scala version, so I iterate through each subproject. private def inject(): State => State = { state => val…
matanster
  • 15,072
  • 19
  • 88
  • 167
7
votes
2 answers

maven "rerun with -feature" when compiling scala

I recently noticed Scala compiler warnings that maven was generating that looked like this: [WARNING] warning: there were 4 deprecation warning(s); re-run with -deprecation for details [WARNING] warning: there were 3 feature warning(s); re-run with…
Philip O.
  • 288
  • 2
  • 8
7
votes
2 answers

What are and when doing Scalac -Xprint:typer?

I've written a tiny bit of Scala object SquareNumbers extends App { val numbers = List(1,2,3,4,5) val squares = numbers map (i => i * i) println (squares) } And run it through scalac as so: $ scalac -Xprint:typer SquareNumbers.scala [[syntax…
colinjwebb
  • 4,362
  • 7
  • 31
  • 35
6
votes
3 answers

Splitting scalac plugin into multiple files

I'd like to split my scalac plugin into multiple files. This sounds easy but I haven't managed to pull it off due to path-dependent type issues stemming from the import global._ line. Here's Lex Spoon's sample plugin: package localhost import…
Yuvi Masory
  • 2,644
  • 2
  • 27
  • 36
6
votes
0 answers

Scala compilation time report

I've got a project that isn't a crazy number of lines of code, but its compilation time is really long on a clean compile. I have the feeling there are some hotspots, but I don't know how to find them. Is there a way to get a report of how long…
acjay
  • 34,571
  • 6
  • 57
  • 100
6
votes
1 answer

How to pass scalacOptions (Xelide-below) to sbt via command line

I am trying to call sbt assembly from the command line passing it a scalac compiler flag to elides (elide-below 1). I have managed to get the flag working in the build.sbt by adding this line to the build.sbt scalacOptions ++= Seq("-Xelide-below",…
Armin
  • 1,367
  • 1
  • 12
  • 17
6
votes
1 answer

Pass closure to Scala compiler plugin

I'm trying to write a Scala compiler plugin that will allow extremely general code generation: something like the generality of the C preprocessor, but a bit more typesafe (I'm not sure if this is a terrible idea, but it's a fun exercise). My ideal…
emchristiansen
  • 3,550
  • 3
  • 26
  • 40
6
votes
2 answers

scalac missing closing brace error reports with weird line number

As I've been learning Scala I'm often reminded of g++ compiler errors when reading the cryptic output from scalac. However, today I came across something I doubt would happen even in the g++ universe. A friend sent me a very simple code snippet with…
DaoWen
  • 32,589
  • 6
  • 74
  • 101
1
2
3
11 12