Skip to content

Commit b1d637b

Browse files
committed
Resugar quotes in Printer
1 parent caf3f11 commit b1d637b

File tree

5 files changed

+24
-4
lines changed

5 files changed

+24
-4
lines changed

library/src/scala/tasty/reflect/Printers.scala

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,26 @@ trait Printers
849849
this += "throw "
850850
printTree(expr)
851851

852+
case Term.Apply(fn, args) if fn.symbol.fullName == "scala.internal.Quoted$.exprQuote" =>
853+
args.head match {
854+
case Term.Block(stats, expr) =>
855+
this += "'{"
856+
indented {
857+
this += lineBreak()
858+
printFlatBlock(stats, expr)
859+
}
860+
this += lineBreak() += "}"
861+
case _ =>
862+
this += "'{"
863+
printTree(args.head)
864+
this += "}"
865+
}
866+
867+
case Term.TypeApply(fn, args) if fn.symbol.fullName == "scala.internal.Quoted$.typeQuote" =>
868+
this += "'["
869+
printTypeTree(args.head)
870+
this += "]"
871+
852872
case Term.Apply(fn, args) =>
853873
fn match {
854874
case Term.Select(Term.This(_), "<init>") => this += "this" // call to constructor inside a constructor
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
scala.internal.Quoted.exprQuote[scala.Int](3)
1+
'{3}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
val a: scala.quoted.Expr[scala.Int] = scala.internal.Quoted.exprQuote[scala.Int](4)
2+
val a: scala.quoted.Expr[scala.Int] = '{4}
33
a
44
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
val t: scala.quoted.Type[scala.Predef.String] = scala.internal.Quoted.typeQuote[scala.Predef.String]
2+
val t: scala.quoted.Type[scala.Predef.String] = '[scala.Predef.String]
33

44
(t: scala.quoted.Type[scala.Predef.String])
55
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
val a: scala.quoted.Expr[scala.Int] = scala.internal.Quoted.exprQuote[scala.Int](4)
2+
val a: scala.quoted.Expr[scala.Int] = '{4}
33
a
44
}

0 commit comments

Comments
 (0)