Merge pull request #1509 from sbt/fix/1501

Fixes #1181/#1501. Fixes ArrayIndexOutOfBoundsException: -1
This commit is contained in:
Josh Suereth 2014-08-08 13:39:01 -04:00
commit fbf9d72607
2 changed files with 17 additions and 2 deletions

View File

@ -348,8 +348,21 @@ final class Eval(optionsNoncp: Seq[String], classpath: Seq[File], mkReporter: Se
val DefaultStartLine = 0
private[this] def makeModuleName(hash: String): String = "$" + Hash.halve(hash)
private[this] def noImports = new EvalImports(Nil, "")
private[this] def mkUnit(srcName: String, firstLine: Int, s: String) = new CompilationUnit(new EvalSourceFile(srcName, firstLine, s))
private[sbt] def noImports = new EvalImports(Nil, "")
private[sbt] def mkUnit(srcName: String, firstLine: Int, s: String) = new CompilationUnit(new EvalSourceFile(srcName, firstLine, s)) {
// This is overridden as a workaround for #1181/#1501,
// When the compiler reports an error back, the position sometimes comes back with source set to NoSourceFile.
override def error(pos0: Position, msg: String) = {
import scala.reflect.internal.util._
val pos = pos0 match {
case op: OffsetPosition if op.point >= 0 =>
if (op.source eq source) op
else new OffsetPosition(source, op.point)
case _ => pos0
}
super.error(pos, msg)
}
}
private[this] def checkError(label: String) = if (reporter.hasErrors) throw new EvalException(label)
private[this] final class EvalSourceFile(name: String, startLine: Int, contents: String) extends BatchSourceFile(name, contents) {

View File

@ -2,6 +2,7 @@
[856]: https://github.com/sbt/sbt/issues/856
[1036]: https://github.com/sbt/sbt/pull/1036
[1059]: https://github.com/sbt/sbt/issues/1059
[1181]: https://github.com/sbt/sbt/issues/1181
[1194]: https://github.com/sbt/sbt/issues/1194
[1200]: https://github.com/sbt/sbt/issues/1200
[1213]: https://github.com/sbt/sbt/issues/1213
@ -96,6 +97,7 @@
- sbt no longer crashes when run in root directory [#1488][1488] by [@jsuereth][@jsuereth]
- set no longer removes any `++` scala version setting. [#856][856]/[#1489][1489] by [@jsuereth][@jsuereth]
- Fixes `Scope.parseScopedKey`. [#1384][1384] by [@eed3si9n][@eed3si9n]
- Fixes `build.sbt` errors causing `ArrayIndexOutOfBoundsException` due to invalid source in position. [#1181][1181] by [@eed3si9n][@eed3si9n]
### enablePlugins/disablePlugins