@@ -122,8 +122,10 @@ trait TypesSupport:
122
122
++ keyword(" & " ).l
123
123
++ inParens(inner(right, skipThisTypePrefix), shouldWrapInParens(right, tp, false ))
124
124
case ByNameType (CapturingType (tpe, refs)) =>
125
- renderCaptureArrow(using q)(Some (refs), skipThisTypePrefix)(using elideThis, originalOwner) ++ (plain(" " ) :: inner(tpe, skipThisTypePrefix))
126
- case ByNameType (tpe) => keyword(" =>!! " ) :: inner(tpe, skipThisTypePrefix) // FIXME: does it need change for CC?
125
+ renderCaptureArrow(using q)(refs, false , skipThisTypePrefix) ++ (plain(" " ) :: inner(tpe, skipThisTypePrefix))
126
+ case ByNameType (tpe) =>
127
+ tpe.typeSymbol.pos.map(p => report.warning(s " Pure ByNameType at ${p}" ))
128
+ keyword(" -> " ) :: inner(tpe, skipThisTypePrefix) // FIXME need to check if cc is enabled in current file first!!!
127
129
case ConstantType (constant) =>
128
130
plain(constant.show).l
129
131
case ThisType (tpe) =>
@@ -349,9 +351,13 @@ trait TypesSupport:
349
351
inCC : Option [List [reflect.TypeRepr ]],
350
352
): SSignature =
351
353
import reflect ._
352
- val arrow = if t.isContextFunctionType then keyword(" ?=> " ).l // FIXME: can we have contextual functions with capture sets?
353
- else plain(" " ) :: (renderCaptureArrow(using q)(inCC, skipThisTypePrefix) ++ plain(" " ).l)
354
- given Option [List [TypeRepr ]] = None
354
+ val refs = if ! inCC.isDefined && t.isContextFunctionType then
355
+ // This'll ensure that an impure context function type is rendered correctly
356
+ Some (List (CaptureDefs .captureRoot.termRef))
357
+ else
358
+ inCC
359
+ val arrow = plain(" " ) :: (renderCaptureArrow(using q)(refs, t.isContextFunctionType, skipThisTypePrefix) ++ plain(" " ).l)
360
+ given Option [List [TypeRepr ]] = None // FIXME: this is ugly
355
361
args match
356
362
case Nil => Nil
357
363
case List (rtpe) => plain(" ()" ).l ++ arrow ++ inner(rtpe, skipThisTypePrefix)
@@ -499,19 +505,21 @@ trait TypesSupport:
499
505
import reflect ._
500
506
Keyword (" ^" ) :: renderCaptureSet(refs, skipThisTypePrefix)
501
507
502
- private def renderCaptureArrow (using q : Quotes )(refs : List [reflect.TypeRepr ], skipThisTypePrefix : Boolean )(
508
+ private def renderCaptureArrow (using q : Quotes )(refs : List [reflect.TypeRepr ], isImplicitFun : Boolean , skipThisTypePrefix : Boolean )(
503
509
using elideThis : reflect.ClassDef , originalOwner : reflect.Symbol
504
510
): SSignature =
505
- import reflect .*
511
+ import reflect ._
512
+ val prefix = if isImplicitFun then " ?" else " "
506
513
refs match
507
- case Nil => List (Keyword (" ->" ))
508
- case List (ref) if ref.isCaptureRoot => List (Keyword (" =>" ))
509
- case refs => Keyword (" ->" ) :: renderCaptureSet(using q)(refs, skipThisTypePrefix)
514
+ case Nil => List (Keyword (prefix + " ->" )) // FIXME need to check if cc is enabled in current file first!!!
515
+ case List (ref) if ref.isCaptureRoot => List (Keyword (prefix + " =>" ))
516
+ case refs => Keyword (prefix + " ->" ) :: renderCaptureSet(using q)(refs, skipThisTypePrefix)
510
517
511
- private def renderCaptureArrow (using q : Quotes )(refs : Option [List [reflect.TypeRepr ]], skipThisTypePrefix : Boolean )(
518
+ private def renderCaptureArrow (using q : Quotes )(refs : Option [List [reflect.TypeRepr ]], isImplicitFun : Boolean , skipThisTypePrefix : Boolean )(
512
519
using elideThis : reflect.ClassDef , originalOwner : reflect.Symbol
513
520
): SSignature =
514
- import reflect .*
521
+ import reflect ._
522
+ val prefix = if isImplicitFun then " ?" else " "
515
523
refs match
516
- case None => List (Keyword (" = >" )) // FIXME: is this correct? or should it be `->` by default?
517
- case Some (refs) => renderCaptureArrow(using q)(refs, skipThisTypePrefix)
524
+ case None => List (Keyword (prefix + " - >" )) // FIXME need to check if cc is enabled in current file first!!!
525
+ case Some (refs) => renderCaptureArrow(using q)(refs, isImplicitFun, skipThisTypePrefix)
0 commit comments