diff options
author | Som Snytt <som.snytt@gmail.com> | 2017-02-05 15:59:59 -0800 |
---|---|---|
committer | Som Snytt <som.snytt@gmail.com> | 2017-02-05 15:59:59 -0800 |
commit | 93dc3badee5305a8a82de264cadf2f9398a4492e (patch) | |
tree | d8cd4f39ba9f6682b278a4d1e7a447c496102b13 /src/compiler | |
parent | 7311a29a992db1d3d16a73a9c49c80b0a4383103 (diff) | |
download | scala-93dc3badee5305a8a82de264cadf2f9398a4492e.tar.gz scala-93dc3badee5305a8a82de264cadf2f9398a4492e.tar.bz2 scala-93dc3badee5305a8a82de264cadf2f9398a4492e.zip |
SI-10173 Crash output shows true line number
Where true means 1-based, for whatever tree was last to typer.
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", "") } |