@@ -40,8 +40,8 @@ trait TypesSupport:
4040 extension (tpeTree : Tree )
4141 def asSignature : DocSignature =
4242 tpeTree match
43- case TypeBoundsTree (low, high) => typeBoundsTreeOfHigherKindedType(low, high)
44- case tpeTree : TypeTree => inner(tpeTree.tpe)
43+ case TypeBoundsTree (low, high) => typeBoundsTreeOfHigherKindedType(low.tpe , high.tpe )
44+ case tpeTree : TypeTree => inner(tpeTree.tpe)
4545 case term : Term => inner(term.tpe)
4646
4747 given TypeSyntax : AnyRef with
@@ -96,7 +96,7 @@ trait TypesSupport:
9696 inner(tpe)
9797 case tl @ TypeLambda (params, paramBounds, resType) =>
9898 texts(" [" ) ++ commas(params.zip(paramBounds).map { (name, typ) =>
99- val normalizedName = name.takeWhile(_ != '$' )
99+ val normalizedName = if name.matches( " _ \\ $ \\ d* " ) then " _ " else name
100100 texts(normalizedName) ++ inner(typ)
101101 }) ++ texts(" ]" )
102102 ++ texts(" =>> " )
@@ -159,6 +159,8 @@ trait TypesSupport:
159159 }
160160 }
161161 case t @ AppliedType (tpe, typeList) =>
162+ // if tpe.typeSymbol.normalizedName == "SomeTraitWithHKTs" then
163+ // println(typeList)
162164 import dotty .tools .dotc .util .Chars ._
163165 if ! t.typeSymbol.name.forall(isIdentifierPart) && typeList.size == 2 then
164166 inner(typeList.head)
@@ -242,7 +244,7 @@ trait TypesSupport:
242244 // case _ => throw Exception("No match for type in conversion to Reference. This should not happen, please open an issue. " + tp)
243245 case TypeBounds (low, hi) =>
244246 if (low == hi) texts(" = " ) ++ inner(low)
245- else typeBound (low, low = true ) ++ typeBound(hi, low = false )
247+ else typeBoundsTreeOfHigherKindedType (low, hi )
246248
247249 case NoPrefix () => Nil
248250
@@ -271,17 +273,16 @@ trait TypesSupport:
271273 case _ => Nil
272274 }
273275
274- private def typeBoundsTreeOfHigherKindedType (low : TypeTree , high : TypeTree ) =
275- def regularTypeBounds (low : TypeTree , high : TypeTree ) =
276- typeBound(low.tpe, low = true ) ++ typeBound(high.tpe, low = false )
277- high.tpe.match
278- case t : TypeLambda => t.match
279- case TypeLambda (params, paramBounds, resType) =>
280- if resType.typeSymbol == defn.AnyClass && params.foldLeft(true )((acc,e) => acc && e.contains(" $" )) then
281- texts(" [" ) ++ commas(paramBounds.map { typ =>
282- texts(" _" ) ++ inner(typ)
283- }) ++ texts(" ]" )
284- else
285- regularTypeBounds(low, high)
286- case _ => regularTypeBounds(low, high)
276+ private def typeBoundsTreeOfHigherKindedType (low : TypeRepr , high : TypeRepr ) =
277+ def regularTypeBounds (low : TypeRepr , high : TypeRepr ) =
278+ typeBound(low, low = true ) ++ typeBound(high, low = false )
279+ high.match
280+ case TypeLambda (params, paramBounds, resType) =>
281+ if resType.typeSymbol == defn.AnyClass then
282+ texts(" [" ) ++ commas(params.zip(paramBounds).map { (name, typ) =>
283+ val normalizedName = if name.matches(" _\\ $\\ d*" ) then " _" else name
284+ texts(normalizedName) ++ inner(typ)
285+ }) ++ texts(" ]" )
286+ else
287+ regularTypeBounds(low, high)
287288 case _ => regularTypeBounds(low, high)
0 commit comments