@@ -88,35 +88,40 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
8888 case TypeTree .TermSelect (Term .Select (Term .Ident (" _root_" ), " scala" , _), " Product" ) => false
8989 case _ => true
9090 }
91- if (parents1.nonEmpty) {
92- sb.append(" extends" )
93- parents1.foreach {
94- case parent@ Term .Apply (Term .TypeApply (Term .Select (Term .New (tpt), _, _), targs), args) =>
95- this += " "
96- printTypeTree(tpt)
97- this += " ["
98- printTypeOrBoundsTrees(targs, " , " )
99- this += " ]"
100- if (args.nonEmpty) {
101- this += " ("
102- printTrees(args, " , " )
103- this += " )"
104- }
91+ if (parents1.nonEmpty)
92+ this += " extends "
93+
94+ def printParent (parent : Parent ): Unit = parent match {
95+ case parent @ Term .TypeApply (fun, targs) =>
96+ printParent(fun)
97+ this += " ["
98+ printTypeOrBoundsTrees(targs, " , " )
99+ this += " ]"
100+
101+ case parent @ Term .Apply (fun, args) =>
102+ printParent(fun)
103+ this += " ("
104+ printTrees(args, " , " )
105+ this += " )"
105106
106- case parent@ Term .Apply (Term .Select (Term .New (tpt), _, _), args) =>
107- this += " "
108- printTypeTree(tpt)
109- if (args.nonEmpty) {
110- this += " ("
111- printTrees(args, " , " )
112- this += " )"
113- }
107+ case parent @ Term .Select (Term .New (tpt), _, _) =>
108+ printTypeTree(tpt)
114109
115- case parent@ TypeTree () =>
116- sb.append(" " )
117- printTypeTree(parent)
118- }
110+ case parent @ TypeTree () =>
111+ printTypeTree(parent)
112+
113+ case parent @ Term () => throw new MatchError (parent.show)
114+ }
115+
116+ def printSeparated (list : List [Parent ]): Unit = list match {
117+ case Nil =>
118+ case x :: Nil => printParent(x)
119+ case x :: xs =>
120+ printParent(x)
121+ this += " with "
122+ printSeparated(xs)
119123 }
124+ printSeparated(parents1)
120125
121126 def keepDefinition (d : Definition ): Boolean = {
122127 val flags = d.flags
0 commit comments