Skip to content

Commit

Permalink
SI-8210 Scaladoc: Fix the false negative @inheritdoc warning on acces…
Browse files Browse the repository at this point in the history
…sors

This fix is just for the false negative warning. Probably we can skip
setters entirely, but I'm not 100% sure.
  • Loading branch information
kzys committed May 28, 2015
1 parent 15ca0b3 commit 23a3ac4
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/compiler/scala/tools/nsc/ast/DocComments.scala
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ trait DocComments { self: Global =>

superComment(sym) match {
case None =>
if (ownComment.indexOf("@inheritdoc") != -1)
reporter.warning(sym.pos, "The comment for " + sym +
" contains @inheritdoc, but no parent comment is available to inherit from.")
// SI-8210 - The warning would be false negative when this symbol is a setter
if (ownComment.indexOf("@inheritdoc") != -1 && ! sym.isSetter)
reporter.warning(sym.pos, s"The comment for ${sym} contains @inheritdoc, but no parent comment is available to inherit from.")
ownComment.replaceAllLiterally("@inheritdoc", "<invalid inheritdoc annotation>")
case Some(sc) =>
if (ownComment == "") sc
Expand Down
1 change: 1 addition & 0 deletions test/scaladoc/run/SI-8210.check
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Done.
24 changes: 24 additions & 0 deletions test/scaladoc/run/SI-8210.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import scala.tools.nsc.doc.model._
import scala.tools.partest.ScaladocModelTest

object Test extends ScaladocModelTest {
override def code = """
object Foo {
trait Config {
/** The bar obviously. */
def bar: Int
}
class ConfigBuilder extends Config {
/** @inheritdoc
*
* The default value is 1234.
*/
var bar: Int = 1234
}
}
"""

def scaladocSettings = ""

def testModel(root: Package) = ()
}

0 comments on commit 23a3ac4

Please sign in to comment.