From f46ae47fb93867e8d11c80498b5dd2b6c2274b23 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Thu, 13 Mar 2014 12:09:23 +0100 Subject: SI-8407 "symbol not found" in Scaladoc use cases: warning only The refactoring in aedec1980 mistakenly used the non-silent typer to typecheck the use cases. It temptingly had the desired type (`ScalaDocAnalyzer`), but sadly the wrong properties (it will report errors, rather than buffer.) This meant that "symbol not found" errors in use cases would prevent Scaladoc generation. This commit introduces a little downcast on the silent typer. A more principled approach would be to go through the rigmarole of the virtual class pattern for `Analzyer.Typer`, but that will have to remain work for another day. --- .../scala/tools/nsc/doc/ScaladocAnalyzer.scala | 2 +- test/scaladoc/run/t8407.check | 4 ++++ test/scaladoc/run/t8407.scala | 20 ++++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 test/scaladoc/run/t8407.check create mode 100644 test/scaladoc/run/t8407.scala diff --git a/src/scaladoc/scala/tools/nsc/doc/ScaladocAnalyzer.scala b/src/scaladoc/scala/tools/nsc/doc/ScaladocAnalyzer.scala index 212f94c531..e5c64c6f45 100644 --- a/src/scaladoc/scala/tools/nsc/doc/ScaladocAnalyzer.scala +++ b/src/scaladoc/scala/tools/nsc/doc/ScaladocAnalyzer.scala @@ -37,7 +37,7 @@ trait ScaladocAnalyzer extends Analyzer { comment.defineVariables(sym) val typer1 = newTyper(context.makeNewScope(docDef, context.owner)) for (useCase <- comment.useCases) { - typer1.silent(_ => typer1 defineUseCases useCase) match { + typer1.silent(_.asInstanceOf[ScaladocTyper].defineUseCases(useCase)) match { case SilentTypeError(err) => unit.warning(useCase.pos, err.errMsg) case _ => diff --git a/test/scaladoc/run/t8407.check b/test/scaladoc/run/t8407.check new file mode 100644 index 0000000000..06c860b3eb --- /dev/null +++ b/test/scaladoc/run/t8407.check @@ -0,0 +1,4 @@ +newSource:4: warning: not found: type $NotFound + * @usecase def zipWithIndex: $NotFound + ^ +Done. diff --git a/test/scaladoc/run/t8407.scala b/test/scaladoc/run/t8407.scala new file mode 100644 index 0000000000..2df9f4f1ac --- /dev/null +++ b/test/scaladoc/run/t8407.scala @@ -0,0 +1,20 @@ +import scala.tools.nsc.doc.model._ +import scala.tools.partest.ScaladocModelTest + +object Test extends ScaladocModelTest { + override def code = """ +class C { + /** + * @usecase def zipWithIndex: $NotFound + * + */ + def zipWithIndex: Int = ??? +} + """ + + def scaladocSettings = "" + + def testModel(root: Package) = { + // just testing that it doesn't error out. + } +} -- cgit v1.2.3