@@ -11,6 +11,7 @@ import dotty.tools.dotc.util.SourcePosition
1111
1212import scala .quoted
1313import scala .reflect .ClassTag
14+ import scala .tasty .util .{Show , ShowExtractors }
1415
1516object TastyImpl extends scala.tasty.Tasty {
1617
@@ -24,6 +25,15 @@ object TastyImpl extends scala.tasty.Tasty {
2425 def toTasty (implicit ctx : Context ): TypeTree = PickledQuotes .quotedTypeToTree(x)
2526 }
2627
28+ // ===== Show =====================================================
29+
30+ def defaultShow : Show [this .type ] = showExtractors
31+
32+ def showExtractors : Show [this .type ] = new ShowExtractors (this )
33+
34+ // TODO
35+ // def showSourceCode: Show[this.type] = ???
36+
2737 // ===== Contexts =================================================
2838
2939 type Context = Contexts .Context
@@ -53,8 +63,9 @@ object TastyImpl extends scala.tasty.Tasty {
5363
5464 type Tree = tpd.Tree
5565
56- def TreeDeco (t : Tree ): AbstractTree = new AbstractTree {
57- def pos (implicit ctx : Context ): Position = t.pos
66+ def TreeDeco (tree : Tree ): AbstractTree = new AbstractTree {
67+ def show (implicit ctx : Context , s : Show [TastyImpl .this .type ]): String = s.showTree(tree)
68+ def pos (implicit ctx : Context ): Position = tree.pos
5869 }
5970
6071 type PackageClause = tpd.PackageDef
@@ -449,8 +460,9 @@ object TastyImpl extends scala.tasty.Tasty {
449460
450461 type TypeOrBoundsTree = tpd.Tree
451462
452- def TypeOrBoundsTreeDeco (x : TypeOrBoundsTree ): AbstractTypeOrBoundsTree = new AbstractTypeOrBoundsTree {
453- def tpe (implicit ctx : Context ): Type = x.tpe.stripTypeVar
463+ def TypeOrBoundsTreeDeco (tpt : TypeOrBoundsTree ): AbstractTypeOrBoundsTree = new AbstractTypeOrBoundsTree {
464+ def show (implicit ctx : Context , s : Show [TastyImpl .this .type ]): String = s.showTypeOrBoundsTree(tpt)
465+ def tpe (implicit ctx : Context ): Type = tpt.tpe.stripTypeVar
454466 }
455467
456468 // ----- TypeTrees ------------------------------------------------
@@ -559,6 +571,10 @@ object TastyImpl extends scala.tasty.Tasty {
559571
560572 type TypeOrBounds = Types .Type
561573
574+ def TypeOrBoundsDeco (tpe : Types .Type ): AbstractTypeOrBounds = new AbstractTypeOrBounds {
575+ def show (implicit ctx : Context , s : Show [TastyImpl .this .type ]): String = s.showTypeOrBounds(tpe)
576+ }
577+
562578 // ----- Types ----------------------------------------------------
563579
564580 type Type = Types .Type
@@ -756,8 +772,9 @@ object TastyImpl extends scala.tasty.Tasty {
756772
757773 type Constant = Constants .Constant
758774
759- def ConstantDeco (x : Constant ): AbstractConstant = new AbstractConstant {
760- def value : Any = x.value
775+ def ConstantDeco (const : Constant ): AbstractConstant = new AbstractConstant {
776+ def show (implicit ctx : Context , s : Show [TastyImpl .this .type ]): String = s.showConstant(const)
777+ def value : Any = const.value
761778 }
762779
763780 def constantClassTag : ClassTag [Constant ] = implicitly[ClassTag [Constant ]]
0 commit comments