Skip to content

Commit edc1c4d

Browse files
committed
Fix rendering bug in arrow TypesSupport
We should not propagate the capture status beyond the current arrow. Under a capture context, types are rendered plainly.
1 parent 2533881 commit edc1c4d

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

scaladoc/src/dotty/tools/scaladoc/tasty/TypesSupport.scala

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ trait TypesSupport:
9696

9797
// TODO #23 add support for all types signatures that make sense
9898
private def inner(
99-
using Quotes,
99+
using q: Quotes,
100100
)(
101101
tp: reflect.TypeRepr,
102102
skipThisTypePrefix: Boolean
@@ -122,7 +122,7 @@ trait TypesSupport:
122122
++ keyword(" & ").l
123123
++ inParens(inner(right, skipThisTypePrefix), shouldWrapInParens(right, tp, false))
124124
case ByNameType(CapturingType(tpe, refs)) =>
125-
renderCaptureArrow(refs, skipThisTypePrefix) ++ (plain(" ") :: inner(tpe, skipThisTypePrefix))
125+
renderCaptureArrow(using q)(Some(refs), skipThisTypePrefix)(using elideThis, originalOwner) ++ (plain(" ") :: inner(tpe, skipThisTypePrefix))
126126
case ByNameType(tpe) => keyword("=>!! ") :: inner(tpe, skipThisTypePrefix) // FIXME: does it need change for CC?
127127
case ConstantType(constant) =>
128128
plain(constant.show).l
@@ -342,15 +342,16 @@ trait TypesSupport:
342342
s"${tpe.show(using Printer.TypeReprStructure)}"
343343
throw MatchError(msg)
344344

345-
private def functionType(using Quotes)(t: reflect.TypeRepr, tpe: reflect.TypeRepr, args: List[reflect.TypeRepr], skipThisTypePrefix: Boolean)(using
345+
private def functionType(using q: Quotes)(t: reflect.TypeRepr, tpe: reflect.TypeRepr, args: List[reflect.TypeRepr], skipThisTypePrefix: Boolean)(using
346346
elideThis: reflect.ClassDef,
347347
indent: Int,
348348
originalOwner: reflect.Symbol,
349349
inCC: Option[List[reflect.TypeRepr]],
350350
): SSignature =
351351
import reflect._
352352
val arrow = if t.isContextFunctionType then keyword(" ?=> ").l // FIXME: can we have contextual functions with capture sets?
353-
else plain(" ") :: (renderCaptureArrow(inCC, skipThisTypePrefix) ++ plain(" ").l)
353+
else plain(" ") :: (renderCaptureArrow(using q)(inCC, skipThisTypePrefix) ++ plain(" ").l)
354+
given Option[List[TypeRepr]] = None
354355
args match
355356
case Nil => Nil
356357
case List(rtpe) => plain("()").l ++ arrow ++ inner(rtpe, skipThisTypePrefix)
@@ -498,19 +499,19 @@ trait TypesSupport:
498499
import reflect._
499500
Keyword("^") :: renderCaptureSet(refs, skipThisTypePrefix)
500501

501-
private def renderCaptureArrow(using Quotes)(refs: List[reflect.TypeRepr], skipThisTypePrefix: Boolean)(
502+
private def renderCaptureArrow(using q: Quotes)(refs: List[reflect.TypeRepr], skipThisTypePrefix: Boolean)(
502503
using elideThis: reflect.ClassDef, originalOwner: reflect.Symbol
503504
): SSignature =
504-
import reflect._
505+
import reflect.*
505506
refs match
506507
case Nil => List(Keyword("->"))
507508
case List(ref) if ref.isCaptureRoot => List(Keyword("=>"))
508-
case refs => Keyword("->") :: renderCaptureSet(refs, skipThisTypePrefix)
509+
case refs => Keyword("->") :: renderCaptureSet(using q)(refs, skipThisTypePrefix)
509510

510-
private def renderCaptureArrow(using Quotes)(refs: Option[List[reflect.TypeRepr]], skipThisTypePrefix: Boolean)(
511+
private def renderCaptureArrow(using q: Quotes)(refs: Option[List[reflect.TypeRepr]], skipThisTypePrefix: Boolean)(
511512
using elideThis: reflect.ClassDef, originalOwner: reflect.Symbol
512513
): SSignature =
513-
import reflect._
514+
import reflect.*
514515
refs match
515516
case None => List(Keyword("=>")) // FIXME: is this correct? or should it be `->` by default?
516-
case Some(refs) => renderCaptureArrow(refs, skipThisTypePrefix)
517+
case Some(refs) => renderCaptureArrow(using q)(refs, skipThisTypePrefix)

0 commit comments

Comments
 (0)