summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/doc/html/page/Template.scala8
-rw-r--r--test/scaladoc/resources/Trac4374.scala5
-rw-r--r--test/scaladoc/scala/html/HtmlFactoryTest.scala24
3 files changed, 35 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/doc/html/page/Template.scala b/src/compiler/scala/tools/nsc/doc/html/page/Template.scala
index 3be5c3ba9c..ac33e66a35 100644
--- a/src/compiler/scala/tools/nsc/doc/html/page/Template.scala
+++ b/src/compiler/scala/tools/nsc/doc/html/page/Template.scala
@@ -277,9 +277,13 @@ class Template(tpl: DocTemplateEntity) extends HtmlPage {
} ++
{ tpl.companion match {
case Some(companion) if (isSelf && !isReduced) =>
- <div class="block">
+ if (companion.visibility.isPublic) {
+ <div class="block">
go to: <a href={relativeLinkTo(companion)}>companion</a>
- </div>
+ </div>
+ } else {
+ NodeSeq.Empty
+ }
case _ =>
NodeSeq.Empty
}
diff --git a/test/scaladoc/resources/Trac4374.scala b/test/scaladoc/resources/Trac4374.scala
new file mode 100644
index 0000000000..4dd8ba2ae8
--- /dev/null
+++ b/test/scaladoc/resources/Trac4374.scala
@@ -0,0 +1,5 @@
+class WithPublic
+object WithPublic
+
+class WithPrivate
+private object WithPrivate
diff --git a/test/scaladoc/scala/html/HtmlFactoryTest.scala b/test/scaladoc/scala/html/HtmlFactoryTest.scala
index 853a7c0fd2..ab76cbc7fc 100644
--- a/test/scaladoc/scala/html/HtmlFactoryTest.scala
+++ b/test/scaladoc/scala/html/HtmlFactoryTest.scala
@@ -130,4 +130,28 @@ object Test extends Properties("HtmlFactory") {
case _ => false
}
}
+
+ property("Trac #4374 - public") = {
+ val files = createTemplates("Trac4374.scala")
+ files("WithPublic.html") match {
+ case node: scala.xml.Node => {
+ val s = node.toString
+ s.contains("""go to: <a href="WithPublic$.html">companion</a>""") &&
+ files.get("WithPublic$.html") != None
+ }
+ case _ => false
+ }
+ }
+
+ property("Trac #4374 - private") = {
+ val files = createTemplates("Trac4374.scala")
+ files("WithPrivate.html") match {
+ case node: scala.xml.Node => {
+ val s = node.toString
+ ! s.contains("""go to: <a href="WithPrivate$.html">companion</a>""") &&
+ files.get("WithPrivate$.html") == None
+ }
+ case _ => false
+ }
+ }
}