Skip to content

Commit d627128

Browse files
authored
Merge pull request #13199 from pikinier20/scaladoc/inherit-doc-warning
Fix inherit doc warnings
2 parents 31d55e0 + a77f23e commit d627128

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package tests
2+
package inheritDoc
3+
4+
class Test {
5+
/** {@inheritDoc} */
6+
def f: Unit = { }
7+
}

scaladoc/src/dotty/tools/scaladoc/tasty/comments/CommentExpander.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class CommentExpander {
7979
case None =>
8080
// SI-8210 - The warning would be false negative when this symbol is a setter
8181
if (ownComment.indexOf("@inheritdoc") != -1 && ! sym.isSetter)
82-
println(s"${sym.span}: the comment for ${sym} contains @inheritdoc, but no parent comment is available to inherit from.")
82+
report.warning(s"The comment for ${sym} contains @inheritdoc, but no parent comment is available to inherit from.", sym.srcPos)
8383
ownComment.replace("@inheritdoc", "<invalid inheritdoc annotation>")
8484
case Some(sc) =>
8585
if (ownComment == "") sc
@@ -159,7 +159,7 @@ class CommentExpander {
159159
* @param sym The child symbol
160160
* @return The child comment with the inheritdoc sections expanded
161161
*/
162-
def expandInheritdoc(parent: String, child: String, sym: Symbol): String =
162+
def expandInheritdoc(parent: String, child: String, sym: Symbol)(using Context): String =
163163
if (child.indexOf("@inheritdoc") == -1)
164164
child
165165
else {
@@ -193,8 +193,8 @@ class CommentExpander {
193193
val sectionTextBounds = extractSectionText(parent, section)
194194
cleanupSectionText(parent.substring(sectionTextBounds._1, sectionTextBounds._2))
195195
case None =>
196-
println(s"""${sym.span}: the """" + getSectionHeader + "\" annotation of the " + sym +
197-
" comment contains @inheritdoc, but the corresponding section in the parent is not defined.")
196+
report.warning(s"""The """" + getSectionHeader + "\" annotation of the " + sym +
197+
" comment contains @inheritdoc, but the corresponding section in the parent is not defined.", sym.srcPos)
198198
"<invalid inheritdoc annotation>"
199199
}
200200

0 commit comments

Comments
 (0)