@@ -62,7 +62,7 @@ trait TypesSupport:
62
62
private def tpe (using Quotes )(symbol : reflect.Symbol )(using inCC : Option [Any ]): SSignature =
63
63
import SymOps ._
64
64
val dri : Option [DRI ] = Option (symbol).filterNot(_.isHiddenByVisibility).map(_.dri)
65
- if inCC.isDefined then
65
+ if inCC.isDefined then // we are in the context of a capture set and want paths to be rendered plainly
66
66
dotty.tools.scaladoc.Plain (symbol.normalizedName).l
67
67
else
68
68
dotty.tools.scaladoc.Type (symbol.normalizedName, dri).l
@@ -124,9 +124,9 @@ trait TypesSupport:
124
124
++ keyword(" & " ).l
125
125
++ inParens(inner(right, skipThisTypePrefix), shouldWrapInParens(right, tp, false ))
126
126
case ByNameType (CapturingType (tpe, refs)) =>
127
- renderByNameArrow (using q)(Some (refs), skipThisTypePrefix) ++ (plain(" " ) :: inner(tpe, skipThisTypePrefix))
127
+ emitByNameArrow (using q)(Some (refs), skipThisTypePrefix) ++ (plain(" " ) :: inner(tpe, skipThisTypePrefix))
128
128
case ByNameType (tpe) =>
129
- renderByNameArrow (using q)(None , skipThisTypePrefix) ++ (plain(" " ) :: inner(tpe, skipThisTypePrefix))
129
+ emitByNameArrow (using q)(None , skipThisTypePrefix) ++ (plain(" " ) :: inner(tpe, skipThisTypePrefix))
130
130
case ConstantType (constant) =>
131
131
plain(constant.show).l
132
132
case ThisType (tpe) =>
@@ -137,12 +137,14 @@ trait TypesSupport:
137
137
inner(tpe, skipThisTypePrefix) :+ plain(" *" )
138
138
case AppliedType (repeatedClass, Seq (tpe)) if isRepeated(repeatedClass) =>
139
139
inner(tpe, skipThisTypePrefix) :+ plain(" *" )
140
- case CapturingType (base, refs) => base match
141
- case t @ AppliedType (base, args) if t.isFunctionType =>
142
- functionType(base, args, skipThisTypePrefix)(using inCC = Some (refs))
143
- case t : Refinement if t.isFunctionType =>
144
- inner(base, skipThisTypePrefix)(using inCC = Some (refs))
145
- case _ => inner(base, skipThisTypePrefix) ++ renderCapturing(refs, skipThisTypePrefix)
140
+ case CapturingType (base, refs) =>
141
+ base match
142
+ case t @ AppliedType (base, args) if t.isFunctionType =>
143
+ functionType(base, args, skipThisTypePrefix)(using inCC = Some (refs))
144
+ case t : Refinement if t.isFunctionType =>
145
+ inner(base, skipThisTypePrefix)(using inCC = Some (refs))
146
+ case t if t.isCapSet => emitCaptureSet(refs, skipThisTypePrefix, omitCap = false )
147
+ case _ => inner(base, skipThisTypePrefix) ++ emitCapturing(refs, skipThisTypePrefix)
146
148
case AnnotatedType (tpe, _) =>
147
149
inner(tpe, skipThisTypePrefix)
148
150
case tl @ TypeLambda (params, paramBounds, AppliedType (tpe, args))
@@ -221,7 +223,7 @@ trait TypesSupport:
221
223
inCC match
222
224
case None | Some (Nil ) => keyword(arrPrefix + " ->" ).l
223
225
case Some (List (c)) if c.isCaptureRoot => keyword(arrPrefix + " =>" ).l
224
- case Some (refs) => keyword(arrPrefix + " ->" ) :: renderCaptureSet (refs, skipThisTypePrefix)
226
+ case Some (refs) => keyword(arrPrefix + " ->" ) :: emitCaptureSet (refs, skipThisTypePrefix)
225
227
else keyword(arrPrefix + " =>" ).l
226
228
val resType = inner(m.resType, skipThisTypePrefix)(using inCC = None )
227
229
paramList ++ (plain(" " ) :: arrow) ++ (plain(" " ) :: resType)
@@ -275,6 +277,8 @@ trait TypesSupport:
275
277
case _ => topLevelProcess(t, skipThisTypePrefix)
276
278
}) ++ plain(" ]" ).l
277
279
280
+ case t : TypeRef if t.isCapSet => emitCaptureSet(Nil , skipThisTypePrefix)
281
+
278
282
case tp @ TypeRef (qual, typeName) =>
279
283
qual match {
280
284
case r : RecursiveThis => tpe(s " this. $typeName" ).l
@@ -362,7 +366,7 @@ trait TypesSupport:
362
366
inCC : Option [List [reflect.TypeRepr ]],
363
367
): SSignature =
364
368
import reflect ._
365
- val arrow = plain(" " ) :: (renderFunctionArrow (using q)(funTy, inCC, skipThisTypePrefix) ++ plain(" " ).l)
369
+ val arrow = plain(" " ) :: (emitFunctionArrow (using q)(funTy, inCC, skipThisTypePrefix) ++ plain(" " ).l)
366
370
given Option [List [TypeRepr ]] = None // FIXME: this is ugly
367
371
args match
368
372
case Nil => Nil
@@ -378,7 +382,10 @@ trait TypesSupport:
378
382
379
383
private def typeBound (using Quotes )(t : reflect.TypeRepr , low : Boolean , skipThisTypePrefix : Boolean )(using elideThis : reflect.ClassDef , originalOwner : reflect.Symbol ) =
380
384
import reflect ._
381
- val ignore = if (low) t.typeSymbol == defn.NothingClass else t.typeSymbol == defn.AnyClass
385
+ val ignore = low && (ccEnabled && t.isCapSetPure
386
+ || t.typeSymbol == defn.NothingClass )
387
+ || ! low && (ccEnabled && t.isCapSetCap
388
+ || t.typeSymbol == defn.AnyClass )
382
389
val prefix = keyword(if low then " >: " else " <: " )
383
390
t match {
384
391
case l : TypeLambda => prefix :: inParens(inner(l, skipThisTypePrefix)(using elideThis, originalOwner))
@@ -482,37 +489,36 @@ trait TypesSupport:
482
489
case AnnotatedType (tr, _) => stripAnnotated(tr)
483
490
case other => other
484
491
485
- private def renderCapability (using Quotes )(ref : reflect.TypeRepr , skipThisTypePrefix : Boolean )(
492
+ private def emitCapability (using Quotes )(ref : reflect.TypeRepr , skipThisTypePrefix : Boolean )(
486
493
using elideThis : reflect.ClassDef , originalOwner : reflect.Symbol
487
494
): SSignature =
488
495
import reflect ._
489
496
ref match
490
- case ReachCapability (c) => renderCapability (c, skipThisTypePrefix) :+ Keyword (" *" )
491
- case ReadOnlyCapability (c) => renderCapability (c, skipThisTypePrefix) :+ Keyword (" .rd" )
497
+ case ReachCapability (c) => emitCapability (c, skipThisTypePrefix) :+ Keyword (" *" )
498
+ case ReadOnlyCapability (c) => emitCapability (c, skipThisTypePrefix) :+ Keyword (" .rd" )
492
499
case ThisType (_) => List (Keyword (" this" ))
493
500
case t => inner(t, skipThisTypePrefix)(using skipTypeSuffix = true , inCC = Some (Nil ))
494
501
495
- private def renderCaptureSet (using Quotes )(refs : List [reflect.TypeRepr ], skipThisTypePrefix : Boolean )(
502
+ private def emitCaptureSet (using Quotes )(refs : List [reflect.TypeRepr ], skipThisTypePrefix : Boolean , omitCap : Boolean = true )(
496
503
using elideThis : reflect.ClassDef , originalOwner : reflect.Symbol
497
504
): SSignature =
498
- import dotty .tools .scaladoc .tasty .NameNormalizer ._
499
505
import reflect ._
500
506
refs match
501
- case List (ref) if ref.isCaptureRoot => Nil
507
+ case List (ref) if omitCap && ref.isCaptureRoot => Nil
502
508
case refs =>
503
- val res0 = refs.map(renderCapability (_, skipThisTypePrefix))
509
+ val res0 = refs.map(emitCapability (_, skipThisTypePrefix))
504
510
val res1 = res0 match
505
511
case Nil => Nil
506
512
case other => other.reduce((r, e) => r ++ (List (Plain (" , " )) ++ e))
507
513
Plain (" {" ) :: (res1 ++ List (Plain (" }" )))
508
514
509
- private def renderCapturing (using Quotes )(refs : List [reflect.TypeRepr ], skipThisTypePrefix : Boolean )(
515
+ private def emitCapturing (using Quotes )(refs : List [reflect.TypeRepr ], skipThisTypePrefix : Boolean )(
510
516
using elideThis : reflect.ClassDef , originalOwner : reflect.Symbol
511
517
): SSignature =
512
518
import reflect ._
513
- Keyword (" ^" ) :: renderCaptureSet (refs, skipThisTypePrefix)
519
+ Keyword (" ^" ) :: emitCaptureSet (refs, skipThisTypePrefix)
514
520
515
- private def renderFunctionArrow (using q : Quotes )(funTy : reflect.TypeRepr , captures : Option [List [reflect.TypeRepr ]], skipThisTypePrefix : Boolean )(
521
+ private def emitFunctionArrow (using Quotes )(funTy : reflect.TypeRepr , captures : Option [List [reflect.TypeRepr ]], skipThisTypePrefix : Boolean )(
516
522
using elideThis : reflect.ClassDef , originalOwner : reflect.Symbol
517
523
): SSignature =
518
524
import reflect ._
@@ -530,16 +536,16 @@ trait TypesSupport:
530
536
else if isImpureFun then
531
537
List (Keyword (prefix + " =>" ))
532
538
else
533
- report.error(s " Cannot render function arrow: expected a (Context)Function* or Impure(Context)Function*, but got: ${funTy.show}" )
539
+ report.error(s " Cannot emit function arrow: expected a (Context)Function* or Impure(Context)Function*, but got: ${funTy.show}" )
534
540
Nil
535
541
case Some (refs) =>
536
542
// there is some capture set
537
543
refs match
538
544
case Nil => List (Keyword (prefix + " ->" ))
539
545
case List (ref) if ref.isCaptureRoot => List (Keyword (prefix + " =>" ))
540
- case refs => Keyword (prefix + " ->" ) :: renderCaptureSet( using q) (refs, skipThisTypePrefix)
546
+ case refs => Keyword (prefix + " ->" ) :: emitCaptureSet (refs, skipThisTypePrefix)
541
547
542
- private def renderByNameArrow (using Quotes )(captures : Option [List [reflect.TypeRepr ]], skipThisTypePrefix : Boolean )(
548
+ private def emitByNameArrow (using Quotes )(captures : Option [List [reflect.TypeRepr ]], skipThisTypePrefix : Boolean )(
543
549
using elideThis : reflect.ClassDef , originalOwner : reflect.Symbol
544
550
): SSignature =
545
- renderFunctionArrow (CaptureDefs .Function1 .typeRef, captures, skipThisTypePrefix)
551
+ emitFunctionArrow (CaptureDefs .Function1 .typeRef, captures, skipThisTypePrefix)
0 commit comments