@@ -11,6 +11,8 @@ import dotty.tools.scaladoc.cc.*
1111import NameNormalizer ._
1212import SyntheticsSupport ._
1313
14+ private case class FunKind (isPure : Boolean , isImplicit : Boolean )
15+
1416trait TypesSupport :
1517 self : TastyParser =>
1618
@@ -122,10 +124,9 @@ trait TypesSupport:
122124 ++ keyword(" & " ).l
123125 ++ inParens(inner(right, skipThisTypePrefix), shouldWrapInParens(right, tp, false ))
124126 case ByNameType (CapturingType (tpe, refs)) =>
125- renderCaptureArrow (using q)(refs, false , skipThisTypePrefix) ++ (plain(" " ) :: inner(tpe, skipThisTypePrefix))
127+ renderFunctionArrow (using q)(refs, FunKind ( true , false ) , skipThisTypePrefix) ++ (plain(" " ) :: inner(tpe, skipThisTypePrefix))
126128 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!!!
129+ (if ccEnabled then keyword(" -> " ) else keyword(" => " )):: inner(tpe, skipThisTypePrefix)
129130 case ConstantType (constant) =>
130131 plain(constant.show).l
131132 case ThisType (tpe) =>
@@ -256,7 +257,8 @@ trait TypesSupport:
256257 ++ plain(" " ).l
257258 ++ inParens(inner(rhs, skipThisTypePrefix), shouldWrapInParens(rhs, t, false ))
258259
259- case t @ AppliedType (tpe, args) if t.isFunctionType => functionType(t, tpe, args, skipThisTypePrefix)
260+ case t @ AppliedType (tpe, args) if t.isFunctionType =>
261+ functionType(t, tpe, args, skipThisTypePrefix)
260262
261263 case t @ AppliedType (tpe, typeList) =>
262264 inner(tpe, skipThisTypePrefix) ++ plain(" [" ).l ++ commas(typeList.map { t => t match
@@ -356,7 +358,7 @@ trait TypesSupport:
356358 Some (List (CaptureDefs .captureRoot.termRef))
357359 else
358360 inCC
359- val arrow = plain(" " ) :: (renderCaptureArrow (using q)(refs, t. isContextFunctionType, skipThisTypePrefix) ++ plain(" " ).l)
361+ val arrow = plain(" " ) :: (renderFunctionArrow (using q)(refs, FunKind (isPure = t.isFunction1, isImplicit = t. isContextFunctionType) , skipThisTypePrefix) ++ plain(" " ).l)
360362 given Option [List [TypeRepr ]] = None // FIXME: this is ugly
361363 args match
362364 case Nil => Nil
@@ -505,21 +507,27 @@ trait TypesSupport:
505507 import reflect ._
506508 Keyword (" ^" ) :: renderCaptureSet(refs, skipThisTypePrefix)
507509
508- private def renderCaptureArrow (using q : Quotes )(refs : List [reflect.TypeRepr ], isImplicitFun : Boolean , skipThisTypePrefix : Boolean )(
510+ private def renderFunctionArrow (using q : Quotes )(refs : List [reflect.TypeRepr ], fun : FunKind , skipThisTypePrefix : Boolean )(
509511 using elideThis : reflect.ClassDef , originalOwner : reflect.Symbol
510512 ): SSignature =
511513 import reflect ._
512- val prefix = if isImplicitFun then " ?" else " "
513- refs match
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)
514+ val prefix = if fun.isImplicit then " ?" else " "
515+ if ! ccEnabled then
516+ List (Keyword (prefix + " =>" ))
517+ else
518+ refs match
519+ case Nil => if fun.isPure then List (Keyword (prefix + " ->" )) else List (Keyword (prefix + " =>" ))
520+ case List (ref) if ref.isCaptureRoot => List (Keyword (prefix + " =>" ))
521+ case refs => Keyword (prefix + " ->" ) :: renderCaptureSet(using q)(refs, skipThisTypePrefix)
517522
518- private def renderCaptureArrow (using q : Quotes )(refs : Option [List [reflect.TypeRepr ]], isImplicitFun : Boolean , skipThisTypePrefix : Boolean )(
523+ private def renderFunctionArrow (using q : Quotes )(refs : Option [List [reflect.TypeRepr ]], fun : FunKind , skipThisTypePrefix : Boolean )(
519524 using elideThis : reflect.ClassDef , originalOwner : reflect.Symbol
520525 ): SSignature =
521526 import reflect ._
522- val prefix = if isImplicitFun then " ?" else " "
523- refs match
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)
527+ val prefix = if fun.isImplicit then " ?" else " "
528+ if ! ccEnabled then
529+ List (Keyword (prefix + " =>" ))
530+ else
531+ refs match
532+ case None => if fun.isPure then List (Keyword (prefix + " ->" )) else List (Keyword (prefix + " =>" ))
533+ case Some (refs) => renderFunctionArrow(using q)(refs, fun, skipThisTypePrefix)
0 commit comments