Questions tagged [scalac]

scalac - Compiler for the Scala 2 language

176 questions
4
votes
1 answer

How to properly use scalac -Xlint

scalax -Xlint help provides the following info: $ scalac -Xlint:help Enable or disable specific warnings adapted-args Warn if an argument list is modified to match the receiver. nullary-unit Warn when nullary methods…
pedrorijo91
  • 7,635
  • 9
  • 44
  • 82
4
votes
1 answer

Why does space in backtick constructor params break the compiler?

A certain combination of whitespace and ordering together with backticks in parameter names where the backticked name has the same leading chars as another param seems to mislead the compiler into producing compile errors: The declaration case…
kostja
  • 60,521
  • 48
  • 179
  • 224
4
votes
1 answer

Unable to resolve path dependent type class evidence w/o having value type accessible

I got stuck for like an hour to discover this fact: class Foo { trait TypeClass[X] object TypeClass { implicit val gimme = new TypeClass[Int]{} } def foo[X : TypeClass](p: X): Unit = println("yeah " + p) } // compiles val foo =…
lisak
  • 21,611
  • 40
  • 152
  • 243
4
votes
2 answers

Display exact scala command issued from SBT build

When I build my (relatively complex) SBT project against a local version of Scala, I am getting the following error: scalac error: bad option: '-Ydelambdafy:method' This is potentially a bug in scalac or our buildfile. However, I am unable to…
gzm0
  • 14,752
  • 1
  • 36
  • 64
3
votes
1 answer

Line Level Scala Coverage Reports w/ Emma / Ant

Are there any tricks that I need to use to get Line Level coverage reports working w/ Scala code using Emma? I can get it working w/ Java code fine, but for some reason the debug info is not getting into the class files when I use scalac. Any help…
fbl
  • 2,840
  • 3
  • 33
  • 41
3
votes
1 answer

Scala 2 Append A Method To Class Body (Metaprogramming)

I have been stuck on this issue for a week and don't seem to be getting anywhere. I am trying to copy some methods and fields from one class to another. I have two phases that are involved in this. The first phase scans the code, finds the method…
sinanspd
  • 2,589
  • 3
  • 19
  • 37
3
votes
1 answer

Scala Compiler Plugin Rewrite Function Definition As A Tuple: error: not found: value scala.Tuple2

I am writing a compiler plugin to rewrite a function definition as a tuple of the function hash + function body So the following def f(a: Int, b: Int) : Int = (a + b) would turn into val f = ("some-complex-hash", (a: Int, b: Int) => (a + b)) Let…
sinanspd
  • 2,589
  • 3
  • 19
  • 37
3
votes
3 answers

Permanently hidden warning from Scalac parsing Java code - compiler bug?

The scalac Java parser is taking objection to my Java code imported `Entity' is permanently hidden by definition of object Entity in package domain Asset.java This seems to be a collision between an import and a class with the same name in the…
Duncan McGregor
  • 17,665
  • 12
  • 64
  • 118
3
votes
1 answer

Adding scala-compiler.jar as a runtime dependency

I'm using sbt and its Proguard plugin to create an executable jar for my program. However, my program relies on scala-compiler.jar at runtime to do compilations. I can't seem to get scala-compiler.jar into my final jar. This page has some very…
Yuvi Masory
  • 2,644
  • 2
  • 27
  • 36
3
votes
1 answer

Implicit resolution choosing the most specific subtype

Can some one explain me why scala resolve the most generic implicit no matter of local scope implicit more specific ? Example: import scala.math.ScalaNumber type Serializer[T] = T => String object SerializedOps{ implicit class AnyOps[T](t: T){ …
David Geirola
  • 616
  • 3
  • 17
3
votes
1 answer

How to apply class exclusions to Scalac warnings options?

We have problems when using Scalac -Xfatal-warnings in the following cases: Implicit vals used by macros internally Internal vals that macros auto-generate In both cases, we see Scalac failing to compile because it detects some values are not…
Edmondo
  • 19,559
  • 13
  • 62
  • 115
3
votes
1 answer

Is there any help for lazy argument passing in Scala?

It could sound like a rookie mistake but I do a lot of that. While passing lazy evaluated block or value into a function, if I forget somehow make that function's corresponding parameter lazy (pass/call by name) its causing some confusions at first…
altayseyhan
  • 735
  • 1
  • 7
  • 18
3
votes
2 answers

JSON to Scala code generation

I have a JSON which is an output of another application, I want to make dynamic Scala code (*.scala file ) from this JSON (can not pre define class/bean as the JSON structure depends many other parameters). Is there any API available for this ?
Isabel Jinson
  • 8,541
  • 16
  • 59
  • 75
3
votes
4 answers

Scala recursive val behaviour

What do you think prints out? val foo: String = "foo" + foo println(foo) val foo2: Int = 3 + foo2 println(foo2) Answer: foonull 3 Why? Is there a part in specification that describes/explains this? EDIT: To clarify my astonishment - I do realize…
slouc
  • 9,508
  • 3
  • 16
  • 41
3
votes
2 answers

FSC recompiles every time

FSC recompiles my .scala files every time even there is no need - I can compile it twice without editing anything between attempts and it recompiles them! For example, I have 2 files Hello.scala class Hello{ print("hello") } And…
Jeriho
  • 7,129
  • 9
  • 41
  • 57