@@ -140,6 +140,8 @@ trait TypesSupport:
140
140
case CapturingType (base, refs) => base match
141
141
case t @ AppliedType (base, args) if t.isFunctionType =>
142
142
functionType(base, args, skipThisTypePrefix)(using inCC = Some (refs))
143
+ case t : Refinement if t.isFunctionType =>
144
+ inner(base, skipThisTypePrefix)(using inCC = Some (refs))
143
145
case _ => inner(base, skipThisTypePrefix) ++ renderCapturing(refs, skipThisTypePrefix)
144
146
case AnnotatedType (tpe, _) =>
145
147
inner(tpe, skipThisTypePrefix)
@@ -213,12 +215,19 @@ trait TypesSupport:
213
215
val isCtx = isContextualMethod(m)
214
216
if isDependentMethod(m) then
215
217
val paramList = getParamList(m)
216
- val arrow = keyword(if isCtx then " ?=> " else " => " ).l
217
- val resType = inner(m.resType, skipThisTypePrefix)
218
- paramList ++ arrow ++ resType
218
+ val arrPrefix = if isCtx then " ?" else " "
219
+ val arrow =
220
+ if ccEnabled then
221
+ inCC match
222
+ case None | Some (Nil ) => keyword(arrPrefix + " ->" ).l
223
+ case Some (List (c)) if c.isCaptureRoot => keyword(arrPrefix + " =>" ).l
224
+ case Some (refs) => keyword(arrPrefix + " ->" ) :: renderCaptureSet(refs, skipThisTypePrefix)
225
+ else keyword(arrPrefix + " =>" ).l
226
+ val resType = inner(m.resType, skipThisTypePrefix)(using inCC = None )
227
+ paramList ++ (plain(" " ) :: arrow) ++ (plain(" " ) :: resType)
219
228
else
220
229
val sym = defn.FunctionClass (m.paramTypes.length, isCtx)
221
- inner(sym.typeRef.appliedTo(m.paramTypes :+ m.resType), skipThisTypePrefix)
230
+ inner(sym.typeRef.appliedTo(m.paramTypes :+ m.resType), skipThisTypePrefix)( using inCC = None )
222
231
case other => noSupported(" Dependent function type without MethodType refinement" )
223
232
}
224
233
@@ -523,13 +532,14 @@ trait TypesSupport:
523
532
else
524
533
report.error(s " Cannot render function arrow: expected a (Context)Function* or Impure(Context)Function*, but got: ${funTy.show}" )
525
534
Nil
526
- case Some (refs) => // there is some capture set
535
+ case Some (refs) =>
536
+ // there is some capture set
527
537
refs match
528
538
case Nil => List (Keyword (prefix + " ->" ))
529
539
case List (ref) if ref.isCaptureRoot => List (Keyword (prefix + " =>" ))
530
540
case refs => Keyword (prefix + " ->" ) :: renderCaptureSet(using q)(refs, skipThisTypePrefix)
531
541
532
- private def renderByNameArrow (using q : Quotes )(captures : Option [List [reflect.TypeRepr ]], skipThisTypePrefix : Boolean )(
542
+ private def renderByNameArrow (using Quotes )(captures : Option [List [reflect.TypeRepr ]], skipThisTypePrefix : Boolean )(
533
543
using elideThis : reflect.ClassDef , originalOwner : reflect.Symbol
534
544
): SSignature =
535
- renderFunctionArrow(using q)( CaptureDefs .Function1 .typeRef, captures, skipThisTypePrefix)
545
+ renderFunctionArrow(CaptureDefs .Function1 .typeRef, captures, skipThisTypePrefix)
0 commit comments