@@ -11,6 +11,8 @@ import dotty.tools.scaladoc.cc.*
11
11
import NameNormalizer ._
12
12
import SyntheticsSupport ._
13
13
14
+ private case class FunKind (isPure : Boolean , isImplicit : Boolean )
15
+
14
16
trait TypesSupport :
15
17
self : TastyParser =>
16
18
@@ -122,10 +124,9 @@ trait TypesSupport:
122
124
++ keyword(" & " ).l
123
125
++ inParens(inner(right, skipThisTypePrefix), shouldWrapInParens(right, tp, false ))
124
126
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))
126
128
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)
129
130
case ConstantType (constant) =>
130
131
plain(constant.show).l
131
132
case ThisType (tpe) =>
@@ -256,7 +257,8 @@ trait TypesSupport:
256
257
++ plain(" " ).l
257
258
++ inParens(inner(rhs, skipThisTypePrefix), shouldWrapInParens(rhs, t, false ))
258
259
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)
260
262
261
263
case t @ AppliedType (tpe, typeList) =>
262
264
inner(tpe, skipThisTypePrefix) ++ plain(" [" ).l ++ commas(typeList.map { t => t match
@@ -356,7 +358,7 @@ trait TypesSupport:
356
358
Some (List (CaptureDefs .captureRoot.termRef))
357
359
else
358
360
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)
360
362
given Option [List [TypeRepr ]] = None // FIXME: this is ugly
361
363
args match
362
364
case Nil => Nil
@@ -505,21 +507,27 @@ trait TypesSupport:
505
507
import reflect ._
506
508
Keyword (" ^" ) :: renderCaptureSet(refs, skipThisTypePrefix)
507
509
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 )(
509
511
using elideThis : reflect.ClassDef , originalOwner : reflect.Symbol
510
512
): SSignature =
511
513
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)
517
522
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 )(
519
524
using elideThis : reflect.ClassDef , originalOwner : reflect.Symbol
520
525
): SSignature =
521
526
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