@@ -13,6 +13,7 @@ import core.Mode
1313import dotty .tools .dotc .core .Symbols .{Symbol , NoSymbol }
1414import diagnostic .messages ._
1515import diagnostic ._
16+ import ast .{tpd , Trees }
1617import Message ._
1718
1819object Reporter {
@@ -89,21 +90,25 @@ trait Reporting { this: Context =>
8990 }
9091
9192 def warning (msg : => Message , pos : SourcePosition = NoSourcePosition ): Unit =
92- reportWarning(new Warning (msg, pos))
93+ reportWarning(new Warning (msg, addInlineds( pos) ))
9394
94- def strictWarning (msg : => Message , pos : SourcePosition = NoSourcePosition ): Unit =
95- if (this .settings.strict.value) error(msg, pos)
96- else reportWarning(new ExtendMessage (() => msg)(_ + " \n (This would be an error under strict mode)" ).warning(pos))
95+ def strictWarning (msg : => Message , pos : SourcePosition = NoSourcePosition ): Unit = {
96+ val fullPos = addInlineds(pos)
97+ if (this .settings.strict.value) error(msg, fullPos)
98+ else reportWarning(new ExtendMessage (() => msg)(_ + " \n (This would be an error under strict mode)" ).warning(fullPos))
99+ }
97100
98101 def error (msg : => Message , pos : SourcePosition = NoSourcePosition ): Unit =
99- reporter.report(new Error (msg, pos))
102+ reporter.report(new Error (msg, addInlineds( pos) ))
100103
101- def errorOrMigrationWarning (msg : => Message , pos : SourcePosition = NoSourcePosition ): Unit =
102- if (ctx.scala2Mode) migrationWarning(msg, pos) else error(msg, pos)
104+ def errorOrMigrationWarning (msg : => Message , pos : SourcePosition = NoSourcePosition ): Unit = {
105+ val fullPos = addInlineds(pos)
106+ if (ctx.scala2Mode) migrationWarning(msg, fullPos) else error(msg, fullPos)
107+ }
103108
104109 def restrictionError (msg : => Message , pos : SourcePosition = NoSourcePosition ): Unit =
105110 reporter.report {
106- new ExtendMessage (() => msg)(m => s " Implementation restriction: $m" ).error(pos)
111+ new ExtendMessage (() => msg)(m => s " Implementation restriction: $m" ).error(addInlineds( pos) )
107112 }
108113
109114 def incompleteInputError (msg : => Message , pos : SourcePosition = NoSourcePosition )(implicit ctx : Context ): Unit =
@@ -135,6 +140,14 @@ trait Reporting { this: Context =>
135140
136141 def debugwarn (msg : => String , pos : SourcePosition = NoSourcePosition ): Unit =
137142 if (this .settings.Ydebug .value) warning(msg, pos)
143+
144+ private def addInlineds (pos : SourcePosition )(implicit ctx : Context ) = {
145+ def recur (pos : SourcePosition , inlineds : List [Trees .Tree [_]]): SourcePosition = inlineds match {
146+ case inlined :: inlineds1 => pos.withOuter(recur(inlined.sourcePos, inlineds1))
147+ case Nil => pos
148+ }
149+ recur(pos, tpd.enclosingInlineds)
150+ }
138151}
139152
140153/**
0 commit comments