@@ -135,9 +135,9 @@ trait TypesSupport:
135
135
case t @ AppliedType (base, args) if t.isFunctionType =>
136
136
functionType(base, args)(using inCC = Some (refs))
137
137
case t : Refinement if t.isFunctionType =>
138
- inner(base)(using inCC = Some (refs))
138
+ inner(base)(using indent = indent, skipTypeSuffix = skipTypeSuffix, inCC = Some (refs))
139
139
case t if t.isCapSet => emitCaptureSet(refs, omitCap = false )
140
- case _ => inner(base) ++ emitCapturing(refs)
140
+ case t => inner(base) ++ emitCapturing(refs)
141
141
case AnnotatedType (tpe, _) =>
142
142
inner(tpe)
143
143
case tl @ TypeLambda (params, paramBounds, AppliedType (tpe, args))
@@ -159,6 +159,8 @@ trait TypesSupport:
159
159
inner(Refinement (at, " apply" , mt))
160
160
161
161
case r : Refinement => { // (parent, name, info)
162
+ val inCC0 = inCC
163
+ given Option [List [TypeRepr ]] = None // do not propagate capture set beyond this point
162
164
def getRefinementInformation (t : TypeRepr ): List [TypeRepr ] = t match {
163
165
case r : Refinement => getRefinementInformation(r.parent) :+ r
164
166
case t => List (t)
@@ -214,16 +216,16 @@ trait TypesSupport:
214
216
val arrPrefix = if isCtx then " ?" else " "
215
217
val arrow =
216
218
if ccEnabled then
217
- inCC match
219
+ inCC0 match
218
220
case None | Some (Nil ) => keyword(arrPrefix + " ->" ).l
219
221
case Some (List (c)) if c.isCaptureRoot => keyword(arrPrefix + " =>" ).l
220
222
case Some (refs) => keyword(arrPrefix + " ->" ) :: emitCaptureSet(refs)
221
223
else keyword(arrPrefix + " =>" ).l
222
- val resType = inner(m.resType)( using inCC = None )
224
+ val resType = inner(m.resType)
223
225
paramList ++ (plain(" " ) :: arrow) ++ (plain(" " ) :: resType)
224
226
else
225
227
val sym = defn.FunctionClass (m.paramTypes.length, isCtx)
226
- inner(sym.typeRef.appliedTo(m.paramTypes :+ m.resType))( using inCC = None )
228
+ inner(sym.typeRef.appliedTo(m.paramTypes :+ m.resType))
227
229
case other => noSupported(" Dependent function type without MethodType refinement" )
228
230
}
229
231
@@ -280,7 +282,7 @@ trait TypesSupport:
280
282
tpe(tp.typeSymbol)
281
283
case _ : TermRef | _ : ParamRef =>
282
284
val suffix = if tp.typeSymbol == Symbol .noSymbol then tpe(typeName).l else tpe(tp.typeSymbol)
283
- inner(qual)(using skipTypeSuffix = true ) ++ plain(" ." ).l ++ suffix
285
+ inner(qual)(using skipTypeSuffix = true , inCC = inCC ) ++ plain(" ." ).l ++ suffix
284
286
case ThisType (tr) =>
285
287
findSupertype(elideThis, tr.typeSymbol) match
286
288
case Some ((sym, AppliedType (tr2, args))) =>
@@ -294,7 +296,7 @@ trait TypesSupport:
294
296
case _ => tpe(tp.typeSymbol)
295
297
case Some (_) => tpe(tp.typeSymbol)
296
298
case None =>
297
- val sig = inParens(inner(qual)(using skipTypeSuffix = true ), shouldWrapInParens(qual, tp, true ))
299
+ val sig = inParens(inner(qual)(using skipTypeSuffix = true , inCC = inCC ), shouldWrapInParens(qual, tp, true ))
298
300
sig ++ plain(" ." ).l ++ tpe(tp.typeSymbol)
299
301
case _ =>
300
302
val sig = inParens(inner(qual), shouldWrapInParens(qual, tp, true ))
@@ -304,7 +306,7 @@ trait TypesSupport:
304
306
case tr @ TermRef (qual, typeName) =>
305
307
val prefix = qual match
306
308
case t if skipPrefix(t, elideThis) => Nil
307
- case tp => inner(tp)(using skipTypeSuffix = true ) ++ plain(" ." ).l
309
+ case tp => inner(tp)(using skipTypeSuffix = true , inCC = inCC ) ++ plain(" ." ).l
308
310
val suffix = if skipTypeSuffix then Nil else List (plain(" ." ), keyword(" type" ))
309
311
val typeSig = tr.termSymbol.tree match
310
312
case vd : ValDef if tr.termSymbol.flags.is(Flags .Module ) =>
@@ -323,9 +325,9 @@ trait TypesSupport:
323
325
val spaces = " " * (indent)
324
326
val casesTexts = cases.flatMap {
325
327
case MatchCase (from, to) =>
326
- keyword(caseSpaces + " case " ).l ++ inner(from) ++ keyword(" => " ).l ++ inner(to)(using indent = indent + 2 ) ++ plain(" \n " ).l
328
+ keyword(caseSpaces + " case " ).l ++ inner(from) ++ keyword(" => " ).l ++ inner(to)(using indent = indent + 2 , inCC = inCC ) ++ plain(" \n " ).l
327
329
case TypeLambda (_, _, MatchCase (from, to)) =>
328
- keyword(caseSpaces + " case " ).l ++ inner(from) ++ keyword(" => " ).l ++ inner(to)(using indent = indent + 2 ) ++ plain(" \n " ).l
330
+ keyword(caseSpaces + " case " ).l ++ inner(from) ++ keyword(" => " ).l ++ inner(to)(using indent = indent + 2 , inCC = inCC ) ++ plain(" \n " ).l
329
331
}
330
332
inner(sc) ++ keyword(" match " ).l ++ plain(" {\n " ).l ++ casesTexts ++ plain(spaces + " }" ).l
331
333
@@ -359,7 +361,7 @@ trait TypesSupport:
359
361
): SSignature =
360
362
import reflect ._
361
363
val arrow = plain(" " ) :: (emitFunctionArrow(using qctx)(funTy, inCC) ++ plain(" " ).l)
362
- given Option [List [TypeRepr ]] = None // FIXME: this is ugly
364
+ given Option [List [TypeRepr ]] = None // do not propagate capture set beyond this point
363
365
args match
364
366
case Nil => Nil
365
367
case List (rtpe) => plain(" ()" ).l ++ arrow ++ inner(rtpe)
@@ -389,14 +391,14 @@ trait TypesSupport:
389
391
private def typeBoundsTreeOfHigherKindedType (using Quotes )(low : reflect.TypeRepr , high : reflect.TypeRepr )(using elideThis : reflect.ClassDef , inCC : Option [List [reflect.TypeRepr ]]) =
390
392
import reflect ._
391
393
def regularTypeBounds (low : TypeRepr , high : TypeRepr ) =
392
- if low == high then keyword(" = " ).l ++ inner(low)(using elideThis)
394
+ if low == high then keyword(" = " ).l ++ inner(low)(using elideThis, inCC = inCC )
393
395
else typeBound(low, low = true )(using elideThis) ++ typeBound(high, low = false )(using elideThis)
394
396
high.match
395
397
case TypeLambda (params, paramBounds, resType) =>
396
398
if resType.typeSymbol == defn.AnyClass then
397
399
plain(" [" ).l ++ commas(params.zip(paramBounds).map { (name, typ) =>
398
400
val normalizedName = if name.matches(" _\\ $\\ d*" ) then " _" else name
399
- tpe(normalizedName)(using inCC).l ++ inner(typ)(using elideThis)
401
+ tpe(normalizedName)(using inCC).l ++ inner(typ)(using elideThis, inCC = inCC )
400
402
}) ++ plain(" ]" ).l
401
403
else
402
404
regularTypeBounds(low, high)
0 commit comments