@@ -21,6 +21,7 @@ import dotc.printing.{ GlobalPrec, DotPrec, Printer, PlainPrinter }
21
21
import dotc .typer .Implicits .SearchResult
22
22
import dotc .typer .ImportInfo
23
23
24
+ // TODO: Avoid code duplication between userfacing and refined printers
24
25
class UserFacingPrinter (_ctx : Context ) extends PlainPrinter (_ctx) {
25
26
26
27
private def panic (msg : String ): Nothing = throw new AssertionError (msg)
@@ -92,7 +93,7 @@ class UserFacingPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
92
93
case tp : TypeAlias => toText(tp.underlying)
93
94
case ExprType (result) => " :" ~~ toText(result)
94
95
case TypeBounds (lo, hi) =>
95
- { if (lo != defn.NothingType ) toText(lo) ~~ " >: _" else Str (" _" ) } ~~
96
+ { if (lo != defn.NothingType ) toText(lo) ~~ " >: _" else Str (" _" ) } ~~ // TODO: that's different from how args are written in source!
96
97
{ if (hi != defn.AnyType ) " <:" ~~ toText(hi) else Text () }
97
98
case tp : TypeRef => tp.info match {
98
99
case TypeAlias (alias) => toText(alias)
@@ -116,19 +117,28 @@ class UserFacingPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
116
117
}
117
118
}
118
119
case AnyAppliedType (tycon, args) => {
120
+ def argText (tp : Type ) =
121
+ toText {
122
+ tp match {
123
+ case tp : TypeArgRef => tp.underlying
124
+ case _ => tp
125
+ }
126
+ }
119
127
def toTextInfixType (tycon : Type , args : List [Type ]): Text = {
120
128
// TODO: blatant copy from `RefinedPrinter`
121
129
val l :: r :: Nil = args
122
130
val isRightAssoc = tycon.typeSymbol.name.endsWith(" :" )
123
- val leftArg = if (isRightAssoc && l.isInfixType) " (" ~ toText (l) ~ " )" else toText (l)
124
- val rightArg = if (! isRightAssoc && r.isInfixType) " (" ~ toText (r) ~ " )" else toText (r)
131
+ val leftArg = if (isRightAssoc && l.isInfixType) " (" ~ argText (l) ~ " )" else argText (l)
132
+ val rightArg = if (! isRightAssoc && r.isInfixType) " (" ~ argText (r) ~ " )" else argText (r)
125
133
leftArg ~~ atPrec(DotPrec ) { tycon.toText(this ) } ~~ rightArg
126
134
}
127
135
if (tp.isInfixType) toTextInfixType(tycon, args)
128
136
else {
129
- toText(tycon) ~ " [" ~ Fluid (args.reverse.map(toText ).intersperse(Str (" , " ))) ~ " ]"
137
+ toText(tycon) ~ " [" ~ Fluid (args.reverse.map(argText ).intersperse(Str (" , " ))) ~ " ]"
130
138
}
131
139
}
140
+ case tp : TypeArgRef =>
141
+ super .toText(tp)
132
142
case tp : ClassInfo => {
133
143
if (wellKnownPkg(tp.cls.owner))
134
144
nameString(tp.cls.name)
0 commit comments