Skip to content

Commit 83ddc76

Browse files
Backport "scaladoc: indicate optional parameters with = ..." to 3.7.4 (#24029)
Backports #23676 to the 3.7.4. PR submitted by the release tooling. [skip ci]
2 parents 985aaa1 + cd442ca commit 83ddc76

File tree

4 files changed

+30
-4
lines changed

4 files changed

+30
-4
lines changed

scaladoc-testcases/src/tests/extendsCall.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ package extendsCall
33

44
class Impl() extends Base(Seq.empty, c = "-") //expected: class Impl() extends Base
55

6-
class Base(val a: Seq[String], val b: String = "", val c: String = "") //expected: class Base(val a: Seq[String], val b: String, val c: String)
6+
class Base(val a: Seq[String], val b: String = "", val c: String = "") //expected: class Base(val a: Seq[String], val b: String = ..., val c: String = ...)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package tests
2+
package optionalParams
3+
4+
class C(val a: Seq[String], val b: String = "", var c: String = "") //expected: class C(val a: Seq[String], val b: String = ..., var c: String = ...)
5+
{
6+
def m(x: Int, s: String = "a"): Nothing //expected: def m(x: Int, s: String = ...): Nothing
7+
= ???
8+
}
9+
10+
def f(x: Int, s: String = "a"): Nothing //expected: def f(x: Int, s: String = ...): Nothing
11+
= ???
12+
13+
extension (y: Int)
14+
def ext(x: Int = 0): Int //expected: def ext(x: Int = ...): Int
15+
= 0
16+
17+
def byname(s: => String = "a"): Int //expected: def byname(s: => String = ...): Int
18+
= 0
19+
20+
enum E(val x: Int = 0) //expected: enum E(val x: Int = ...)
21+
{
22+
case E1(y: Int = 10) extends E(y) //expected: final case class E1(y: Int = ...) extends E
23+
}

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -454,14 +454,15 @@ trait ClassLikeSupport:
454454
val inlinePrefix = if symbol.flags.is(Flags.Inline) then "inline " else ""
455455
val name = symbol.normalizedName
456456
val nameIfNotSynthetic = Option.when(!symbol.flags.is(Flags.Synthetic))(name)
457+
val defaultValue = Option.when(symbol.flags.is(Flags.HasDefault))(Plain(" = ..."))
457458
api.TermParameter(
458459
symbol.getAnnotations(),
459460
inlinePrefix + prefix(symbol),
460461
nameIfNotSynthetic,
461462
symbol.dri,
462-
argument.tpt.asSignature(classDef, symbol.owner),
463-
isExtendedSymbol,
464-
isGrouped
463+
argument.tpt.asSignature(classDef, symbol.owner) :++ defaultValue,
464+
isExtendedSymbol = isExtendedSymbol,
465+
isGrouped = isGrouped
465466
)
466467

467468
def mkTypeArgument(

scaladoc/test/dotty/tools/scaladoc/signatures/TranslatableSignaturesTestCases.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,5 @@ class RightAssocExtension extends SignatureTest("rightAssocExtension", Signature
130130
class NamedTuples extends SignatureTest("namedTuples", SignatureTest.all)
131131

132132
class InnerClasses extends SignatureTest("innerClasses", SignatureTest.all)
133+
134+
class OptionalParams extends SignatureTest("optionalParams", SignatureTest.all)

0 commit comments

Comments
 (0)