Skip to content

Commit 227cd6e

Browse files
committed
Add necessary parentheses in function types
1 parent 5ed7960 commit 227cd6e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

scaladoc/src/dotty/tools/scaladoc/tasty/TypesSupport.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,11 @@ trait TypesSupport:
199199
case Seq(rtpe) =>
200200
plain("()").l ++ keyword(arrow).l ++ inner(rtpe)
201201
case Seq(arg, rtpe) =>
202+
def withParentheses(tpe: TypeRepr) = plain("(").l ++ inner(tpe) ++ plain(")").l
202203
val partOfSignature = arg match
203-
case byName: ByNameType => plain("(").l ++ inner(byName) ++ plain(")").l
204-
case _ => inner(arg)
204+
case tpe @ (_:TermRef | _:TypeRef | _:ConstantType | _: ParamRef) => inner(arg)
205+
case tpe: AppliedType if !tpe.isFunctionType && !tpe.isTupleN => inner(arg)
206+
case _ => withParentheses(arg)
205207
partOfSignature ++ keyword(arrow).l ++ inner(rtpe)
206208
case args =>
207209
plain("(").l ++ commas(args.init.map(inner)) ++ plain(")").l ++ keyword(arrow).l ++ inner(args.last)

0 commit comments

Comments
 (0)