Skip to content

Commit 5b7298d

Browse files
committed
Fix #1604: print outer context if applicable
1 parent 8bfaada commit 5b7298d

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/dotty/tools/dotc/reporting/ConsoleReporter.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ class ConsoleReporter(
6262
s"$prefix|$whitespace${carets.show}"
6363
}
6464

65+
private def outer(pos: SourcePosition, prefix: String)(implicit ctx: Context): List[String] =
66+
if (pos.outer.exists) {
67+
s"$prefix| This location is in code that was inlined at ${pos.outer}" ::
68+
outer(pos.outer, prefix)
69+
} else Nil
70+
6571
def errorMsg(pos: SourcePosition, msg: String, offset: Int)(implicit ctx: Context) = {
6672
val leastWhitespace = msg.lines.foldLeft(Int.MaxValue) { (minPad, line) =>
6773
val lineLength = stripColor(line).length
@@ -101,7 +107,7 @@ class ConsoleReporter(
101107
val marker = columnMarker(pos, offset)
102108
val err = errorMsg(pos, msg.msg, offset)
103109

104-
printMessage((srcBefore ::: marker :: err :: srcAfter).mkString("\n"))
110+
printMessage((srcBefore ::: marker :: err :: outer(pos, " " * (offset - 1)) ::: srcAfter).mkString("\n"))
105111
} else printMessage(msg.msg)
106112
true
107113
}

src/dotty/tools/dotc/typer/Inliner.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,12 @@ object Inliner {
236236
def inlineCall(tree: Tree, pt: Type)(implicit ctx: Context): Tree =
237237
if (enclosingInlineds.length < ctx.settings.xmaxInlines.value)
238238
new Inliner(tree, bodyToInline(tree.symbol)).inlined(pt)
239-
else errorTree(tree,
240-
i"""Maximal number of successive inlines (${ctx.settings.xmaxInlines.value}) exceeded,
241-
| Maybe this is caused by a recursive inline method?
242-
| You can use -Xmax:inlines to change the limit.""")
239+
else errorTree(
240+
tree,
241+
i"""|Maximal number of successive inlines (${ctx.settings.xmaxInlines.value}) exceeded,
242+
|Maybe this is caused by a recursive inline method?
243+
|You can use -Xmax:inlines to change the limit."""
244+
)
243245

244246
/** Replace `Inlined` node by a block that contains its bindings and expansion */
245247
def dropInlined(inlined: tpd.Inlined)(implicit ctx: Context): Tree = {

0 commit comments

Comments
 (0)