@@ -91,7 +91,7 @@ trait TypesSupport:
91
91
92
92
// TODO #23 add support for all types signatures that make sense
93
93
private def inner (
94
- using Quotes ,
94
+ using qctx : Quotes ,
95
95
)(
96
96
tp : reflect.TypeRepr ,
97
97
)(using
@@ -115,8 +115,10 @@ trait TypesSupport:
115
115
++ keyword(" & " ).l
116
116
++ inParens(inner(right), shouldWrapInParens(right, tp, false ))
117
117
case ByNameType (CapturingType (tpe, refs)) =>
118
- renderCaptureArrow(refs) ++ (plain(" " ) :: inner(tpe))
119
- case ByNameType (tpe) => keyword(" =>!! " ) :: inner(tpe) // FIXME: does it need change for CC?
118
+ renderCaptureArrow(using qctx)(refs, false ) ++ (plain(" " ) :: inner(tpe))
119
+ case ByNameType (tpe) =>
120
+ tpe.typeSymbol.pos.map(p => report.warning(s " Pure ByNameType at ${p}" ))
121
+ keyword(" -> " ) :: inner(tpe) // FIXME need to check if cc is enabled in current file first!!!
120
122
case ConstantType (constant) =>
121
123
plain(constant.show).l
122
124
case ThisType (tpe) =>
@@ -332,16 +334,20 @@ trait TypesSupport:
332
334
s " ${tpe.show(using Printer .TypeReprStructure )}"
333
335
throw MatchError (msg)
334
336
335
- private def functionType (using Quotes )(t : reflect.TypeRepr , tpe : reflect.TypeRepr , args : List [reflect.TypeRepr ])(using
337
+ private def functionType (using qctx : Quotes )(t : reflect.TypeRepr , tpe : reflect.TypeRepr , args : List [reflect.TypeRepr ])(using
336
338
elideThis : reflect.ClassDef ,
337
339
indent : Int ,
338
340
skipTypeSuffix : Boolean ,
339
341
inCC : Option [List [reflect.TypeRepr ]],
340
342
): SSignature =
341
343
import reflect ._
342
- val arrow = if t.isContextFunctionType then keyword(" ?=> " ).l // FIXME: can we have contextual functions with capture sets?
343
- else plain(" " ) :: (renderCaptureArrow(inCC) ++ plain(" " ).l)
344
- given Option [List [TypeRepr ]] = None
344
+ val refs = if ! inCC.isDefined && t.isContextFunctionType then
345
+ // This'll ensure that an impure context function type is rendered correctly
346
+ Some (List (CaptureDefs .captureRoot.termRef))
347
+ else
348
+ inCC
349
+ val arrow = plain(" " ) :: (renderCaptureArrow(using qctx)(refs, t.isContextFunctionType) ++ plain(" " ).l)
350
+ given Option [List [TypeRepr ]] = None // FIXME: this is ugly
345
351
args match
346
352
case Nil => Nil
347
353
case List (rtpe) => plain(" ()" ).l ++ arrow ++ inner(rtpe)
@@ -479,15 +485,17 @@ trait TypesSupport:
479
485
import reflect ._
480
486
Keyword (" ^" ) :: renderCaptureSet(refs)
481
487
482
- private def renderCaptureArrow (using Quotes )(refs : List [reflect.TypeRepr ])(using elideThis : reflect.ClassDef ): SSignature =
488
+ private def renderCaptureArrow (using Quotes )(refs : List [reflect.TypeRepr ], isImplicitFun : Boolean )(using elideThis : reflect.ClassDef ): SSignature =
483
489
import reflect ._
490
+ val prefix = if isImplicitFun then " ?" else " "
484
491
refs match
485
- case Nil => List (Keyword (" ->" ))
486
- case List (ref) if ref.isCaptureRoot => List (Keyword (" =>" ))
487
- case refs => Keyword (" ->" ) :: renderCaptureSet(refs)
492
+ case Nil => List (Keyword (prefix + " ->" )) // FIXME need to check if cc is enabled in current file first!!!
493
+ case List (ref) if ref.isCaptureRoot => List (Keyword (prefix + " =>" ))
494
+ case refs => Keyword (prefix + " ->" ) :: renderCaptureSet(refs)
488
495
489
- private def renderCaptureArrow (using Quotes )(refs : Option [List [reflect.TypeRepr ]])(using elideThis : reflect.ClassDef ): SSignature =
496
+ private def renderCaptureArrow (using qctx : Quotes )(refs : Option [List [reflect.TypeRepr ]], isImplicitFun : Boolean )(using elideThis : reflect.ClassDef ): SSignature =
490
497
import reflect ._
498
+ val prefix = if isImplicitFun then " ?" else " "
491
499
refs match
492
- case None => List (Keyword (" = >" )) // FIXME: is this correct? or should it be `->` by default?
493
- case Some (refs) => renderCaptureArrow(refs)
500
+ case None => List (Keyword (prefix + " - >" )) // FIXME need to check if cc is enabled in current file first!!!
501
+ case Some (refs) => renderCaptureArrow(using qctx)( refs, isImplicitFun )
0 commit comments