File tree Expand file tree Collapse file tree 5 files changed +15
-4
lines changed
compiler/src/dotty/tools/dotc/tastyreflect Expand file tree Collapse file tree 5 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -448,9 +448,10 @@ object TastyImpl extends scala.tasty.Tasty {
448
448
449
449
type Pattern = tpd.Tree
450
450
451
- def PatternDeco (x : Pattern ): AbstractPattern = new AbstractPattern {
452
- def pos (implicit ctx : Context ): Position = x.pos
453
- def tpe (implicit ctx : Context ): Types .Type = x.tpe.stripTypeVar
451
+ def PatternDeco (pattern : Pattern ): AbstractPattern = new AbstractPattern {
452
+ def show (implicit ctx : Context , s : Show [TastyImpl .this .type ]): String = s.showPattern(pattern)
453
+ def pos (implicit ctx : Context ): Position = pattern.pos
454
+ def tpe (implicit ctx : Context ): Types .Type = pattern.tpe.stripTypeVar
454
455
}
455
456
456
457
def patternClassTag : ClassTag [Pattern ] = implicitly[ClassTag [Pattern ]]
Original file line number Diff line number Diff line change @@ -314,7 +314,9 @@ abstract class Tasty { tasty =>
314
314
315
315
type Pattern
316
316
317
- trait AbstractPattern extends Typed with Positioned
317
+ trait AbstractPattern extends Typed with Positioned {
318
+ def show (implicit ctx : Context , s : Show [tasty.type ]): String
319
+ }
318
320
implicit def PatternDeco (x : Pattern ): AbstractPattern
319
321
320
322
implicit def patternClassTag : ClassTag [Pattern ]
Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ abstract class Show[T <: Tasty with Singleton](val tasty: T) {
6
6
7
7
def showTree (tree : tasty.Tree )(implicit ctx : tasty.Context ): String
8
8
9
+ def showPattern (pattern : tasty.Pattern )(implicit ctx : tasty.Context ): String
10
+
9
11
def showTypeOrBoundsTree (tpt : tasty.TypeOrBoundsTree )(implicit ctx : tasty.Context ): String
10
12
11
13
def showTypeOrBounds (tpe : tasty.TypeOrBounds )(implicit ctx : tasty.Context ): String
Original file line number Diff line number Diff line change @@ -8,6 +8,9 @@ class ShowExtractors[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
8
8
def showTree (tree : Tree )(implicit ctx : Context ): String =
9
9
new Buffer ().visitTree(tree).result()
10
10
11
+ def showPattern (pattern : tasty.Pattern )(implicit ctx : tasty.Context ): String =
12
+ new Buffer ().visitPattern(pattern).result()
13
+
11
14
def showTypeOrBoundsTree (tpt : TypeOrBoundsTree )(implicit ctx : Context ): String =
12
15
new Buffer ().visitTypeTree(tpt).result()
13
16
Original file line number Diff line number Diff line change @@ -7,6 +7,9 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
7
7
def showTree (tree : Tree )(implicit ctx : Context ): String =
8
8
(new Buffer ).printTree(tree).result()
9
9
10
+ def showPattern (pattern : Pattern )(implicit ctx : Context ): String =
11
+ (new Buffer ).printPattern(pattern).result()
12
+
10
13
def showTypeOrBoundsTree (tpt : TypeOrBoundsTree )(implicit ctx : Context ): String =
11
14
(new Buffer ).printTypeOrBoundsTree(tpt).result()
12
15
You can’t perform that action at this time.
0 commit comments