scalac

Display exact scala command issued from SBT build

为君一笑 提交于 2019-12-11 02:03:52
问题 When I build my (relatively complex) SBT project against a local version of Scala, I am getting the following error: scalac error: bad option: '-Ydelambdafy:method' This is potentially a bug in scalac or our buildfile. However, I am unable to reproduce this error while invoking scalac directly: $ scalac -Ydelambdafy:method test.scala This runs as expected. Is there a way I can make SBT display the exact scalac command it issues? (Note that passing the exact flags from scalacOptions to scalac

What is a ScalaSignature?

﹥>﹥吖頭↗ 提交于 2019-12-11 01:38:22
问题 When decompiling Scala files to Java code, one often comes across classes that are annotated with the ScalaSignature s. These seem to only have one annotation value, a somewhat encoded String. Why does the Scala Compiler create such an odd construct, instead of using custom Attribute s in the class file? 回答1: From Storage of pickled Scala signatures in class files: The legacy method for storing signatures as attributes is simultaneously more elegant, more compact (about 15%) and simpler than

What is the 8-bit simulator in scala compiler and how to launch it?

霸气de小男生 提交于 2019-12-10 14:59:14
问题 I was reading this question and saw: scalac includes an 8-bit simulator of a fully armed and operational battle station, viewable using the magic key combination CTRL-ALT-F12 during the GenICode compilation phase. To show what compilation phases scalac has, I used scalac -Xshow-phases . phase name id description ---------- -- ----------- < ... > icode 23 generate portable intermediate code Seems to be the relevant phase. I compile a Hello-world program object Hello { def main(args: Array

scala does not warn about unused computation or value

穿精又带淫゛_ 提交于 2019-12-10 14:16:21
问题 I have this little scala example: object Test { def add(x: Int, y: Int) = { val z = x - y x match { case 0 => 0 - y case 1 => 1 - y case _ => x - y } x + y } def main(args: Array[String]) { println(add(5, 6)) } } I feel that scala should warn about 'z' and the 'x match ...' being unused. I did not notice any compiler options to turn on more warnings. I'm using scala 2.10.1. Thoughts? Thanks! 回答1: As you can see here, "unused" warnings will be introduced in the next version of scala, 2.11.

Scalac hanging on phase typer of RegexParser

假如想象 提交于 2019-12-10 11:25:30
问题 I have a scala program which among other things has a parser-combinator. This is done by extending scala.util.parsing.combinator.RegexParsers . I had developed it using Scala 2.10 and all was working fine. Yesterday I upgraded my system to Scala 2.11.4, together with IntelliJ 14.02 (not that it matters). However, whenever I try to compile this program now, scalac hangs during this phase: scalac: phase typer on MyParser.scala I changed absolutely nothing to this code, I can't understand why it

FSC recompiles every time

主宰稳场 提交于 2019-12-07 17:47:53
问题 FSC recompiles my .scala files every time even there is no need - I can compile it twice without editing anything between attempts and it recompiles them! For example, I have 2 files Hello.scala class Hello{ print("hello") } And Tokens.scala: abstract class Token(val str: String, val start: Int, val end: Int) {override def toString = getClass.getSimpleName + "(" + "[" + start + "-" + end + "]" + str + ")"} class InputToken(str: String, start: Int, end: Int) extends Token(str, start, end)

Adding a library dependency via an sbt plugin - per sub-project

会有一股神秘感。 提交于 2019-12-07 00:26:37
问题 I am trying to add a library dependency through an sbt plugin. The dependency should be added to each sub-project per its binary scala version, so I iterate through each subproject. private def inject(): State => State = { state => val extracted: Extracted = Project.extract(state) val enrichedLibDepSettings = extracted.structure.allProjectRefs map { projRef => val projectScalaVersion = (scalaBinaryVersion in projRef) libraryDependencies in projRef += compilerPluginOrg %

Scala "Hello,world!" 程序

大憨熊 提交于 2019-12-06 16:07:56
"Hello, world!" 程序 首先我们使用标准的 “Hello, world!” 程序来演示一下 Scala 的简单使用 object HelloWorld { def main(args: Array[String]): Unit = { println("Hello, world!") } } 这个程序的结构对于 Java 程序员来说应该比较熟悉: 程序由 main 方法组成, 它使用命令行参数即一个字符串数组作为参数; main 方法体由一个对预定义函数 println 的简单调用组成, println函数使用 “Hello, world!” 作为参数, 最终结果会将 “Hello, world!” 打印输出到标准输出。main 方法没有返回值 (它是一个过程函数). 因此没有必要声明一个返回值类型。 而对于 Java 程序员来说不那么熟悉的是 object 声明包含了 main 方法。 这样一种声明介绍通常被称为一个 单例对象 , 即一个只有单个实例的类。因此*** object 声明既声明了一个叫做 HelloWorld 的类, 又声明了这个类的一个实例, 它也叫做 HelloWorld***。这个实例在第一次使用的时候创建。 细心的读者可能会注意到 main 方法没有声明为 static。这是因为 Scala 中不存在静态的成员(方法或字段) 。Scala

Scalac hanging on phase typer of RegexParser

ε祈祈猫儿з 提交于 2019-12-06 08:51:40
I have a scala program which among other things has a parser-combinator. This is done by extending scala.util.parsing.combinator.RegexParsers . I had developed it using Scala 2.10 and all was working fine. Yesterday I upgraded my system to Scala 2.11.4, together with IntelliJ 14.02 (not that it matters). However, whenever I try to compile this program now, scalac hangs during this phase: scalac: phase typer on MyParser.scala I changed absolutely nothing to this code, I can't understand why it is hanging or from where I should start. IntelliJ had a warning about postfix operators for parser

FSC recompiles every time

烈酒焚心 提交于 2019-12-05 21:23:50
FSC recompiles my .scala files every time even there is no need - I can compile it twice without editing anything between attempts and it recompiles them! For example, I have 2 files Hello.scala class Hello{ print("hello") } And Tokens.scala: abstract class Token(val str: String, val start: Int, val end: Int) {override def toString = getClass.getSimpleName + "(" + "[" + start + "-" + end + "]" + str + ")"} class InputToken(str: String, start: Int, end: Int) extends Token(str, start, end) class ParsedToken(str: String, start: Int, end: Int, val invisible: Boolean) extends Token(str, start, end)