File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
src/dotty/tools/dotc/typer Expand file tree Collapse file tree 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 =>
593593 def setDocstring (sym : Symbol , tree : Tree )(using Context ): Unit = tree match {
594594 case t : MemberDef if t.rawComment.isDefined =>
595595 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)
596599 case _ => ()
597600 }
598601
Original file line number Diff line number Diff line change @@ -31,6 +31,23 @@ class DocTests extends ReplTest {
3131 assertEquals(" doc" , doc(" new Foo" ))
3232 }
3333
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+
3451 @ Test def docOfDefInObject =
3552 eval(" object O { /** doc */ def foo = 0 }" ).andThen { implicit s =>
3653 assertEquals(" doc" , doc(" O.foo" ))
You can’t perform that action at this time.
0 commit comments