@@ -10,6 +10,9 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
1010 def showCaseDef (caseDef : CaseDef )(implicit ctx : Context ): String =
1111 (new Buffer ).printCaseDef(caseDef).result()
1212
13+ def showPattern (pattern : Pattern )(implicit ctx : Context ): String =
14+ (new Buffer ).printPattern(pattern).result()
15+
1316 def showTypeOrBoundsTree (tpt : TypeOrBoundsTree )(implicit ctx : Context ): String =
1417 (new Buffer ).printTypeOrBoundsTree(tpt).result()
1518
@@ -50,7 +53,7 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
5053 this += lineBreak()
5154 printTrees(stats1, lineBreak())
5255 }
53- this += lineBreak() += " }" += lineBreak()
56+ this += lineBreak() += " }"
5457 }
5558
5659 case Import (expr, selectors) =>
@@ -485,7 +488,13 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
485488 this += " =>"
486489 indented {
487490 this += lineBreak()
488- printTree(body)
491+ body match {
492+ case Term .Block (stats, expr) =>
493+ printTrees(stats, lineBreak())
494+ printTree(expr)
495+ case body =>
496+ printTree(body)
497+ }
489498 }
490499 this
491500 }
@@ -509,7 +518,11 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
509518 printPattern(pattern)
510519
511520 case Pattern .Unapply (fun, implicits, patterns) =>
512- printTree(fun)
521+ fun match {
522+ case Term .Select (extractor, " unapply" | " unapplySeq" , _) => printTree(extractor)
523+ case Term .TypeApply (Term .Select (extractor, " unapply" | " unapplySeq" , _), _) => printTree(extractor)
524+ case _ => throw new MatchError (fun.show)
525+ }
513526 this += " ("
514527 printPatterns(patterns, " , " )
515528 this += " )"
@@ -518,7 +531,11 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
518531 printPatterns(trees, " | " )
519532
520533 case Pattern .TypeTest (tpt) =>
521- this
534+ this += " _: "
535+ printTypeOrBoundsTree(tpt)
536+
537+ case _ =>
538+ throw new MatchError (pattern.show)
522539
523540 }
524541
@@ -542,8 +559,8 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
542559 printTypeTree(lo)
543560 this += " <: "
544561 printTypeTree(hi)
545- case tpt@ Type () =>
546- printType (tpt)
562+ case tpt @ TypeTree () =>
563+ printTypeTree (tpt)
547564 }
548565
549566 def printTypeTree (tree : TypeTree ): Buffer = tree match {
@@ -629,7 +646,9 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
629646
630647 case Type .TermRef (name, prefix) =>
631648 prefix match {
632- case prefix@ Type () =>
649+ case Type .ThisType (Types .EmptyPackage ()) =>
650+ this += name
651+ case prefix @ Type () =>
633652 printType(prefix)
634653 if (name != " package" )
635654 this += " ." += name
@@ -640,7 +659,7 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
640659
641660 case Type .TypeRef (name, prefix) =>
642661 prefix match {
643- case NoPrefix () =>
662+ case NoPrefix () | Type . ThisType ( Types . EmptyPackage ()) =>
644663 case prefix@ Type () =>
645664 printType(prefix)
646665 this += " ."
0 commit comments