diff options
author | Felix Mulder <felix.mulder@gmail.com> | 2016-10-18 15:25:51 +0200 |
---|---|---|
committer | Felix Mulder <felix.mulder@gmail.com> | 2016-11-04 14:00:41 +0100 |
commit | 8ea583671a0dc88a9a8ef59eb4f60d70541adfce (patch) | |
tree | 58abb041ba728118c25a036b0f5f831503b79181 | |
parent | 26e98d35c35f251c0f3ab785b7fbc19f5869da8d (diff) | |
download | dotty-8ea583671a0dc88a9a8ef59eb4f60d70541adfce.tar.gz dotty-8ea583671a0dc88a9a8ef59eb4f60d70541adfce.tar.bz2 dotty-8ea583671a0dc88a9a8ef59eb4f60d70541adfce.zip |
Fix #1604: print outer context if applicable
-rw-r--r-- | src/dotty/tools/dotc/reporting/MessageRendering.scala | 8 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Inliner.scala | 10 |
2 files changed, 13 insertions, 5 deletions
diff --git a/src/dotty/tools/dotc/reporting/MessageRendering.scala b/src/dotty/tools/dotc/reporting/MessageRendering.scala index 6d9e45a6e..79632c965 100644 --- a/src/dotty/tools/dotc/reporting/MessageRendering.scala +++ b/src/dotty/tools/dotc/reporting/MessageRendering.scala @@ -15,6 +15,12 @@ trait MessageRendering { def stripColor(str: String): String = str.replaceAll("\u001B\\[[;\\d]*m", "") + def outer(pos: SourcePosition, prefix: String)(implicit ctx: Context): List[String] = + if (pos.outer.exists) { + s"$prefix| This location is in code that was inlined at ${pos.outer}" :: + outer(pos.outer, prefix) + } else Nil + def sourceLines(pos: SourcePosition)(implicit ctx: Context): (List[String], List[String], Int) = { var maxLen = Int.MinValue def render(xs: List[Int]) = @@ -92,7 +98,7 @@ trait MessageRendering { val (srcBefore, srcAfter, offset) = sourceLines(pos) val marker = columnMarker(pos, offset) val err = errorMsg(pos, msg.msg, offset) - sb.append((srcBefore ::: marker :: err :: srcAfter).mkString("\n")) + sb.append((srcBefore ::: marker :: err :: outer(pos, " " * (offset - 1)) ::: srcAfter).mkString("\n")) } else sb.append(msg.msg) sb.toString } diff --git a/src/dotty/tools/dotc/typer/Inliner.scala b/src/dotty/tools/dotc/typer/Inliner.scala index 40c1ca350..4869b5e16 100644 --- a/src/dotty/tools/dotc/typer/Inliner.scala +++ b/src/dotty/tools/dotc/typer/Inliner.scala @@ -236,10 +236,12 @@ object Inliner { def inlineCall(tree: Tree, pt: Type)(implicit ctx: Context): Tree = if (enclosingInlineds.length < ctx.settings.xmaxInlines.value) new Inliner(tree, bodyToInline(tree.symbol)).inlined(pt) - else errorTree(tree, - i"""Maximal number of successive inlines (${ctx.settings.xmaxInlines.value}) exceeded, - | Maybe this is caused by a recursive inline method? - | You can use -Xmax:inlines to change the limit.""") + else errorTree( + tree, + i"""|Maximal number of successive inlines (${ctx.settings.xmaxInlines.value}) exceeded, + |Maybe this is caused by a recursive inline method? + |You can use -Xmax:inlines to change the limit.""" + ) /** Replace `Inlined` node by a block that contains its bindings and expansion */ def dropInlined(inlined: tpd.Inlined)(implicit ctx: Context): Tree = { |