@@ -11,8 +11,6 @@ import dotty.tools.scaladoc.cc.*
11
11
import NameNormalizer ._
12
12
import SyntheticsSupport ._
13
13
14
- private case class FunKind (isPure : Boolean , isImplicit : Boolean )
15
-
16
14
trait TypesSupport :
17
15
self : TastyParser =>
18
16
@@ -142,9 +140,9 @@ trait TypesSupport:
142
140
case t @ AppliedType (base, args) if t.isFunctionType =>
143
141
functionType(base, args, skipThisTypePrefix)(using inCC = Some (refs))
144
142
case t : Refinement if t.isFunctionType =>
145
- inner(base, skipThisTypePrefix)(using inCC = Some (refs))
143
+ inner(base, skipThisTypePrefix)(using indent = indent, skipTypeSuffix = skipTypeSuffix, inCC = Some (refs))
146
144
case t if t.isCapSet => emitCaptureSet(refs, skipThisTypePrefix, omitCap = false )
147
- case _ => inner(base, skipThisTypePrefix) ++ emitCapturing(refs, skipThisTypePrefix)
145
+ case t => inner(base, skipThisTypePrefix) ++ emitCapturing(refs, skipThisTypePrefix)
148
146
case AnnotatedType (tpe, _) =>
149
147
inner(tpe, skipThisTypePrefix)
150
148
case tl @ TypeLambda (params, paramBounds, AppliedType (tpe, args))
@@ -169,6 +167,8 @@ trait TypesSupport:
169
167
inner(Refinement (at, " apply" , mt), skipThisTypePrefix)
170
168
171
169
case r : Refinement => { // (parent, name, info)
170
+ val inCC0 = inCC
171
+ given Option [List [TypeRepr ]] = None // do not propagate capture set beyond this point
172
172
def getRefinementInformation (t : TypeRepr ): List [TypeRepr ] = t match {
173
173
case r : Refinement => getRefinementInformation(r.parent) :+ r
174
174
case t => List (t)
@@ -224,16 +224,16 @@ trait TypesSupport:
224
224
val arrPrefix = if isCtx then " ?" else " "
225
225
val arrow =
226
226
if ccEnabled then
227
- inCC match
227
+ inCC0 match
228
228
case None | Some (Nil ) => keyword(arrPrefix + " ->" ).l
229
229
case Some (List (c)) if c.isCaptureRoot => keyword(arrPrefix + " =>" ).l
230
230
case Some (refs) => keyword(arrPrefix + " ->" ) :: emitCaptureSet(refs, skipThisTypePrefix)
231
231
else keyword(arrPrefix + " =>" ).l
232
- val resType = inner(m.resType, skipThisTypePrefix)( using inCC = None )
232
+ val resType = inner(m.resType, skipThisTypePrefix)
233
233
paramList ++ (plain(" " ) :: arrow) ++ (plain(" " ) :: resType)
234
234
else
235
235
val sym = defn.FunctionClass (m.paramTypes.length, isCtx)
236
- inner(sym.typeRef.appliedTo(m.paramTypes :+ m.resType), skipThisTypePrefix)( using inCC = None )
236
+ inner(sym.typeRef.appliedTo(m.paramTypes :+ m.resType), skipThisTypePrefix)
237
237
case other => noSupported(" Dependent function type without MethodType refinement" )
238
238
}
239
239
@@ -286,25 +286,27 @@ trait TypesSupport:
286
286
case tp @ TypeRef (qual, typeName) =>
287
287
qual match {
288
288
case r : RecursiveThis => tpe(s " this. $typeName" ).l
289
+ case t if skipPrefix(t, elideThis, originalOwner, skipThisTypePrefix) =>
290
+ tpe(tp.typeSymbol)
291
+ case _ : TermRef | _ : ParamRef =>
292
+ val suffix = if tp.typeSymbol == Symbol .noSymbol then tpe(typeName).l else tpe(tp.typeSymbol)
293
+ inner(qual, skipThisTypePrefix)(using skipTypeSuffix = true , inCC = inCC) ++ plain(" ." ).l ++ suffix
289
294
case ThisType (tr) =>
290
- val typeFromSupertypeConstructor = findSupertype(elideThis, tr.typeSymbol) match
295
+ findSupertype(elideThis, tr.typeSymbol) match
291
296
case Some ((sym, AppliedType (tr2, args))) =>
292
297
sym.tree.asInstanceOf [ClassDef ].constructor.paramss.headOption match
293
298
case Some (TypeParamClause (tpc)) =>
294
299
tpc.zip(args).collectFirst {
295
300
case (TypeDef (name, _), arg) if name == typeName => arg
296
- }.map(inner(_, skipThisTypePrefix))
297
- case _ => None
298
- case _ => None
299
- typeFromSupertypeConstructor.getOrElse:
300
- if skipPrefix(qual, elideThis, originalOwner, skipThisTypePrefix) then
301
- tpe(tp.typeSymbol)
302
- else
303
- val sig = inParens(inner(qual, skipThisTypePrefix)(using skipTypeSuffix = true ), shouldWrapInParens(qual, tp, true ))
301
+ } match
302
+ case Some (tr) => inner(tr, skipThisTypePrefix)
303
+ case None => tpe(tp.typeSymbol)
304
+ case _ => tpe(tp.typeSymbol)
305
+ case Some (_) => tpe(tp.typeSymbol)
306
+ case None =>
307
+ val sig = inParens(inner(qual, skipThisTypePrefix)(using skipTypeSuffix = true , inCC = inCC), shouldWrapInParens(qual, tp, true ))
304
308
sig ++ plain(" ." ).l ++ tpe(tp.typeSymbol)
305
309
306
- case t if skipPrefix(t, elideThis, originalOwner, skipThisTypePrefix) =>
307
- tpe(tp.typeSymbol)
308
310
case _ : TermRef | _ : ParamRef =>
309
311
val suffix = if tp.typeSymbol == Symbol .noSymbol then tpe(typeName).l else tpe(tp.typeSymbol)
310
312
inner(qual, skipThisTypePrefix)(using skipTypeSuffix = true ) ++ plain(" ." ).l ++ suffix
@@ -316,7 +318,7 @@ trait TypesSupport:
316
318
case tr @ TermRef (qual, typeName) =>
317
319
val prefix = qual match
318
320
case t if skipPrefix(t, elideThis, originalOwner, skipThisTypePrefix) => Nil
319
- case tp => inner(tp, skipThisTypePrefix)(using skipTypeSuffix = true ) ++ plain(" ." ).l
321
+ case tp => inner(tp, skipThisTypePrefix)(using skipTypeSuffix = true , inCC = inCC ) ++ plain(" ." ).l
320
322
val suffix = if skipTypeSuffix then Nil else List (plain(" ." ), keyword(" type" ))
321
323
val typeSig = tr.termSymbol.tree match
322
324
case vd : ValDef if tr.termSymbol.flags.is(Flags .Module ) =>
@@ -335,9 +337,9 @@ trait TypesSupport:
335
337
val spaces = " " * (indent)
336
338
val casesTexts = cases.flatMap {
337
339
case MatchCase (from, to) =>
338
- keyword(caseSpaces + " case " ).l ++ inner(from, skipThisTypePrefix) ++ keyword(" => " ).l ++ inner(to, skipThisTypePrefix)(using indent = indent + 2 ) ++ plain(" \n " ).l
340
+ keyword(caseSpaces + " case " ).l ++ inner(from, skipThisTypePrefix) ++ keyword(" => " ).l ++ inner(to, skipThisTypePrefix)(using indent = indent + 2 , inCC = inCC ) ++ plain(" \n " ).l
339
341
case TypeLambda (_, _, MatchCase (from, to)) =>
340
- keyword(caseSpaces + " case " ).l ++ inner(from, skipThisTypePrefix) ++ keyword(" => " ).l ++ inner(to, skipThisTypePrefix)(using indent = indent + 2 ) ++ plain(" \n " ).l
342
+ keyword(caseSpaces + " case " ).l ++ inner(from, skipThisTypePrefix) ++ keyword(" => " ).l ++ inner(to, skipThisTypePrefix)(using indent = indent + 2 , inCC = inCC ) ++ plain(" \n " ).l
341
343
}
342
344
inner(sc, skipThisTypePrefix) ++ keyword(" match " ).l ++ plain(" {\n " ).l ++ casesTexts ++ plain(spaces + " }" ).l
343
345
@@ -371,7 +373,7 @@ trait TypesSupport:
371
373
): SSignature =
372
374
import reflect ._
373
375
val arrow = plain(" " ) :: (emitFunctionArrow(using q)(funTy, inCC, skipThisTypePrefix) ++ plain(" " ).l)
374
- given Option [List [TypeRepr ]] = None // FIXME: this is ugly
376
+ given Option [List [TypeRepr ]] = None // do not propagate capture set beyond this point
375
377
args match
376
378
case Nil => Nil
377
379
case List (rtpe) => plain(" ()" ).l ++ arrow ++ inner(rtpe, skipThisTypePrefix)
@@ -403,14 +405,14 @@ trait TypesSupport:
403
405
) =
404
406
import reflect ._
405
407
def regularTypeBounds (low : TypeRepr , high : TypeRepr ) =
406
- if low == high then keyword(" = " ).l ++ inner(low, skipThisTypePrefix)(using elideThis, originalOwner)
408
+ if low == high then keyword(" = " ).l ++ inner(low, skipThisTypePrefix)(using elideThis, originalOwner, inCC = inCC )
407
409
else typeBound(low, low = true , skipThisTypePrefix)(using elideThis, originalOwner) ++ typeBound(high, low = false , skipThisTypePrefix)(using elideThis, originalOwner)
408
410
high.match
409
411
case TypeLambda (params, paramBounds, resType) =>
410
412
if resType.typeSymbol == defn.AnyClass then
411
413
plain(" [" ).l ++ commas(params.zip(paramBounds).map { (name, typ) =>
412
414
val normalizedName = if name.matches(" _\\ $\\ d*" ) then " _" else name
413
- tpe(normalizedName)(using inCC).l ++ inner(typ, skipThisTypePrefix)(using elideThis, originalOwner)
415
+ tpe(normalizedName)(using inCC).l ++ inner(typ, skipThisTypePrefix)(using elideThis, originalOwner, inCC = inCC )
414
416
}) ++ plain(" ]" ).l
415
417
else
416
418
regularTypeBounds(low, high)
0 commit comments