scalac - Compiler for the Scala 2 language
Questions tagged [scalac]
176 questions
5
votes
1 answer
How do I run a Fast Scala Compiler remote server?
I want to set an fsc process running on a box that I can then access remotely.
I understand I need to share a temp directory.
However, I'm struggling to even get it going on my laptop.
I'm trying:
fsc -Djava.io.tmpdir=/tempscala -server…

R u c k s a c k
- 784
- 6
- 17
5
votes
1 answer
Scala compilation error: not found: type _$1
I am researching about existential types in Scala 2.12.x. For that I'm testing the following code:
trait Parent
class ChildA extends Parent
class ChildB extends Parent
def whatIsInside(opt: Option[_ <: Parent]): String = {
opt match {
case _:…

Nicolas Schejtman
- 433
- 2
- 17
5
votes
0 answers
What is the 8-bit simulator in scala compiler and how to launch it?
I was reading this question and saw:
scalac includes an 8-bit simulator of a fully armed and operational battle station, viewable using the magic key combination CTRL-ALT-F12 during the GenICode compilation phase.
To show what compilation phases…

user2829759
- 3,372
- 2
- 29
- 53
5
votes
2 answers
Scala compiler optimization for immutability
Does the scala compiler optimize for memory usage by removing refs to vals used only once within a block?
Imagine an object holding in aggregate some huge data - reaching a size where cloning data or derivatives of it may well scratch the maximum…

matanster
- 15,072
- 19
- 88
- 167
5
votes
0 answers
How do types flow through pattern matches in Scala?
This gist (a partial Scala port of this Haskell tagless interpreter) compiles with scalac 2.11.1, but fails with the newer 2.11.6:
typechecker.scala:55: error: type mismatch;
found : Expr[B] where type B
required: Expr[Int]
case (lhs…

David B.
- 5,700
- 5
- 31
- 52
5
votes
1 answer
What is a ScalaSignature?
When decompiling Scala files to Java code, one often comes across classes that are annotated with the ScalaSignatures. These seem to only have one annotation value, a somewhat encoded String. Why does the Scala Compiler create such an odd construct,…

Clashsoft
- 11,553
- 5
- 40
- 79
5
votes
1 answer
scala does not warn about unused computation or value
I have this little scala example:
object Test {
def add(x: Int, y: Int) = {
val z = x - y
x match {
case 0 => 0 - y
case 1 => 1 - y
case _ => x - y
}
x + y
}
def main(args: Array[String]) {
println(add(5,…

Fysx
- 805
- 1
- 6
- 12
4
votes
3 answers
Scala Range contains(elem: Any) method
Apparently Range has a method that checks if it contains a value of type Any. I understand that it is from SeqLike, but causes some problems.
For instance, i was matching hours from joda.DateTime:
DateTime.now match {
case d if 0 to 12 contains…

F0RR
- 1,590
- 4
- 16
- 30
4
votes
0 answers
How can I tell scalac to suppress warnings is macro-generated code?
I'm currently using a macro (ZIO's @mockable) whose generated code is causing a compilation error that is causing my build to fail:
[error] /home/me/xxx/backend/:5:204: parameter value rts in anonymous function is never used
[error] val…

tjarvstrand
- 836
- 9
- 20
4
votes
2 answers
Fields interfering with method resolution for Scala Dynamic trait?
As my first foray into Dynamic Scala land, I thought that I'd try accessing bean properties via applyDynamic.
My first very rough cut is
trait BeanProperties extends Dynamic {
def applyDynamic(name: String)(args: Any*) = {
if (args.length ==…

Duncan McGregor
- 17,665
- 12
- 64
- 118
4
votes
1 answer
Why does wrapping a method in another method stop type mismatch in Scala - using underscore in type parameter in pattern match?
In the following block of code (with both scala 2.11 and 2.12) the method apply does not compile, while applyInlined does.
package blar
trait Bar[T]
class A
class B
class C
trait Exploder[T] {
// Removing explode and changing Foo so that
//…

samthebest
- 30,803
- 25
- 102
- 142
4
votes
0 answers
Breakpoints in Eclipse for Lagom or Akka code
We are using Eclipse to remote debug Lagom and Akka applications, but Eclipse is not allowing us to put breakpoints in the code.
I am able to put breakpoints in my Scala code, but not in the Akka library.
For example: I am trying add a breakpoint on…

techagrammer
- 1,291
- 8
- 19
4
votes
1 answer
Scalac bug or misunderstanding on my part?
I set the -Xfatal-warnings compiler flag in my SBT build and sure enough this code doesn't compile:
package example
sealed trait Errors
object Errors {
case class BadFirstName(name: String) extends Errors
case class BadLastName(name: String)…
user404345
4
votes
1 answer
Why does scalac need to box an `Int` in a method expecting an `Any`
Consider the following class:
package test
class Test {
def main(args: Array[String]): Unit = {
val i: Int = 0
println(i)
}
}
The bytecode of main is:
public main([Ljava/lang/String;)V
// parameter final args
L0
LINENUMBER 4…

oxbow_lakes
- 133,303
- 56
- 317
- 449
4
votes
3 answers
Java Void to Scala Unit
I have a java library method requiring a class of Void as a parameter. for example, in com.mongodb.async.client.MongoCollection:
void insertOne(TDocument document, SingleResultCallback callback);
I'm accessing this method from scala. Scala…

Luciano
- 2,388
- 1
- 22
- 33