@@ -236,7 +236,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
236
236
private val bindingsBuf = new mutable.ListBuffer [ValOrDefDef ]
237
237
238
238
private def newSym (name : Name , flags : FlagSet , info : Type ): Symbol =
239
- ctx.newSymbol(ctx.owner, name, flags, info, coord = call .span)
239
+ ctx.newSymbol(ctx.owner, name, flags, info, coord = inlinedMethod .span)
240
240
241
241
/** A binding for the parameter of an inline method. This is a `val` def for
242
242
* by-value parameters and a `def` def for by-name parameters. `val` defs inherit
@@ -249,6 +249,8 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
249
249
*/
250
250
private def paramBindingDef (name : Name , paramtp : Type , arg : Tree ,
251
251
bindingsBuf : mutable.ListBuffer [ValOrDefDef ]): ValOrDefDef = {
252
+ implicit val ctx : Context = this .ctx.withSource(inlinedMethod.source(this .ctx))
253
+
252
254
val argtpe = arg.tpe.dealiasKeepAnnots
253
255
val isByName = paramtp.dealias.isInstanceOf [ExprType ]
254
256
var inlineFlag = InlineProxy
@@ -257,11 +259,21 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
257
259
if (isByName) (InlineByNameProxy .toTermFlags, ExprType (argtpe.widen))
258
260
else (inlineFlag, argtpe.widen)
259
261
val boundSym = newSym(name, bindingFlags, bindingType).asTerm
262
+ println(" =================" )
263
+ println(arg.show)
264
+ println(arg)
265
+ println()
266
+ println(boundSym.span)
267
+ println()
260
268
val binding = {
261
- if (isByName) DefDef (boundSym, arg.changeOwner(ctx.owner, boundSym))
262
- else ValDef (boundSym, arg)
263
- }.withSpan(boundSym .span)
269
+ if (isByName) DefDef (boundSym, Inlined ( EmptyTree , arg.changeOwner(ctx.owner, boundSym) ))
270
+ else ValDef (boundSym, Inlined ( EmptyTree , arg).withSpan(inlinedMethod.span) )
271
+ }.withSpan(inlinedMethod .span)
264
272
bindingsBuf += binding.setDefTree
273
+ println(" ********" )
274
+ println(binding.show)
275
+ println()
276
+ println()
265
277
binding
266
278
}
267
279
@@ -516,6 +528,11 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
516
528
// Drop unused bindings
517
529
val (finalBindings, finalExpansion) = dropUnusedDefs(bindingsBuf.toList, expansion1)
518
530
531
+ println()
532
+ println(expansion1)
533
+ println(expansion1.span)
534
+ println()
535
+ println()
519
536
if (inlinedMethod == defn.Compiletime_error ) issueError()
520
537
521
538
// Widen TermRefs to bindings
@@ -529,7 +546,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
529
546
finalExpansion
530
547
}
531
548
532
- tpd.Inlined (call, tpd.seq(finalBindings, finalExpansion2))
549
+ tpd.Inlined (call, tpd.seq(finalBindings, finalExpansion2)(ctx.withSource(inlinedMethod.source)).withSpan(inlinedMethod.span union finalExpansion2.span) )
533
550
}
534
551
}
535
552
0 commit comments