Skip to content

Commit

Permalink
Merge pull request #13192 from KacperFKorban/scaladoc/fix-13148
Browse files Browse the repository at this point in the history
Empty argument list is not shown in scaladoc in some cases
  • Loading branch information
KacperFKorban authored Jul 30, 2021
2 parents cb2df55 + 0b349b4 commit 461b30f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
27 changes: 27 additions & 0 deletions scaladoc-testcases/src/tests/emptyparens.scala
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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(": "))
Expand Down

0 comments on commit 461b30f

Please sign in to comment.