Questions tagged [scala-compiler]
135 questions
4
votes
2 answers
Scala: can compiler optimize constants efficiently?
Let's consider the following:
object Foo {
val BUFFER_SIZE = 1024
}
class Foo {
.
.
.
val buffer = new Array[Byte](Foo.BUFFER_SIZE)
This is too verbose and doesn't seem to be elegant compared with Java's static (final) variable,…

K J
- 4,505
- 6
- 27
- 45
4
votes
1 answer
MissingRequirementError when Compiling Scala code with Global.Run
I'm trying to compile Scala files programmatically by using an instance of Global.Run:
val settings = new Settings
val reporter = new ConsoleReporter(settings)
val compiler = new Global(settings, reporter)
val run = new compiler.Run…

Matthias Meid
- 12,455
- 7
- 45
- 79
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 Implicit Method Compilation when Method Tries to Access Non-Existing Case Class Members
I did run into an scala compiler issue with implicit methods. The scenario is quite easy. The task of the implicit method is to turn an object of the case class A into an object of the case class B. The implicit method implementation accesses a case…

joel
- 480
- 1
- 5
- 9
3
votes
1 answer
How to configure IntelliJ Scala Plugin to use Scala's native presentation compiler?
Although IntelliJ Scala Plugin uses Scala compiler proper to generate the actual bytecode, it seems to use its own implementation of presentation compiler to provide real-time type-aware error highlighting in the editor:
syntax highlighting feature…

Mario Galic
- 47,285
- 6
- 56
- 98
3
votes
2 answers
How to override value when value types have a different number of type parameters?
Why does this happily compile,
class Foo[T]
class DerivedFoo[T] extends Foo[T]
class Bar(val foo: Foo[_])
class DerivedBar(override val foo: DerivedFoo[_]) extends Bar(foo)
while this does not?
class OtherDerivedFoo[T, U] extends Foo[T]
class…

Lasf
- 2,536
- 1
- 16
- 35
3
votes
1 answer
IntelliJ IDEA 2017.3.4 & Scala compile server : IDE can't connect to its own local server
I'm using IntelliJ IDEA 2017.3.4 as Scala IDE.
I have activate the "Build project automatically" option and set the Java 8 JDK as default project SDK.
Bellow, the Scala compiler server configuration
The Scala compiler server is running and listen…

JimyRyan
- 359
- 1
- 2
- 17
3
votes
2 answers
How does Scala's type erasure work for higher kinded type parameters?
I don't understand which generic type parameters Scala erases. I used to think that it should erase all generic type parameters, but this does not seem to be the case.
Correct me if I'm wrong: if I instantiate an instance of type Map[Int, String] in…

Andrey Tyukin
- 43,673
- 4
- 57
- 93
3
votes
1 answer
Scala compiler output after cleanup phase
I would like to develop a tool that post-processes a scala program once all the heavy lifting has been completed by the Scala compiler. From what I understand the different phases of the Scala compiler incrementally simplify the program in terms of…

Than21
- 321
- 1
- 2
- 10
3
votes
1 answer
How to get the full class name of a dynamically created class in Scala
I have a situation where I have to get the fully qualified name of a class I generate dynamically in Scala. Here's what I have so far.
import scala.reflect.runtime.universe
import scala.tools.reflect.ToolBox
val tb =…

Jon
- 3,985
- 7
- 48
- 80
3
votes
1 answer
Method in sealed trait gives Duplicate field name & signature in class file
When I add process() on IntList it gives a runtime "Duplicate field name&signature in class file Cons$3...". This happens only when the sealed trait is defined inside a function.
scala> def t4() = {
|
| sealed trait IntList {
| …

neverlastn
- 2,164
- 16
- 23
3
votes
1 answer
Functor misses implicit value for parameter instance (only after sbt clean)
I did some experiments with Kittens (https://github.com/milessabin/kittens) and have issues with compiling my code. I receive the following error.
[error] ...danirey\scala\kittens\Kittens.scala:23: could not find implicit value for parameter…

DaniRey
- 61
- 5
3
votes
1 answer
How to use fsc with sbt?
Related question: Does SBT use the Fast Scala Compiler (fsc)?
Can fsc be used with sbt; would it be practical; and if so, how to integrate fsc into sbt?

Dominykas Mostauskis
- 7,797
- 3
- 48
- 67
3
votes
3 answers
Intermediate language used in scalac?
In the GCC compiler we see several 'intermediate languages': RTL, GENERIC and GIMPLE.
This answer hints at the idea of an intermediate representation in scalac.
My question is: is there an 'intermediate representation' of the compiler in Scala? Is…

hawkeye
- 34,745
- 30
- 150
- 304
3
votes
1 answer
Resolving the dependency of Scala Macros and Compiler Framework in SBT
I am trying to write a framework to make writing Scala compiler plugins easier, what I am doing is writing a framework on top of the Scala quasiquotes. So my project depends on macros from macro-paradise and both scala-compiler and scala-reflect…

Amanj Sherwany
- 236
- 2
- 13