Questions tagged [scala-compiler]
135 questions
1
vote
0 answers
Scala Lower Bounds Error: value is not a member of type parameter
The scala compiler seems to give false type-errors for statements with multiple lower bounds.
Given class Foo with the method g using a lower bound for A and B
class Foo[A, B](a: A, b: B) {
def g[T, A1 >: A <: T, B1 >: B <: T] = List[T](a: A1, b:…

anselm
- 76
- 4
1
vote
1 answer
Compile Scala Object using NSC
Could someone give a simple example of how I'd use scala.tools.nsc to compile a Scala class during runtime from within a JVM? I'm experimenting with some dynamic behavior where I want to be able to compile Scala classes during runtime, then load…

John Stanford
- 993
- 1
- 7
- 18
1
vote
0 answers
Scala 2.11 refined with scalatest MustMatchers and Await causes compiler error "trying to do lub/glb of typevar ?F[?T, ?B]"
I have been trying to use the refined with scalatest and am getting compiler errors at the "typer" phase: trying to do lub/glb of typevar ?F[?T, ?B]
This is my best attempt at a minimalist reproduction of the issue using a self-contained ammonite…

rmin
- 1,018
- 1
- 9
- 18
1
vote
0 answers
Accessing documentation comments in a Scala compiler plugin
I want to access documentation comments from a Scala compiler plugin running after typer stage.
scala.tools.nsc.Global extends DocComments, so I assumed it would be as simple as calling global.cookedDocComment(symbol) but it returns empty string…

Alexey Romanov
- 167,066
- 35
- 309
- 487
1
vote
0 answers
How to create a Scala presentation compiler inside Ammonite REPL?
I want to create a Scala presentation compiler in Ammonite REPL, however I always got the error of Missing dependency 'object scala in compiler mirror'.
I have tried the workaround mentioned in object scala in compiler mirror not found - running…

Yang Bo
- 3,586
- 3
- 22
- 35
1
vote
0 answers
scalac plugin : how to get it working after typer phase with a missing jar
I'm currently trying to build a plugin that visits the AST produced by Scala to run some rule checks. So far, it only pretty prints the AST to get an hand in. AFAK, this plugin may run after different phases, but I tried with those two :
namer :…

Jeff
- 11
- 3
1
vote
4 answers
Complexity of mapping identity function to a Scala collection?
When I apply the Scala predefined identity function to a collection using the map method the original collection is returned unchanged. However, is the compiler smart enough to simply return the unchanged collection as an O(1) operation? Or will…

davidrpugh
- 4,363
- 5
- 32
- 46
1
vote
1 answer
Debug Scala compiler plugin in IntelliJ IDEA
I would like to write my compiler plugin for scalac, but I get a problem in early state in development because I cannot run and debug my code from IntelliJ IDEA.
I use these tutorials for implementing a dummy plugin:
Scalac plugin template
An old…

Zoltán Kollár
- 15
- 3
1
vote
1 answer
Parse a file to AST with non-interactive scala.tools.nsc.Global
In scala.tools.nsc.interactive.Global, there is a parseTree method. I'd like to get the AST from a file using scala.tools.nsc.Global instead. Looking at parseTree definition, I wrote
val settings = new…

Alexey Romanov
- 167,066
- 35
- 309
- 487
1
vote
1 answer
InvocationTargetException. Cannot cast class X to class X. When invoked in Scala Imain through spark-submit
So, I have the following use case.
I'm simplifying the usage of Spark dataframes for a particular domain by providing a DSL like interface.
All this code goes in a fat jar created by maven shade plugin. (fat jar = without spark and hadoop…

Dhruv Kapur
- 726
- 1
- 8
- 24
1
vote
1 answer
Finding type signatures of all non-synthetic methods/functions in Scala
I'm trying to find a way to get at the symbol table (?) of the Scala compiler and dump all the type information on the methods/functions in say, a particular SBT project. The current direction I'm going is a compiler plugin, hooking into it right…

adelbertc
- 7,270
- 11
- 47
- 70
1
vote
1 answer
Scala TypeTag to java.lang.reflect.Type
I wonder if there are some predefined functions in scala (2.10+) to convert a scala TypeTag to a java.lang.reflect.Type.
Note that I have seen this question, but I need complete generic type information at runtime.
If it is not the case I can still…

eugen
- 5,856
- 2
- 29
- 26
1
vote
1 answer
What's the difference between type `()Int` and `Int` in Scala `IMain` v. 2.11?
I've been playing around with the new API for the compiler and repl in 2.11 and have hit something weird. Here's my repl output:
Welcome to Scala version 2.11.0-20140415-163722-cac6383e66 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_51).
Type in…

Todd O'Bryan
- 2,234
- 17
- 30
1
vote
0 answers
Scala-compiler: Add jar to class path
I have the following code:
import scala.tools.nsc.{Settings,Global}
val setts = new Settings
setts.outputDirs.setSingleOutput("/sdat/projects/prStrat/Saves")
setts.classpath.append("/sdat/projects/prStrat/Saves/Strat.jar")
val comp = new…

Rich Oliver
- 6,001
- 4
- 34
- 57
1
vote
1 answer
Scala Compiler generate throw code
I am trying to change a compiler plugin some other person wrote which runs directly after the typer and I want to generate code that throws an Exception.
The Exception class looks like this:
case class MyException(message: String) extends…

Lykos
- 1,039
- 6
- 25