Skip to content

Commit c82af99

Browse files
committed
Add tests for extensions's signatures
1 parent 29e229b commit c82af99

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

project/Build.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ object Build {
361361
// Settings used when compiling dotty with a non-bootstrapped dotty
362362
lazy val commonBootstrappedSettings = commonDottySettings ++ NoBloopExport.settings ++ Seq(
363363
// To enable support of scaladoc and language-server projects you need to change this to true and use sbt as your build server
364-
bspEnabled := false,
364+
// bspEnabled := false,
365365
(Compile / unmanagedSourceDirectories) += baseDirectory.value / "src-bootstrapped",
366366

367367
version := dottyVersion,

scaladoc-testcases/src/tests/extensionParams.scala

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,25 @@ extension (using String)(using Unit)(a: Animal)(using Int)(using Number)
5353
def f11(b: Any)(c: Any): Any
5454
= ???
5555

56+
extension (a: Int)
57+
def f13(): Any
58+
= ???
59+
60+
extension (using Unit)(a: Int)
61+
def f14(): Any
62+
= ???
63+
64+
extension (a: Int)(using Unit)
65+
def f15(): Any
66+
= ???
67+
5668
import scala.language.experimental.clauseInterleaving
5769

5870
extension (using String)(using Unit)(a: Animal)(using Int)(using Number)
59-
def f13(b: Any)[T](c: T): T
71+
def f16(b: Any)[T](c: T): T
6072
= ???
61-
def f14[D](b: D)[T](c: T): T
73+
def f17[D](b: D)[T](c: T): T
6274
= ???
6375

76+
77+

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,17 @@ abstract class SignatureTest(
8383
private def compactWhitespaces = whitespaceRegex.replaceAllIn(s, " ")
8484

8585
private def findName(signature: String, kinds: Seq[String]): Option[String] =
86+
var counter = 1
8687
for
87-
kindMatch <- kinds.flatMap(k => s"\\b$k\\b".r.findFirstMatchIn(signature)).headOption
88+
kindMatch <- kinds.flatMap(k =>s"\\b$k\\b".r.findFirstMatchIn(signature)).headOption
8889
afterKind <- Option(kindMatch.after(0)) // to filter out nulls
89-
nameMatch <- identifierRegex.findFirstMatchIn(afterKind)
90+
nameMatch <- identifierRegex.findFirstMatchIn(
91+
if kindMatch.group(0).contains("extension")
92+
then
93+
signature
94+
else
95+
afterKind
96+
)
9097
yield nameMatch.group(1)
9198

9299
private def signaturesFromSources(source: Source, kinds: Seq[String]): Seq[SignatureRes] =
@@ -129,6 +136,6 @@ abstract class SignatureTest(
129136

130137
object SignatureTest {
131138
val classlikeKinds = Seq("class", "object", "trait", "enum") // TODO add docs for packages
132-
val members = Seq("type", "def", "val", "var", "given")
139+
val members = Seq("type", "def", "val", "var", "given", "extension")
133140
val all = classlikeKinds ++ members
134141
}

0 commit comments

Comments
 (0)