Questions tagged [scalac]
scalac - Compiler for the Scala 2 language
scalac
176
questions
1
vote
1
answer
80
views
How to remove comments from the scala code
Any ideas how to remove comments from the scala code so that:
Nested multi line or single line comments are removed.
Comments inside string literals are not removed.
Code can have single and triple ...
0
votes
1
answer
173
views
Scala case class method: `public scala.collection.Iterator<java.lang.String> productElementNames()`
if we have a look into the bytecode produced by this case class compilation
case class Person(name: String, age: Int)
we get besides others this method:
public scala.collection.Iterator<java....
1
vote
1
answer
216
views
How to compile a scala program without any builder?
I am trying to compile this simple code in scala to run it in spark:
import org.apache.spark.sql.SparkSession
...
1
vote
2
answers
184
views
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 ...
0
votes
0
answers
20
views
Can't add resources in jar generated by scalac
I have file in with an SQL query, which I need to run using SparkSQL. Since the file is too big, I don't want to copy it straight into the code.
.
├──_main.scala
├──_resources
│ └── query.sql
...
3
votes
1
answer
229
views
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. ...
1
vote
1
answer
223
views
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(...
0
votes
0
answers
55
views
How to write scala jar executable by Java to fetch hostname of the machine?
I want to perform this activity in Scala and execute it with Java:
hostname -i
The scala code for this is:
import java.net._
object HostName {
def main(args: Array[String]){
val ...
0
votes
1
answer
394
views
Running Scala function from command line
I'm working on an exercise. I need to create a java project that can be run from the scala command line. The final output should be this:
scala> int2str(6)
res0: String = six
scala> int2str(65)
...
4
votes
0
answers
409
views
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/<macro>:5:204: parameter value ...
5
votes
1
answer
1k
views
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[_ &...
0
votes
1
answer
96
views
Compiling with scalac does not find sbt dependencies
I tried running my Scala code in VSCode editor. I am able to run my script via spark-submit command. But when I am trying with scalac to compile, I am getting:
.\src\main\scala\sample.scala:1: error: ...
0
votes
1
answer
82
views
Is there scala compiler option that makes ` Option[T](t).map(x => null)` return None instead of Some(null)
I've enterprise polyglot codebase which is made of java and scala.
We have lot of places where we do map function on Option[T] and the mapping function is legacy code which returns null.
Option(2).map(...
2
votes
1
answer
1k
views
Assertion failed: Invalid interfaces in / assertion failed: ClassBType.info not yet assigned
I fall on this two errors during compilation of my test part and unfortunately my attemps to find any hint to solve these issues failed.
I tried to clean, rebuild from scratch without any success. I ...
13
votes
1
answer
2k
views
Add Scala 3.0 SDK to IntelliJ
Currently, the dotty compiler released its first Release Candidate and will be released in the next few months.
I updated the IntelliJ scala plugin to EarlyAccess to make it working with Scala 3.0, ...