diff --git a/scaladoc-testcases/src/tests/emptyparens.scala b/scaladoc-testcases/src/tests/emptyparens.scala new file mode 100644 index 000000000000..1d2c3d0843fa --- /dev/null +++ b/scaladoc-testcases/src/tests/emptyparens.scala @@ -0,0 +1,27 @@ +package tests.emptyparens + +class C { + def f1()(implicit i: Int) = i + + def f2()(using i: Int) = i + + def f3(s: String)(implicit i: Int) = i + + def f4(s: String)(using i: Int) = i + + def f5()()(using i: Int) = i + + def f6() = 1 + + def f7()() = 2 + + def f8(i: Int)() = 1 +} + +class C1()(implicit i: Int) + +class C2()(using i: Int) + +class C3()() + +class C4()(i: Int) \ No newline at end of file diff --git a/scaladoc/src/dotty/tools/scaladoc/translators/ScalaSignatureUtils.scala b/scaladoc/src/dotty/tools/scaladoc/translators/ScalaSignatureUtils.scala index 3817c70eef5a..2973cd537354 100644 --- a/scaladoc/src/dotty/tools/scaladoc/translators/ScalaSignatureUtils.scala +++ b/scaladoc/src/dotty/tools/scaladoc/translators/ScalaSignatureUtils.scala @@ -28,10 +28,11 @@ trait SignatureBuilder extends ScalaSignatureUtils { prefix: String = "", suffix: String = "", separator: String = ", ", + forcePrefixAndSuffix: Boolean = false )( elemOp: (SignatureBuilder, E) => SignatureBuilder ): SignatureBuilder = elements match { - case Nil => this + case Nil => if forcePrefixAndSuffix then this.text(prefix + suffix) else this case head :: tail => tail.foldLeft(elemOp(text(prefix), head))((b, e) => elemOp(b.text(separator), e)).text(suffix) } @@ -85,7 +86,7 @@ trait SignatureBuilder extends ScalaSignatureUtils { if params.isEmpty then this.text("") else if params.size == 1 && params(0).parameters == Nil then this.text("()") else this.list(params, separator = ""){ (bld, pList) => - bld.list(pList.parameters, s"(${pList.modifiers}", ")"){ (bld, p) => + bld.list(pList.parameters, s"(${pList.modifiers}", ")", forcePrefixAndSuffix = true){ (bld, p) => val annotationsAndModifiers = bld.annotationsInline(p) .text(p.modifiers) val name = p.name.fold(annotationsAndModifiers)(annotationsAndModifiers.memberName(_, p.dri).text(": "))