scalac - Compiler for the Scala 2 language
Questions tagged [scalac]
176 questions
2
votes
1 answer
Loading Native library in Scala Compiler Plugin
I am developing a scala compiler plugin. The compiler plugin runs after the "refcheck" phase. It analyzes the AST(Abstract Syntax Tree)
and generates some output. In this plugin, I am loading a native library "scalaz3.dll" using System.loadLibrary
I…

dips
- 1,627
- 14
- 25
1
vote
3 answers
Shebangs in scalac code
The scala interpreter allows shebangs, but strangely, scalac borks on them. Are there any tricks like these to get around this flaw?

mcandre
- 22,868
- 20
- 88
- 147
1
vote
2 answers
Can a Scala compiler plugin transform the autogenerated accessor methods of scala case classes?
After the parser phase of the Scalac process, the following case class
case class ExampleCaseClass(var s:String, var i:Int) extends ContextuallyMutable
takes the intermediate form:
Clazz(case class ExampleCaseClass extends ContextuallyMutable with…

Ben McKenneby
- 481
- 4
- 15
1
vote
1 answer
Scala 3 -Ysafe-init and -Yexplicit-nulls do not report unsafe null inits in classes?
I wrote the following Scala 3 example to test the new explicit nulls feature:
class NullFoo:
var s: String = _
override def toString: String = s"Foo:s=$s"
object NullFoo:
def main(args: Array[String]): Unit =
println(new NullFoo)
My sbt…

Chris W.
- 2,266
- 20
- 40
1
vote
0 answers
Pass information from one compiler component to another without mutation
I am building a compiler plugin that has two components
Permission Accumulator: Load the function definitions and some extra meta data about them into a structure like a Map[String, (...)] where String keys represents the function name and the…

sinanspd
- 2,589
- 3
- 19
- 37
1
vote
0 answers
For a scala compiler, what are the differences between 'Symbol '***' is missing from the classpath' error and 'object *** is not a member' error?
In a recent experiment, I tried to use maven-shade plugin to move all classes in a package com.original.work under a scala library into a different package, and compile into a new project JAR:
…

tribbloid
- 4,026
- 14
- 64
- 103
1
vote
1 answer
Scala Compiler Plugin - Determine whether method is overridden
I am writing a Scala Compiler Plugin with a component the executes after the "jvm" phase where there is need to know that a method is overridden. Here is a distilled version of a test case I am working on:
abstract class GenericController[T] {
…

daltontf1212
- 11
- 1
1
vote
1 answer
Scala compiler-plugin, finding an annotation
I would like this plugin to fetch the contents of an annotation (@Typestate(filename)).
But at the moment even if I print out the entire tree I can't find the annotation anywhere.
How to get an annotation from source code or alternatively, where to…

aurorarized
- 23
- 4
1
vote
1 answer
In scala, are there any condition where implicit view won't be able to propagate to other implicit function?
Assuming that A class called 'summoner' was defined, that is capable of summoning implicit views from the scope:
case class Summoner[R]() {
def summon[T](v: T)(implicit ev: T => R): R = ev(v)
}
I found that it works most of the time, but…

tribbloid
- 4,026
- 14
- 64
- 103
1
vote
2 answers
Problem in scala for-comprehension de-sugar?
I have the following for-comprehension which I de-sugared using command scala -Xprint:parser ForComprehensionDemo.scala. When I copy the de-sugared method and call it, it produces different result than the for-comprehension. Any idea why?
For…

Dangerous Scholar
- 225
- 1
- 3
- 12
1
vote
0 answers
intellij Maven Project throwing java.lang.UnsatisfiedLinkError
Intellij Maven Project set up tried and tested on Linux and Windows works fine, but trying to get it installed and running on one particular Windows machine 7 machine is throwing the below error:
Error:scalac: Error:…

blueberret
- 21
- 1
- 5
1
vote
1 answer
How to compile output of a compiler phase?
Using -Xprint flag in scalac we get output of different compiler phases, for example given the following Foo.scala
object Foo {
val x = 42
}
then scalac -Xprint:jvm Foo.scala outputs
package {
object Foo extends Object {
…

Mario Galic
- 47,285
- 6
- 56
- 98
1
vote
2 answers
getting Suspicious application of an implicit view when converting from Option(lang.Long) to Long
after adding this flag to scalacoptions :
"-Xlint:option-implicit"
I don't understand why am I getting this and how to resolve it
Error:(47, 34) Suspicious application of an implicit view
(scala.Predef.Long2long) in the argument to…

igx
- 4,101
- 11
- 43
- 88
1
vote
1 answer
Scala 2.12.8 macros with Maven
I'm trying to use Scala Macros with Maven!
I found an old answer on Stackoverflow HERE but seems it doesn't work in my case.
I got an error at compile time even if in my code there isn't any macros!
Searching on google i didn't found a lot…

David Geirola
- 616
- 3
- 17
1
vote
0 answers
How do we set scalac options for test environment, not just test file tree?
We want to cause scalac warnings to fail our build in the test/CI environment, but not in a dev environment. We tried this in our build.sbt:
scalacOptions in Test += "-Xfatal-warnings"
However, what that does is cause warnings in the test tree to…

elijah
- 2,904
- 1
- 17
- 21