@@ -13,6 +13,7 @@ import core.Mode
13
13
import dotty .tools .dotc .core .Symbols .{Symbol , NoSymbol }
14
14
import diagnostic .messages ._
15
15
import diagnostic ._
16
+ import ast .{tpd , Trees }
16
17
import Message ._
17
18
18
19
object Reporter {
@@ -89,21 +90,25 @@ trait Reporting { this: Context =>
89
90
}
90
91
91
92
def warning (msg : => Message , pos : SourcePosition = NoSourcePosition ): Unit =
92
- reportWarning(new Warning (msg, pos))
93
+ reportWarning(new Warning (msg, addInlineds( pos) ))
93
94
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
+ }
97
100
98
101
def error (msg : => Message , pos : SourcePosition = NoSourcePosition ): Unit =
99
- reporter.report(new Error (msg, pos))
102
+ reporter.report(new Error (msg, addInlineds( pos) ))
100
103
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
+ }
103
108
104
109
def restrictionError (msg : => Message , pos : SourcePosition = NoSourcePosition ): Unit =
105
110
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) )
107
112
}
108
113
109
114
def incompleteInputError (msg : => Message , pos : SourcePosition = NoSourcePosition )(implicit ctx : Context ): Unit =
@@ -135,6 +140,14 @@ trait Reporting { this: Context =>
135
140
136
141
def debugwarn (msg : => String , pos : SourcePosition = NoSourcePosition ): Unit =
137
142
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
+ }
138
151
}
139
152
140
153
/**
0 commit comments