@@ -590,8 +590,9 @@ trait Printers
590
590
else if (flags.is(Flags .Abstract )) this += highlightKeyword(" abstract class " , color) += highlightTypeDef(name, color)
591
591
else this += highlightKeyword(" class " , color) += highlightTypeDef(name, color)
592
592
593
+ val typeParams = stats.collect { case IsTypeDef (targ) => targ }.filter(_.symbol.isTypeParam).zip(targs)
593
594
if (! flags.is(Flags .Object )) {
594
- printTargsDefs(targs )
595
+ printTargsDefs(typeParams )
595
596
val it = argss.iterator
596
597
while (it.hasNext)
597
598
printArgsDefs(it.next())
@@ -606,14 +607,19 @@ trait Printers
606
607
if (parents1.nonEmpty)
607
608
this += highlightKeyword(" extends " , color)
608
609
609
- def printParent (parent : TermOrTypeTree ): Unit = parent match {
610
+ def printParent (parent : TermOrTypeTree , needEmptyParens : Boolean = false ): Unit = parent match {
610
611
case IsTypeTree (parent) =>
611
612
printTypeTree(parent)
612
613
case IsTerm (Term .TypeApply (fun, targs)) =>
613
614
printParent(fun)
615
+ case IsTerm (Term .Apply (fun@ Term .Apply (_,_), args)) =>
616
+ printParent(fun, true )
617
+ if (! args.isEmpty || needEmptyParens)
618
+ inParens(printTrees(args, " , " ))
614
619
case IsTerm (Term .Apply (fun, args)) =>
615
620
printParent(fun)
616
- inParens(printTrees(args, " , " ))
621
+ if (! args.isEmpty || needEmptyParens)
622
+ inParens(printTrees(args, " , " ))
617
623
case IsTerm (Term .Select (Term .New (tpt), _)) =>
618
624
printTypeTree(tpt)
619
625
case IsTerm (parent) =>
@@ -691,7 +697,7 @@ trait Printers
691
697
case IsTypeDef (tdef @ TypeDef (name, rhs)) =>
692
698
printDefAnnotations(tdef)
693
699
this += highlightKeyword(" type " , color)
694
- printTargDef(tdef, isMember = true )
700
+ printTargDef(( tdef, tdef) , isMember = true )
695
701
696
702
case IsValDef (vdef @ ValDef (name, tpt, rhs)) =>
697
703
printDefAnnotations(vdef)
@@ -754,7 +760,7 @@ trait Printers
754
760
printProtectedOrPrivate(ddef)
755
761
756
762
this += highlightKeyword(" def " , color) += highlightValDef((if (isConstructor) " this" else name), color)
757
- printTargsDefs(targs)
763
+ printTargsDefs(targs.zip(targs) )
758
764
val it = argss.iterator
759
765
while (it.hasNext)
760
766
printArgsDefs(it.next())
@@ -1125,13 +1131,13 @@ trait Printers
1125
1131
this
1126
1132
}
1127
1133
1128
- def printTargsDefs (targs : List [TypeDef ] ): Unit = {
1134
+ def printTargsDefs (targs : List [( TypeDef , TypeDef )], isDef : Boolean = true ): Unit = {
1129
1135
if (! targs.isEmpty) {
1130
- def printSeparated (list : List [TypeDef ]): Unit = list match {
1136
+ def printSeparated (list : List [( TypeDef , TypeDef ) ]): Unit = list match {
1131
1137
case Nil =>
1132
- case x :: Nil => printTargDef(x)
1138
+ case x :: Nil => printTargDef(x, isDef = isDef )
1133
1139
case x :: xs =>
1134
- printTargDef(x)
1140
+ printTargDef(x, isDef = isDef )
1135
1141
this += " , "
1136
1142
printSeparated(xs)
1137
1143
}
@@ -1140,9 +1146,19 @@ trait Printers
1140
1146
}
1141
1147
}
1142
1148
1143
- def printTargDef (arg : TypeDef , isMember : Boolean = false ): Buffer = {
1144
- this += arg.name
1145
- arg.rhs match {
1149
+ def printTargDef (arg : (TypeDef , TypeDef ), isMember : Boolean = false , isDef: Boolean = true ): Buffer = {
1150
+ val (argDef, argCons) = arg
1151
+
1152
+ if (isDef) {
1153
+ if (argDef.symbol.flags.is(Flags .Covariant )) {
1154
+ this += highlightValDef(" +" , color)
1155
+ } else if (argDef.symbol.flags.is(Flags .Contravariant )) {
1156
+ this += highlightValDef(" -" , color)
1157
+ }
1158
+ }
1159
+
1160
+ this += argCons.name
1161
+ argCons.rhs match {
1146
1162
case IsTypeBoundsTree (rhs) => printBoundsTree(rhs)
1147
1163
case rhs @ WildcardTypeTree () =>
1148
1164
printTypeOrBound(rhs.tpe)
@@ -1412,7 +1428,7 @@ trait Printers
1412
1428
printTypeTree(result)
1413
1429
1414
1430
case TypeTree .LambdaTypeTree (tparams, body) =>
1415
- printTargsDefs(tparams)
1431
+ printTargsDefs(tparams.zip(tparams), isDef = false )
1416
1432
this += highlightTypeDef(" => " , color)
1417
1433
printTypeOrBoundsTree(body)
1418
1434
0 commit comments