Questions tagged [scala-compiler]

135 questions
37
votes
3 answers

How can I find a description of scala compiler flags/options?

How can I find all of the flags for the latest scalac version? After googling for hours I have found only outdated docs. (for example, they don't even mention "-feature" flag). Is there any way to obtain the list of compiler flags with descriptions…
Jeriho
  • 7,129
  • 9
  • 41
  • 57
25
votes
3 answers

Extracting the complete call graph of a scala project (tough one)

I would like to extract from a given Scala project, the call graph of all methods which are part of the project's own source. As I understand, the presentation compiler doesn't enable that, and it requires going down all the way down to the actual…
matanster
  • 15,072
  • 19
  • 88
  • 167
16
votes
2 answers

What is "Scala Presentation Compiler"?

What is the "Scala Presentation Compiler"?
Ashkan Kh. Nazary
  • 21,844
  • 13
  • 44
  • 68
16
votes
5 answers

Understanding the limits of Scala GADT support

The error in Test.test seems unjustified: sealed trait A[-K, +V] case class B[+V]() extends A[Option[Unit], V] case class Test[U]() { def test[V](t: A[Option[U], V]) = t match { case B() => null // constructor cannot be instantiated to…
Patrick Prémont
  • 948
  • 7
  • 13
16
votes
1 answer

Any info out there on migrating a Scala 2.9 compiler plugin to 2.10?

I have a Scala 2.9 compiler plugin (source code) and works just fine in 2.9 but does not even compile with 2.10. There are dozens (maybe 100+) of errors all of the same kind such as: [scalac] C:\***.scala:31: error: illegal cyclic reference…
Learner
  • 1,215
  • 1
  • 11
  • 26
14
votes
2 answers

What's the effect of -Yrangepos other than giving me source locations in macros

So I googl'ed a bit, but no information other than the sparse: -Yrangepos Use range positions for syntax trees. Ok. And I know I need to use it if I want to capture source fragments in a macro. Now my two questions are: why is…
0__
  • 66,707
  • 21
  • 171
  • 266
14
votes
2 answers

Scala - How to compile code from an external file at runtime?

I want to design a Scala program that accepts Scala files as parameters which can customize the execution of the program. In particular, I want to supply at runtime files that contain implementations of methods that will be invoked by the program. …
Kvass
  • 8,294
  • 12
  • 65
  • 108
14
votes
2 answers

How to invoke the Scala compiler programmatically?

I want my Scala code to take a Scala class as input, compile and execute that class. How can I programmatically invoke a Scala compiler? I will be using the latest Scala version, i.e. 2.10.
Anuj Mehta
  • 1,072
  • 3
  • 13
  • 25
13
votes
1 answer

"scala.runtime in compiler mirror not found" but working when started with -Xbootclasspath/p:scala-library.jar

I'm trying to run a Scala application packed as JAR (including dependencies) but this fails until the Scala library is added by using the -Xbootclasspath/p option. Failing invocation: java -jar…
Augustus Kling
  • 3,303
  • 1
  • 22
  • 25
11
votes
2 answers

create an ambiguous low priority implicit

Consider the default codec as offered in the io package. implicitly[io.Codec].name //res0: String = UTF-8 It's a "low priority" implicit so it's easy to override without ambiguity. implicit val betterCodec: io.Codec =…
jwvh
  • 50,871
  • 7
  • 38
  • 64
11
votes
4 answers

object scala in compiler mirror not found - running Scala compiler programmatically

Running w/ a simple SBT project w/ Java 7 (details below) and invoking sbt run at the command line (no IntelliJ or anything) source import scala.tools.nsc.{ Global, Settings } object Playground extends App { val compiler = new Global(new…
adelbertc
  • 7,270
  • 11
  • 47
  • 70
10
votes
1 answer

Cannot infer contravariant Nothing type parameter

Consider the following snippet: trait X[-T] object Y extends X[Nothing] def a[T](x: X[T]): X[T] = x a(Y) Compilation of the above (2.12.3) fails with: type mismatch; found : Y.type required: X[T] a(Y) ^ This compiles fine if: a…
adamw
  • 8,038
  • 4
  • 28
  • 32
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
6
votes
3 answers

Why collect with pattern match cannot narrow a specific class?

Let's consider following trait: sealed trait AB case class A(a: Int) extends AB case class B(b: Int) extends AB I am trying to collect to limit a collection to specific subclass. If I try to collect, matching individual components and reassembling…
6
votes
2 answers

Why doesn't the scala compiler generate a warning on if statements that always yield false inside a pattern match?

The scala compiler should generate warnings for the if statements I've commented on below, but it doesn't. Why? sealed trait T object A extends T val s:Seq[T] = Seq(A) val result = s.map { //This if should produce a compiler warning case a…
coltfred
  • 1,470
  • 9
  • 17
1
2 3
8 9