Skip to content

Commit b431a4b

Browse files
author
Vlad Ureche
committed
Merge pull request scala#4105 from gourlaysama/wip/t5730-scaladoc-sealed-ctor
SI-5730 hide constructors of sealed abstract classes in scaladoc
2 parents f7c3c6b + 6b9f543 commit b431a4b

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -753,8 +753,10 @@ class ModelFactory(val global: Global, val settings: doc.Settings) {
753753
})
754754
}
755755
else if (bSym.isConstructor)
756-
if (conversion.isDefined)
757-
None // don't list constructors inherted by implicit conversion
756+
if (conversion.isDefined || (bSym.enclClass.isAbstract && (bSym.enclClass.isSealed || bSym.enclClass.isFinal)))
757+
// don't list constructors inherited by implicit conversion
758+
// and don't list constructors of abstract sealed types (they cannot be accessed anyway)
759+
None
758760
else
759761
Some(new NonTemplateParamMemberImpl(bSym, conversion, useCaseOf, inTpl) with Constructor {
760762
override def isConstructor = true

test/scaladoc/run/t5730.check

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Done.

test/scaladoc/run/t5730.scala

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import scala.tools.nsc.doc.base._
2+
import scala.tools.nsc.doc.model._
3+
import scala.tools.partest.ScaladocModelTest
4+
5+
object Test extends ScaladocModelTest {
6+
7+
override def code = """
8+
package scala.test.scaladoc.T5730
9+
10+
/**
11+
* A link:
12+
*
13+
* [[scala.Option$ object Option]].
14+
*/
15+
sealed abstract class A
16+
17+
case object B extends A
18+
19+
abstract final class C
20+
"""
21+
22+
def scaladocSettings = ""
23+
24+
def testModel(rootPackage: Package) = {
25+
// get the quick access implicit defs in scope (_package(s), _class(es), _trait(s), object(s) _method(s), _value(s))
26+
import access._
27+
28+
val p = rootPackage._package("scala")._package("test")._package("scaladoc")._package("T5730")
29+
30+
val a = p._class("A")
31+
val c = p._class("C")
32+
33+
assert(a.constructors.isEmpty, s"there should be no constructors, found: ${a.constructors}")
34+
assert(c.constructors.isEmpty, s"there should be no constructors, found: ${c.constructors}")
35+
}
36+
}

0 commit comments

Comments
 (0)