File tree 2 files changed +20
-0
lines changed
src/dotty/tools/dotc/typer
2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -593,6 +593,9 @@ class Namer { typer: Typer =>
593
593
def setDocstring (sym : Symbol , tree : Tree )(using Context ): Unit = tree match {
594
594
case t : MemberDef if t.rawComment.isDefined =>
595
595
ctx.docCtx.foreach(_.addDocstring(sym, t.rawComment))
596
+ case t : ExtMethods =>
597
+ for meth <- t.methods.find(_.span.point == sym.span.point) do
598
+ setDocstring(sym, meth)
596
599
case _ => ()
597
600
}
598
601
Original file line number Diff line number Diff line change @@ -31,6 +31,23 @@ class DocTests extends ReplTest {
31
31
assertEquals(" doc" , doc(" new Foo" ))
32
32
}
33
33
34
+ @ Test def docOfExtension1 =
35
+ eval(" /** doc */ extension (x: Int) def foo = 0" ).andThen { implicit s =>
36
+ assertEquals(" doc" , doc(" extension_foo" ))
37
+ }
38
+
39
+ @ Test def docOfExtension2 =
40
+ eval(" extension (x: Int) /** doc */ def foo = 0" ).andThen { implicit s =>
41
+ assertEquals(" doc" , doc(" extension_foo" ))
42
+ }
43
+
44
+ @ Test def docOfExtension3 =
45
+ eval(" /** doc0 */ extension (x: Int) { /** doc1 */ def foo = 0; /** doc2 */ def bar = 0; def baz = 0 }" ).andThen { implicit s =>
46
+ assertEquals(" doc1" , doc(" extension_foo" ))
47
+ assertEquals(" doc2" , doc(" extension_bar" ))
48
+ assertEquals(" doc0" , doc(" extension_baz" ))
49
+ }
50
+
34
51
@ Test def docOfDefInObject =
35
52
eval(" object O { /** doc */ def foo = 0 }" ).andThen { implicit s =>
36
53
assertEquals(" doc" , doc(" O.foo" ))
You can’t perform that action at this time.
0 commit comments