File tree Expand file tree Collapse file tree 6 files changed +16
-4
lines changed
compiler/src/dotty/tools/dotc/tastyreflect
tests/run/tasty-custom-show Expand file tree Collapse file tree 6 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -454,9 +454,10 @@ object TastyImpl extends scala.tasty.Tasty {
454
454
455
455
type Pattern = tpd.Tree
456
456
457
- def PatternDeco (x : Pattern ): AbstractPattern = new AbstractPattern {
458
- def pos (implicit ctx : Context ): Position = x.pos
459
- def tpe (implicit ctx : Context ): Types .Type = x.tpe.stripTypeVar
457
+ def PatternDeco (pattern : Pattern ): AbstractPattern = new AbstractPattern {
458
+ def show (implicit ctx : Context , s : Show [TastyImpl .this .type ]): String = s.showPattern(pattern)
459
+ def pos (implicit ctx : Context ): Position = pattern.pos
460
+ def tpe (implicit ctx : Context ): Types .Type = pattern.tpe.stripTypeVar
460
461
}
461
462
462
463
def patternClassTag : ClassTag [Pattern ] = implicitly[ClassTag [Pattern ]]
Original file line number Diff line number Diff line change @@ -324,7 +324,9 @@ abstract class Tasty { tasty =>
324
324
325
325
type Pattern
326
326
327
- trait AbstractPattern extends Typed with Positioned
327
+ trait AbstractPattern extends Typed with Positioned {
328
+ def show (implicit ctx : Context , s : Show [tasty.type ]): String
329
+ }
328
330
implicit def PatternDeco (x : Pattern ): AbstractPattern
329
331
330
332
implicit def patternClassTag : ClassTag [Pattern ]
Original file line number Diff line number Diff line change @@ -8,6 +8,8 @@ abstract class Show[T <: Tasty with Singleton](val tasty: T) {
8
8
9
9
def showCaseDef (caseDef : tasty.CaseDef )(implicit ctx : tasty.Context ): String
10
10
11
+ def showPattern (pattern : tasty.Pattern )(implicit ctx : tasty.Context ): String
12
+
11
13
def showTypeOrBoundsTree (tpt : tasty.TypeOrBoundsTree )(implicit ctx : tasty.Context ): String
12
14
13
15
def showTypeOrBounds (tpe : tasty.TypeOrBounds )(implicit ctx : tasty.Context ): String
Original file line number Diff line number Diff line change @@ -11,6 +11,9 @@ class ShowExtractors[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
11
11
def showCaseDef (caseDef : CaseDef )(implicit ctx : Context ): String =
12
12
new Buffer ().visitCaseDef(caseDef).result()
13
13
14
+ def showPattern (pattern : tasty.Pattern )(implicit ctx : tasty.Context ): String =
15
+ new Buffer ().visitPattern(pattern).result()
16
+
14
17
def showTypeOrBoundsTree (tpt : TypeOrBoundsTree )(implicit ctx : Context ): String =
15
18
new Buffer ().visitTypeTree(tpt).result()
16
19
Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
10
10
def showCaseDef (caseDef : CaseDef )(implicit ctx : Context ): String =
11
11
(new Buffer ).printCaseDef(caseDef).result()
12
12
13
+ def showPattern (pattern : Pattern )(implicit ctx : Context ): String =
14
+ (new Buffer ).printPattern(pattern).result()
15
+
13
16
def showTypeOrBoundsTree (tpt : TypeOrBoundsTree )(implicit ctx : Context ): String =
14
17
(new Buffer ).printTypeOrBoundsTree(tpt).result()
15
18
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ class DummyShow[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty0) {
49
49
import tasty ._
50
50
def showTree (tree : Tree )(implicit ctx : Context ): String = " Tree"
51
51
def showCaseDef (caseDef : CaseDef )(implicit ctx : Context ): String = " CaseDef"
52
+ def showPattern (pattern : Pattern )(implicit ctx : Context ): String = " Pattern"
52
53
def showTypeOrBoundsTree (tpt : TypeOrBoundsTree )(implicit ctx : Context ): String = " TypeOrBoundsTree"
53
54
def showTypeOrBounds (tpe : TypeOrBounds )(implicit ctx : Context ): String = " TypeOrBounds"
54
55
def showConstant (const : Constant )(implicit ctx : Context ): String = " Constant"
You can’t perform that action at this time.
0 commit comments