FSC 每次都重新编译我的 .scala 文件,即使不需要 - 我可以编译它两次,而无需在尝试之间编辑任何内容,它会重新编译它们!例如,我有 2 个文件
你好.scala
class Hello{
print("hello")
}
和 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)
当我要求 ant 从头开始编译项目时,我看到以下输出:
ant compile
init:
[mkdir] Created dir: D:\projects\Test\build\classes
[mkdir] Created dir: D:\projects\Test\build\test\classes
compile:
[fsc] Base directory is `D:\projects\Test`
[fsc] Compiling source files: somepackage\Hello.scala, somepackage\Tokens.scala to D:\projects\Test\build\classes
BUILD SUCCESSFUL
比我不编辑任何东西并再次询问 ant compile :
ant compile
init:
[mkdir] Created dir: D:\projects\Test\build\classes
[mkdir] Created dir: D:\projects\Test\build\test\classes
compile:
[fsc] Base directory is `D:\projects\Test`
[fsc] Compiling source files: somepackage\Tokens.scala to D:\projects\Test\build\classes
BUILD SUCCESSFUL
如您所见,fsc 在 Hello.scala 的情况下表现得很聪明(没有重新编译)而在 Tokens.scala 的情况下表现得很愚蠢。我认为这个问题与继承有关,但仅此而已。
那么有什么问题呢?