@@ -4,6 +4,7 @@ package reflect
4
4
import scala .annotation .switch
5
5
import scala .quoted .show .SyntaxHighlight
6
6
7
+ /** Printer for fully elaborated representation of the source code */
7
8
class SourceCodePrinter [R <: Reflection & Singleton ](val tasty : R )(syntaxHighlight : SyntaxHighlight ) extends Printer [R ] {
8
9
import tasty .{_ , given }
9
10
import syntaxHighlight ._
@@ -382,18 +383,26 @@ class SourceCodePrinter[R <: Reflection & Singleton](val tasty: R)(syntaxHighlig
382
383
this += " }"
383
384
384
385
case Apply (fn, args) =>
386
+ var argsPrefix = " "
385
387
fn match {
386
388
case Select (This (_), " <init>" ) => this += " this" // call to constructor inside a constructor
387
- case Select (qual, " apply" ) if qual.tpe.isContextFunctionType =>
388
- printTree(qual) += " given "
389
+ case Select (qual, " apply" ) =>
390
+ if qual.tpe.isContextFunctionType then
391
+ argsPrefix += " using "
392
+ if qual.tpe.isErasedFunctionType then
393
+ argsPrefix += " erased "
394
+ printQualTree(fn)
389
395
case _ => printQualTree(fn)
390
396
}
391
397
val args1 = args match {
392
398
case init :+ Typed (Repeated (Nil , _), _) => init // drop empty var args at the end
393
399
case _ => args
394
400
}
395
401
396
- inParens(printTrees(args1, " , " ))
402
+ inParens {
403
+ this += argsPrefix
404
+ printTrees(args1, " , " )
405
+ }
397
406
398
407
case TypeApply (fn, args) =>
399
408
printQualTree(fn)
@@ -446,10 +455,10 @@ class SourceCodePrinter[R <: Reflection & Singleton](val tasty: R)(syntaxHighlig
446
455
this += " = "
447
456
printTree(rhs)
448
457
449
- case Lambda (params, body) => // must come before `Block`
458
+ case tree @ Lambda (params, body) => // must come before `Block`
450
459
inParens {
451
460
printArgsDefs(params)
452
- this += " => "
461
+ this += ( if tree.tpe.isContextFunctionType then " ? => " else " => " )
453
462
printTree(body)
454
463
}
455
464
0 commit comments