@@ -186,9 +186,10 @@ trait Printers
186
186
this += " DefDef(\" " += name += " \" , " ++= typeParams += " , " +++= paramss += " , " += returnTpt += " , " += rhs += " )"
187
187
case TypeDef (name, rhs) =>
188
188
this += " TypeDef(\" " += name += " \" , " += rhs += " )"
189
- case ClassDef (name, constr, parents, self, body) =>
189
+ case ClassDef (name, constr, parents, derived, self, body) =>
190
190
this += " ClassDef(\" " += name += " \" , " += constr += " , "
191
191
visitList[TermOrTypeTree ](parents, visitTermOrTypeTree)
192
+ visitList[TypeTree ](derived, visitTypeTree)
192
193
this += " , " += self += " , " ++= body += " )"
193
194
case PackageDef (name, owner) =>
194
195
this += " PackageDef(\" " += name += " \" , " += owner += " )"
@@ -569,7 +570,7 @@ trait Printers
569
570
this += " ."
570
571
printImportSelectors(selectors)
571
572
572
- case IsClassDef (cdef @ ClassDef (name, DefDef (_, targs, argss, _, _), parents, self, stats)) =>
573
+ case IsClassDef (cdef @ ClassDef (name, DefDef (_, targs, argss, _, _), parents, derived, self, stats)) =>
573
574
printDefAnnotations(cdef)
574
575
575
576
val flags = cdef.symbol.flags
@@ -625,6 +626,11 @@ trait Printers
625
626
}
626
627
printSeparated(parents1)
627
628
629
+ if (derived.nonEmpty) {
630
+ this += highlightKeyword(" derives " , color)
631
+ printTypeTrees(derived, " , " )
632
+ }
633
+
628
634
def keepDefinition (d : Definition ): Boolean = {
629
635
val flags = d.symbol.flags
630
636
def isCaseClassUnOverridableMethod : Boolean = {
@@ -1004,19 +1010,25 @@ trait Printers
1004
1010
printSeparated(stats)
1005
1011
}
1006
1012
1007
- def printTrees ( trees : List [Tree ], sep : String ): Buffer = {
1008
- def printSeparated (list : List [Tree ]): Unit = list match {
1013
+ def printList [ T ]( xs : List [T ], sep : String , print : T => Buffer ): Buffer = {
1014
+ def printSeparated (list : List [T ]): Unit = list match {
1009
1015
case Nil =>
1010
- case x :: Nil => printTree (x)
1016
+ case x :: Nil => print (x)
1011
1017
case x :: xs =>
1012
- printTree (x)
1018
+ print (x)
1013
1019
this += sep
1014
1020
printSeparated(xs)
1015
1021
}
1016
- printSeparated(trees )
1022
+ printSeparated(xs )
1017
1023
this
1018
1024
}
1019
1025
1026
+ def printTrees (trees : List [Tree ], sep : String ): Buffer =
1027
+ printList(trees, sep, printTree)
1028
+
1029
+ def printTypeTrees (trees : List [TypeTree ], sep : String ): Buffer =
1030
+ printList(trees, sep, printTypeTree)
1031
+
1020
1032
def printTypes (trees : List [Type ], sep : String ): Buffer = {
1021
1033
def printSeparated (list : List [Type ]): Unit = list match {
1022
1034
case Nil =>
@@ -1201,7 +1213,7 @@ trait Printers
1201
1213
val name = arg.name
1202
1214
arg.symbol.owner match {
1203
1215
case IsDefSymbol (sym) if sym.name == " <init>" =>
1204
- val ClassDef (_, _, _, _, body) = sym.owner.asClass.tree
1216
+ val ClassDef (_, _, _, _, _, body) = sym.owner.asClass.tree
1205
1217
body.collectFirst {
1206
1218
case IsValDef (vdef @ ValDef (`name`, _, _)) if vdef.symbol.flags.is(Flags .ParamAccessor ) =>
1207
1219
if (! vdef.symbol.flags.is(Flags .Local )) {
@@ -1552,7 +1564,7 @@ trait Printers
1552
1564
def printDefinitionName (sym : Definition ): Buffer = sym match {
1553
1565
case ValDef (name, _, _) => this += highlightValDef(name, color)
1554
1566
case DefDef (name, _, _, _, _) => this += highlightValDef(name, color)
1555
- case ClassDef (name, _, _, _, _) => this += highlightTypeDef(name.stripSuffix(" $" ), color)
1567
+ case ClassDef (name, _, _, _, _, _ ) => this += highlightTypeDef(name.stripSuffix(" $" ), color)
1556
1568
case TypeDef (name, _) => this += highlightTypeDef(name, color)
1557
1569
case PackageDef (name, _) => this += highlightTypeDef(name, color)
1558
1570
}
0 commit comments