@@ -133,6 +133,8 @@ trait TypesSupport:
133133 case CapturingType (base, refs) => base match
134134 case t @ AppliedType (base, args) if t.isFunctionType =>
135135 functionType(base, args)(using inCC = Some (refs))
136+ case t : Refinement if t.isFunctionType =>
137+ inner(base)(using inCC = Some (refs))
136138 case _ => inner(base) ++ renderCapturing(refs)
137139 case AnnotatedType (tpe, _) =>
138140 inner(tpe)
@@ -203,12 +205,19 @@ trait TypesSupport:
203205 val isCtx = isContextualMethod(m)
204206 if isDependentMethod(m) then
205207 val paramList = getParamList(m)
206- val arrow = keyword(if isCtx then " ?=> " else " => " ).l
207- val resType = inner(m.resType)
208- paramList ++ arrow ++ resType
208+ val arrPrefix = if isCtx then " ?" else " "
209+ val arrow =
210+ if ccEnabled then
211+ inCC match
212+ case None | Some (Nil ) => keyword(arrPrefix + " ->" ).l
213+ case Some (List (c)) if c.isCaptureRoot => keyword(arrPrefix + " =>" ).l
214+ case Some (refs) => keyword(arrPrefix + " ->" ) :: renderCaptureSet(refs)
215+ else keyword(arrPrefix + " =>" ).l
216+ val resType = inner(m.resType)(using inCC = None )
217+ paramList ++ (plain(" " ) :: arrow) ++ (plain(" " ) :: resType)
209218 else
210219 val sym = defn.FunctionClass (m.paramTypes.length, isCtx)
211- inner(sym.typeRef.appliedTo(m.paramTypes :+ m.resType))
220+ inner(sym.typeRef.appliedTo(m.paramTypes :+ m.resType))( using inCC = None )
212221 case other => noSupported(" Dependent function type without MethodType refinement" )
213222 }
214223
@@ -499,11 +508,12 @@ trait TypesSupport:
499508 else
500509 report.error(s " Cannot render function arrow: expected a (Context)Function* or Impure(Context)Function*, but got: ${funTy.show}" )
501510 Nil
502- case Some (refs) => // there is some capture set
511+ case Some (refs) =>
512+ // there is some capture set
503513 refs match
504514 case Nil => List (Keyword (prefix + " ->" ))
505515 case List (ref) if ref.isCaptureRoot => List (Keyword (prefix + " =>" ))
506516 case refs => Keyword (prefix + " ->" ) :: renderCaptureSet(refs)
507517
508518 private def renderByNameArrow (using Quotes )(captures : Option [List [reflect.TypeRepr ]])(using elideThis : reflect.ClassDef ): SSignature =
509- renderFunctionArrow(CaptureDefs .Function1 .typeRef, captures)
519+ renderFunctionArrow(CaptureDefs .Function1 .typeRef, captures)
0 commit comments