@@ -133,6 +133,8 @@ trait TypesSupport:
133
133
case CapturingType (base, refs) => base match
134
134
case t @ AppliedType (base, args) if t.isFunctionType =>
135
135
functionType(base, args)(using inCC = Some (refs))
136
+ case t : Refinement if t.isFunctionType =>
137
+ inner(base)(using inCC = Some (refs))
136
138
case _ => inner(base) ++ renderCapturing(refs)
137
139
case AnnotatedType (tpe, _) =>
138
140
inner(tpe)
@@ -203,12 +205,19 @@ trait TypesSupport:
203
205
val isCtx = isContextualMethod(m)
204
206
if isDependentMethod(m) then
205
207
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)
209
218
else
210
219
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 )
212
221
case other => noSupported(" Dependent function type without MethodType refinement" )
213
222
}
214
223
@@ -499,11 +508,12 @@ trait TypesSupport:
499
508
else
500
509
report.error(s " Cannot render function arrow: expected a (Context)Function* or Impure(Context)Function*, but got: ${funTy.show}" )
501
510
Nil
502
- case Some (refs) => // there is some capture set
511
+ case Some (refs) =>
512
+ // there is some capture set
503
513
refs match
504
514
case Nil => List (Keyword (prefix + " ->" ))
505
515
case List (ref) if ref.isCaptureRoot => List (Keyword (prefix + " =>" ))
506
516
case refs => Keyword (prefix + " ->" ) :: renderCaptureSet(refs)
507
517
508
518
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