diff options
author | Lukas Rytz <lukas.rytz@gmail.com> | 2017-02-13 11:16:03 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-13 11:16:03 +0100 |
commit | 4bbb7afabe909881a84ed283d7a1b65ef4410973 (patch) | |
tree | 756034075f9393589cea26f445287f45fbea1abe /src/compiler | |
parent | 502e3c6296e5e997549b7e496e0bbfa62c522110 (diff) | |
parent | 93dc3badee5305a8a82de264cadf2f9398a4492e (diff) | |
download | scala-4bbb7afabe909881a84ed283d7a1b65ef4410973.tar.gz scala-4bbb7afabe909881a84ed283d7a1b65ef4410973.tar.bz2 scala-4bbb7afabe909881a84ed283d7a1b65ef4410973.zip |
Merge pull request #5676 from som-snytt/issue/10173
SI-10173 Crash output shows true line number
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/Global.scala | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 873a5947ed..40be302799 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -989,7 +989,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter) ) private def formatExplain(pairs: (String, Any)*): String = ( - pairs.toList collect { case (k, v) if v != null => "%20s: %s".format(k, v) } mkString "\n" + pairs collect { case (k, v) if v != null => f"$k%20s: $v" } mkString "\n" ) /** Don't want to introduce new errors trying to report errors, @@ -1002,9 +1002,10 @@ class Global(var currentSettings: Settings, var reporter: Reporter) val site = lastSeenContext.enclClassOrMethod.owner val pos_s = if (tree.pos.isDefined) s"line ${tree.pos.line} of ${tree.pos.source.file}" else "<unknown>" val context_s = try { + import scala.reflect.io.{File => SFile} // Taking 3 before, 3 after the fingered line. - val start = 0 max (tree.pos.line - 3) - val xs = scala.reflect.io.File(tree.pos.source.file.file).lines drop start take 7 + val start = 1 max (tree.pos.line - 3) + val xs = SFile(tree.pos.source.file.file).lines.drop(start-1).take(7) val strs = xs.zipWithIndex map { case (line, idx) => f"${start + idx}%6d $line" } strs.mkString("== Source file context for tree position ==\n\n", "\n", "") } |