summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Zeiger <szeiger@novocode.com>2016-08-12 13:37:34 +0200
committerGitHub <noreply@github.com>2016-08-12 13:37:34 +0200
commit7ff88c0bcba04cf8edbe98d488d14028e6ac399f (patch)
treebda800be3690f55a54eb0c72792a9d2cd898810a
parent1950412f6d4118433408444ace371eb020342711 (diff)
parent1149453c9a762b0a5792d6139ec2c201e418c914 (diff)
downloadscala-7ff88c0bcba04cf8edbe98d488d14028e6ac399f.tar.gz
scala-7ff88c0bcba04cf8edbe98d488d14028e6ac399f.tar.bz2
scala-7ff88c0bcba04cf8edbe98d488d14028e6ac399f.zip
Merge pull request #5231 from gourlaysama/ticket/t9585-scaladoc-wrong-implicits
SI-9585 hide auto-implicit conversions from scaladoc
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala14
-rw-r--r--test/scaladoc/run/t9585.check6
-rw-r--r--test/scaladoc/run/t9585.scala25
3 files changed, 45 insertions, 0 deletions
diff --git a/src/scaladoc/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala b/src/scaladoc/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala
index e67a717257..cedbdd1547 100644
--- a/src/scaladoc/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala
+++ b/src/scaladoc/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala
@@ -171,6 +171,20 @@ trait ModelFactoryImplicitSupport {
return Nil
}
+ if (!settings.docImplicitsShowAll && viewSimplifiedType.resultType.typeSymbol == sym) {
+ // If, when looking at views for a class A, we find one that returns A as well
+ // (possibly with different type parameters), we ignore it.
+ // It usually is a way to build a "whatever" into an A, but we already have an A, as in:
+ // {{{
+ // object Box {
+ // implicit def anyToBox[T](t: T): Box[T] = new Box(t)
+ // }
+ // class Box[T](val t: T)
+ // }}}
+ // We don't want the implicit conversion from Box[T] to Box[Box[T]] to appear.
+ return Nil
+ }
+
// type the view application so we get the exact type of the result (not the formal type)
val viewTree = result.tree.setType(viewSimplifiedType)
val appliedTree = new ApplyImplicitView(viewTree, List(Ident("<argument>") setType viewTree.tpe.paramTypes.head))
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"))
+ }
+}