summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAntoine Gourlay <antoine@gourlay.fr>2016-04-29 19:33:47 +0200
committerAntoine Gourlay <antoine@gourlay.fr>2016-06-06 20:45:28 +0200
commit1149453c9a762b0a5792d6139ec2c201e418c914 (patch)
tree3bfc88cc3abdb45c06161b788d6f2471bba10e71 /test
parent28e0e18106a93fd8fd9a086c29836631c754ba35 (diff)
downloadscala-1149453c9a762b0a5792d6139ec2c201e418c914.tar.gz
scala-1149453c9a762b0a5792d6139ec2c201e418c914.tar.bz2
scala-1149453c9a762b0a5792d6139ec2c201e418c914.zip
SI-9585 hide auto-implicit conversions from scaladoc
This hides implicits conversions (and potential members obtained through it) that converts a type into itself, because these conversions are usually non-sensical. They are not completely removed, just placed behind `-doc-implicits-show-all`, like other implicits deemed probably useless. --- Consider the scaladoc for the following class: ``` object Box { implicit def anyToBox[T](t: T): Box[T] = new Box(t) } class Box[T](val t: T) ``` When looking for implicits members to add to class `Box`, it finds the implicit conversion `anyToBox`, and applies it to itself to have an implicit conversion to Box[Box[T]], which brings a useless implicit member `t: Box[T]`. This commit makes scaladoc ignore any conversion from a type to itself (even if type parameters differ) by default. Using the (very useful) `tools/scaladoc-diff` script, I found that this change removes the following conversion from the library doc: ``` Ensuring[A] to Ensuring[Ensuring[A]] anytostringadd[A] to any2stringadd[anytostringadd[A]] ArrowAssoc[A] to ArrowAssoc[ArrowAssoc[A]] =:=[From,To] to =:=[From,To] SearchImpl[A,Repr] to SearchImpl[A,SearchImpl[A,Repr]] CollectionsHaveToParArray[C, T] to CollectionsHaveToParArray[CollectionsHaveToParArray[C, T], T] Ordered[A] to Ordered[Ordered[A]] StringFormat[A] to StringFormat[StringFormat[A]] ```
Diffstat (limited to 'test')
-rw-r--r--test/scaladoc/run/t9585.check6
-rw-r--r--test/scaladoc/run/t9585.scala25
2 files changed, 31 insertions, 0 deletions
diff --git a/test/scaladoc/run/t9585.check b/test/scaladoc/run/t9585.check
new file mode 100644
index 0000000000..3784317d54
--- /dev/null
+++ b/test/scaladoc/run/t9585.check
@@ -0,0 +1,6 @@
+warning: there was one feature warning; re-run with -feature for details
+any2stringadd[Box[T]]
+StringFormat[Box[T]]
+Ensuring[Box[T]]
+ArrowAssoc[Box[T]]
+Done.
diff --git a/test/scaladoc/run/t9585.scala b/test/scaladoc/run/t9585.scala
new file mode 100644
index 0000000000..af8350b6cf
--- /dev/null
+++ b/test/scaladoc/run/t9585.scala
@@ -0,0 +1,25 @@
+import scala.tools.nsc.doc.model._
+import scala.tools.partest.ScaladocModelTest
+
+object Test extends ScaladocModelTest {
+ override def code = """
+ object Box {
+
+ implicit def anyToBox[T](t: T): Box[T] = new Box(t)
+
+ }
+
+ class Box[T](val t: T)
+ """
+
+ def scaladocSettings = "-implicits"
+
+ def testModel(root: Package) = {
+ import access._
+
+ // this used to contain the conversion to Box[Box[T]],
+ // but not anymore.
+ val conversions = root._class("Box").conversions
+ println(conversions.map(_.targetType).mkString("\n"))
+ }
+}