@@ -2,16 +2,23 @@ package dotty.tools
2
2
package dotc
3
3
package inlines
4
4
5
- import ast .* , core .*
6
- import Flags .* , Symbols .* , Types .* , Decorators .* , Constants .* , Contexts .*
5
+ import ast .{tpd , * }
6
+ import core .*
7
+ import Flags .*
8
+ import Symbols .*
9
+ import Types .*
10
+ import Decorators .*
11
+ import Constants .*
12
+ import Contexts .*
7
13
import StdNames .tpnme
8
- import transform .SymUtils ._
14
+ import transform .SymUtils .*
9
15
import typer .*
10
16
import NameKinds .BodyRetainerName
11
17
import SymDenotations .SymDenotation
12
18
import config .Printers .inlining
13
19
import ErrorReporting .errorTree
14
- import dotty .tools .dotc .util .{SourceFile , SourcePosition , SrcPos , Property }
20
+ import dotty .tools .dotc .ast .tpd .{cpy , inlineContext }
21
+ import dotty .tools .dotc .util .{Property , SourceFile , SourcePosition , SrcPos }
15
22
import parsing .Parsers .Parser
16
23
import transform .{PostTyper , Inlining , CrossVersionChecks }
17
24
import staging .StagingLevel
@@ -30,7 +37,7 @@ object Inlines:
30
37
private [dotc] class MissingInlineInfo extends Exception
31
38
32
39
object InliningPosition extends Property .StickyKey [InliningPosition ]
33
- case class InliningPosition (sourcePos : SourcePosition , topLevelSymbol : Option [Symbol ])
40
+ case class InliningPosition (targetPos : List [( SourcePosition , Option [Symbol ]) ])
34
41
35
42
/** `sym` is an inline method with a known body to inline.
36
43
*/
@@ -245,9 +252,20 @@ object Inlines:
245
252
/** Replace `Inlined` node by a block that contains its bindings and expansion */
246
253
def dropInlined (inlined : Inlined )(using Context ): Tree =
247
254
val topLevelClass = Option .when(! inlined.call.isEmpty)(inlined.call.symbol.topLevelClass)
248
- val inliningPosition = InliningPosition (inlined.sourcePos, topLevelClass)
249
- val withPos = inlined.expansion.withAttachment(InliningPosition , inliningPosition)
250
- if inlined.bindings.isEmpty then withPos else cpy.Block (inlined)(inlined.bindings, withPos)
255
+ val position = (inlined.sourcePos, topLevelClass)
256
+ val withPos =
257
+ if inlined.expansion.hasAttachment(InliningPosition ) then
258
+ val att = InliningPosition (position :: inlined.expansion.getAttachment(InliningPosition ).get.targetPos)
259
+ inlined.expansion.withAttachment(InliningPosition , att)
260
+ else
261
+ inlined.expansion.withAttachment(InliningPosition , InliningPosition (List (position)))
262
+
263
+ if inlined.bindings.isEmpty then
264
+ withPos
265
+ else
266
+ cpy.Block (inlined)(inlined.bindings, withPos)
267
+
268
+
251
269
252
270
/** Leave only a call trace consisting of
253
271
* - a reference to the top-level class from which the call was inlined,
0 commit comments