Skip to content

Commit

Permalink
Merge pull request #9114 from forketyfork/bug/11101
Browse files Browse the repository at this point in the history
Fixed scaladoc error on processing of incorrect comment placeholder
  • Loading branch information
lrytz committed Jul 13, 2020
2 parents a9328bf + 824c6b2 commit 29c8bfc
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/compiler/scala/tools/nsc/ast/DocComments.scala
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ trait DocComments { self: Global =>
* since r23926.
*/
private def allInheritedOverriddenSymbols(sym: Symbol): List[Symbol] = {
if (!sym.owner.isClass) Nil
else sym.owner.ancestors map (sym overriddenSymbol _) filter (_ != NoSymbol)
val getter: Symbol = sym.getter
val symOrGetter = getter.orElse(sym)
if (!symOrGetter.owner.isClass) Nil
else symOrGetter.owner.ancestors map (symOrGetter overriddenSymbol _) filter (_ != NoSymbol)
}

def fillDocComment(sym: Symbol, comment: DocComment): Unit = {
Expand Down Expand Up @@ -143,8 +145,7 @@ trait DocComments { self: Global =>

/** The cooked doc comment of an overridden symbol */
protected def superComment(sym: Symbol): Option[String] = {
val getter: Symbol = sym.getter
allInheritedOverriddenSymbols(getter.orElse(sym)).iterator
allInheritedOverriddenSymbols(sym).iterator
.map(cookedDocComment(_))
.find(_ != "")
}
Expand Down
14 changes: 14 additions & 0 deletions test/scaladoc/resources/stray-dollar-sign-res.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package scaladoc.resources

trait T {

/** $a */
def foo: Int

}

object O extends T {

val foo = 42

}
4 changes: 4 additions & 0 deletions test/scaladoc/run/stray-dollar-sign.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
newSource:5: warning: Variable a undefined in comment for value foo in object O
/** $a */
^
Done.
17 changes: 17 additions & 0 deletions test/scaladoc/run/stray-dollar-sign.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import scala.tools.nsc.doc.model._
import scala.tools.partest.ScaladocModelTest

object Test extends ScaladocModelTest {

override def resourceFile = "stray-dollar-sign-res.scala"

def scaladocSettings = ""

def testModel(rootPackage: Package) = {
// get the quick access implicit defs in scope (_package(s), _class(es), _trait(s), object(s) _method(s), _value(s))
import access._

val comment = rootPackage._package("scaladoc")._package("resources")._object("O")._value("foo").comment
assert(extractCommentText(comment.get) == "$a")
}
}

0 comments on commit 29c8bfc

Please sign in to comment.