Skip to content

Commit 461b30f

Browse files
Merge pull request #13192 from KacperFKorban/scaladoc/fix-13148
Empty argument list is not shown in scaladoc in some cases
2 parents cb2df55 + 0b349b4 commit 461b30f

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package tests.emptyparens
2+
3+
class C {
4+
def f1()(implicit i: Int) = i
5+
6+
def f2()(using i: Int) = i
7+
8+
def f3(s: String)(implicit i: Int) = i
9+
10+
def f4(s: String)(using i: Int) = i
11+
12+
def f5()()(using i: Int) = i
13+
14+
def f6() = 1
15+
16+
def f7()() = 2
17+
18+
def f8(i: Int)() = 1
19+
}
20+
21+
class C1()(implicit i: Int)
22+
23+
class C2()(using i: Int)
24+
25+
class C3()()
26+
27+
class C4()(i: Int)

scaladoc/src/dotty/tools/scaladoc/translators/ScalaSignatureUtils.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ trait SignatureBuilder extends ScalaSignatureUtils {
2828
prefix: String = "",
2929
suffix: String = "",
3030
separator: String = ", ",
31+
forcePrefixAndSuffix: Boolean = false
3132
)(
3233
elemOp: (SignatureBuilder, E) => SignatureBuilder
3334
): SignatureBuilder = elements match {
34-
case Nil => this
35+
case Nil => if forcePrefixAndSuffix then this.text(prefix + suffix) else this
3536
case head :: tail =>
3637
tail.foldLeft(elemOp(text(prefix), head))((b, e) => elemOp(b.text(separator), e)).text(suffix)
3738
}
@@ -85,7 +86,7 @@ trait SignatureBuilder extends ScalaSignatureUtils {
8586
if params.isEmpty then this.text("")
8687
else if params.size == 1 && params(0).parameters == Nil then this.text("()")
8788
else this.list(params, separator = ""){ (bld, pList) =>
88-
bld.list(pList.parameters, s"(${pList.modifiers}", ")"){ (bld, p) =>
89+
bld.list(pList.parameters, s"(${pList.modifiers}", ")", forcePrefixAndSuffix = true){ (bld, p) =>
8990
val annotationsAndModifiers = bld.annotationsInline(p)
9091
.text(p.modifiers)
9192
val name = p.name.fold(annotationsAndModifiers)(annotationsAndModifiers.memberName(_, p.dri).text(": "))

0 commit comments

Comments
 (0)