Questions tagged [scalac]

scalac - Compiler for the Scala 2 language

176 questions
2
votes
3 answers

How to make the scala compiler find case classes used with wrong arguments

I have a case class Disconnect(nodeId: PublicKey) that has 1 parameter in it, however in some other part of the code it happened to be used without the parameter i.e: Disconnect and the compiler did not catch the error, note that I've also tried to…
2
votes
1 answer

sbt compile fails with bad option: '-Ywarn-macros:after'

With a build.sbt file like: ThisBuild / organization := "com.company" ThisBuild / version := "1.0.0-SNAPSHOT" ThisBuild / scalaVersion := "2.11.12" Global / concurrentRestrictions += Tags.limit(Tags.Test, 1) Global / scalacOptions ++=…
Metropolis
  • 2,018
  • 1
  • 19
  • 36
2
votes
1 answer

Using tpolecat's recommended scalac flags with Play in Scala

Play generates scala classes from routes files, twirl templates. When I add scalac linting flags, sbt picks up generated classes making it impossible to use together with play. I really want to use https://github.com/DavidGregory084/sbt-tpolecat all…
Felix
  • 8,385
  • 10
  • 40
  • 59
2
votes
1 answer

Scala: Multiple flatMap definitions for for-comprehension type-inference issue

I have something like this: case class Box[A](x: A) { def flatMap[B](f: A => GenTraversableOnce[B]): GenTraversableOnce[B] = f(x) def flatMap[B](f: A => Box[B]): Box[B] = f(x) def map[B](f: A => B): Box[B] = Box(f(x)) } object…
pathikrit
  • 32,469
  • 37
  • 142
  • 221
2
votes
2 answers

Could not find proxy for ... in Macro

I have been chasing the following issue for quite a while and am hoping someone with more experience on this than myself can help me resolve it. In my test-case the exact error is as follows: java.lang.IllegalArgumentException: Could not find proxy…
darkfrog
  • 1,053
  • 8
  • 29
2
votes
1 answer

Why does scalac need a transitive dependency on the classpath

I'm running into an unexpected (only for me?) ScalaC behavior. The TL;DR is that the following is a recreation of an issue I saw while trying to migrate a codebase from maven to bazel. One of the main focuses of this migration is to try to minimize…
Ittai
  • 5,625
  • 14
  • 60
  • 97
2
votes
0 answers

Output code after all translations and implicit applications?

In this post Find all implicits I've seen that there is an -Xlog-implicit-conversions option for scalac which shows implicit applications during compilation. There is also -Xprint: option which shows program code after a specified compilation…
Link42
  • 43
  • 4
2
votes
1 answer

Play framework route file compilation warning: local val in method at is never used

On my play app, I have a routes file with routes for public files. Recently I added the -Ywarn-unused compiler flag, and I'm getting some unexpected warnings. Steps: activator new testingScalac (choose play-scala from the template list) Add to…
pedrorijo91
  • 7,635
  • 9
  • 44
  • 82
2
votes
1 answer

Scala Removing Generic Type Information

I have a scala project that is generating a jar. I'm trying to use the jar in a Java project. The weird thing is the method signatures are losing generic type information when they are compiled to .class files. def foo(x:List[Long]) = ... …
Tim
  • 1,013
  • 1
  • 10
  • 16
2
votes
0 answers

Extract all symbols defined in a scala source file using Scala Compiler API

I'm trying to extract all (but I'm mostly interested in classes/objects) symbols defined in a scala source file from a Java app using Scala Compiler API. I'm able to compile a source file using scala.tools.nsc.Global.Run.compileSources, but how to…
Filipp
  • 859
  • 1
  • 6
  • 20
2
votes
2 answers

scala Ywarn-all usage

I'm trying to use scala compiler Y warnings, but I don't think I'm doing it right. In the example below, nums is unused, hence I'd expect -Ywarn-value-discard to print a warning for that. There are two if conditions, one nested inside the other.…
0fnt
  • 8,211
  • 9
  • 45
  • 62
2
votes
1 answer

Scalac hanging on phase typer of RegexParser

I have a scala program which among other things has a parser-combinator. This is done by extending scala.util.parsing.combinator.RegexParsers. I had developed it using Scala 2.10 and all was working fine. Yesterday I upgraded my system to Scala…
jbx
  • 21,365
  • 18
  • 90
  • 144
2
votes
3 answers

How are final val defined inside a trait treated by Scala Compiler?

I use very often the selfless trait pattern and I need to use "expensive" constants inside the trait: I would like to have a single instance of these values, which might require several steps to be computed, in all my application. However, the…
Edmondo
  • 19,559
  • 13
  • 62
  • 115
2
votes
0 answers

scalac's dependencyfile option doesn't work?

I was reading a previous stack overflow question about setting up ant tasks for scalac: FSC recompiles every time The weird thing is when I test the -dependencyfile option, I find no dependency file generated anywhere. I am testing this with…
Li He
  • 46
  • 4
2
votes
2 answers

Do scalac "-deprecation" and "-unchecked" compiler options make it slower

Anecdotally, our builds seem slower after enabling these options. I've searched online a bit and tried to do some comparisons but found nothing conclusive. Wondering if anyone knows offhand.
dyross
  • 741
  • 5
  • 18