@@ -55,7 +55,7 @@ trait TypesSupport:
55
55
private def tpe (using Quotes )(symbol : reflect.Symbol )(using inCC : Option [Any ]): SSignature =
56
56
import SymOps ._
57
57
val dri : Option [DRI ] = Option (symbol).filterNot(_.isHiddenByVisibility).map(_.dri)
58
- if inCC.isDefined then
58
+ if inCC.isDefined then // we are in the context of a capture set and want paths to be rendered plainly
59
59
dotty.tools.scaladoc.Plain (symbol.normalizedName).l
60
60
else
61
61
dotty.tools.scaladoc.Type (symbol.normalizedName, dri).l
@@ -115,9 +115,9 @@ trait TypesSupport:
115
115
++ keyword(" & " ).l
116
116
++ inParens(inner(right), shouldWrapInParens(right, tp, false ))
117
117
case ByNameType (CapturingType (tpe, refs)) =>
118
- renderByNameArrow (using qctx)(Some (refs)) ++ (plain(" " ) :: inner(tpe))
118
+ emitByNameArrow (using qctx)(Some (refs)) ++ (plain(" " ) :: inner(tpe))
119
119
case ByNameType (tpe) =>
120
- renderByNameArrow (using qctx)(None ) ++ (plain(" " ) :: inner(tpe))
120
+ emitByNameArrow (using qctx)(None ) ++ (plain(" " ) :: inner(tpe))
121
121
case ConstantType (constant) =>
122
122
plain(constant.show).l
123
123
case ThisType (tpe) =>
@@ -130,12 +130,14 @@ trait TypesSupport:
130
130
inner(tpe) :+ plain(" *" )
131
131
case AppliedType (repeatedClass, Seq (tpe)) if isRepeated(repeatedClass) =>
132
132
inner(tpe) :+ plain(" *" )
133
- case CapturingType (base, refs) => base match
134
- case t @ AppliedType (base, args) if t.isFunctionType =>
135
- functionType(base, args)(using inCC = Some (refs))
136
- case t : Refinement if t.isFunctionType =>
137
- inner(base)(using inCC = Some (refs))
138
- case _ => inner(base) ++ renderCapturing(refs)
133
+ case CapturingType (base, refs) =>
134
+ base match
135
+ case t @ AppliedType (base, args) if t.isFunctionType =>
136
+ functionType(base, args)(using inCC = Some (refs))
137
+ case t : Refinement if t.isFunctionType =>
138
+ inner(base)(using inCC = Some (refs))
139
+ case t if t.isCapSet => emitCaptureSet(refs, omitCap = false )
140
+ case _ => inner(base) ++ emitCapturing(refs)
139
141
case AnnotatedType (tpe, _) =>
140
142
inner(tpe)
141
143
case tl @ TypeLambda (params, paramBounds, AppliedType (tpe, args))
@@ -211,7 +213,7 @@ trait TypesSupport:
211
213
inCC match
212
214
case None | Some (Nil ) => keyword(arrPrefix + " ->" ).l
213
215
case Some (List (c)) if c.isCaptureRoot => keyword(arrPrefix + " =>" ).l
214
- case Some (refs) => keyword(arrPrefix + " ->" ) :: renderCaptureSet (refs)
216
+ case Some (refs) => keyword(arrPrefix + " ->" ) :: emitCaptureSet (refs)
215
217
else keyword(arrPrefix + " =>" ).l
216
218
val resType = inner(m.resType)(using inCC = None )
217
219
paramList ++ (plain(" " ) :: arrow) ++ (plain(" " ) :: resType)
@@ -265,6 +267,8 @@ trait TypesSupport:
265
267
case _ => topLevelProcess(t)
266
268
}) ++ plain(" ]" ).l
267
269
270
+ case t : TypeRef if t.isCapSet => emitCaptureSet(Nil )
271
+
268
272
case tp @ TypeRef (qual, typeName) =>
269
273
qual match {
270
274
case r : RecursiveThis => tpe(s " this. $typeName" ).l
@@ -350,7 +354,7 @@ trait TypesSupport:
350
354
inCC : Option [List [reflect.TypeRepr ]],
351
355
): SSignature =
352
356
import reflect ._
353
- val arrow = plain(" " ) :: (renderFunctionArrow (using qctx)(funTy, inCC) ++ plain(" " ).l)
357
+ val arrow = plain(" " ) :: (emitFunctionArrow (using qctx)(funTy, inCC) ++ plain(" " ).l)
354
358
given Option [List [TypeRepr ]] = None // FIXME: this is ugly
355
359
args match
356
360
case Nil => Nil
@@ -366,7 +370,10 @@ trait TypesSupport:
366
370
367
371
private def typeBound (using Quotes )(t : reflect.TypeRepr , low : Boolean )(using elideThis : reflect.ClassDef ) =
368
372
import reflect ._
369
- val ignore = if (low) t.typeSymbol == defn.NothingClass else t.typeSymbol == defn.AnyClass
373
+ val ignore = low && (ccEnabled && t.isCapSetPure
374
+ || t.typeSymbol == defn.NothingClass )
375
+ || ! low && (ccEnabled && t.isCapSetCap
376
+ || t.typeSymbol == defn.AnyClass )
370
377
val prefix = keyword(if low then " >: " else " <: " )
371
378
t match {
372
379
case l : TypeLambda => prefix :: inParens(inner(l)(using elideThis))
@@ -466,31 +473,30 @@ trait TypesSupport:
466
473
case AnnotatedType (tr, _) => stripAnnotated(tr)
467
474
case other => other
468
475
469
- private def renderCapability (using Quotes )(ref : reflect.TypeRepr )(using elideThis : reflect.ClassDef ): SSignature =
476
+ private def emitCapability (using Quotes )(ref : reflect.TypeRepr )(using elideThis : reflect.ClassDef ): SSignature =
470
477
import reflect ._
471
478
ref match
472
- case ReachCapability (c) => renderCapability (c) :+ Keyword (" *" )
473
- case ReadOnlyCapability (c) => renderCapability (c) :+ Keyword (" .rd" )
479
+ case ReachCapability (c) => emitCapability (c) :+ Keyword (" *" )
480
+ case ReadOnlyCapability (c) => emitCapability (c) :+ Keyword (" .rd" )
474
481
case ThisType (_) => List (Keyword (" this" ))
475
482
case t => inner(t)(using skipTypeSuffix = true , inCC = Some (Nil ))
476
483
477
- private def renderCaptureSet (using Quotes )(refs : List [reflect.TypeRepr ])(using elideThis : reflect.ClassDef ): SSignature =
478
- import dotty .tools .scaladoc .tasty .NameNormalizer ._
484
+ private def emitCaptureSet (using Quotes )(refs : List [reflect.TypeRepr ], omitCap : Boolean = true )(using elideThis : reflect.ClassDef ): SSignature =
479
485
import reflect ._
480
486
refs match
481
- case List (ref) if ref.isCaptureRoot => Nil
487
+ case List (ref) if omitCap && ref.isCaptureRoot => Nil
482
488
case refs =>
483
- val res0 = refs.map(renderCapability )
489
+ val res0 = refs.map(emitCapability )
484
490
val res1 = res0 match
485
491
case Nil => Nil
486
492
case other => other.reduce((r, e) => r ++ (List (Plain (" , " )) ++ e))
487
493
Plain (" {" ) :: (res1 ++ List (Plain (" }" )))
488
494
489
- private def renderCapturing (using Quotes )(refs : List [reflect.TypeRepr ])(using elideThis : reflect.ClassDef ): SSignature =
495
+ private def emitCapturing (using Quotes )(refs : List [reflect.TypeRepr ])(using elideThis : reflect.ClassDef ): SSignature =
490
496
import reflect ._
491
- Keyword (" ^" ) :: renderCaptureSet (refs)
497
+ Keyword (" ^" ) :: emitCaptureSet (refs)
492
498
493
- private def renderFunctionArrow (using Quotes )(funTy : reflect.TypeRepr , captures : Option [List [reflect.TypeRepr ]])(using elideThis : reflect.ClassDef ): SSignature =
499
+ private def emitFunctionArrow (using Quotes )(funTy : reflect.TypeRepr , captures : Option [List [reflect.TypeRepr ]])(using elideThis : reflect.ClassDef ): SSignature =
494
500
import reflect ._
495
501
val isContextFun = funTy.isAnyContextFunction || funTy.isAnyImpureContextFunction
496
502
val prefix = if isContextFun then " ?" else " "
@@ -506,14 +512,14 @@ trait TypesSupport:
506
512
else if isImpureFun then
507
513
List (Keyword (prefix + " =>" ))
508
514
else
509
- report.error(s " Cannot render function arrow: expected a (Context)Function* or Impure(Context)Function*, but got: ${funTy.show}" )
515
+ report.error(s " Cannot emit function arrow: expected a (Context)Function* or Impure(Context)Function*, but got: ${funTy.show}" )
510
516
Nil
511
517
case Some (refs) =>
512
518
// there is some capture set
513
519
refs match
514
520
case Nil => List (Keyword (prefix + " ->" ))
515
521
case List (ref) if ref.isCaptureRoot => List (Keyword (prefix + " =>" ))
516
- case refs => Keyword (prefix + " ->" ) :: renderCaptureSet (refs)
522
+ case refs => Keyword (prefix + " ->" ) :: emitCaptureSet (refs)
517
523
518
- private def renderByNameArrow (using Quotes )(captures : Option [List [reflect.TypeRepr ]])(using elideThis : reflect.ClassDef ): SSignature =
519
- renderFunctionArrow (CaptureDefs .Function1 .typeRef, captures)
524
+ private def emitByNameArrow (using Quotes )(captures : Option [List [reflect.TypeRepr ]])(using elideThis : reflect.ClassDef ): SSignature =
525
+ emitFunctionArrow (CaptureDefs .Function1 .typeRef, captures)
0 commit comments