From 48283ca80c17b2814a27464c30bca2445ffcc7a5 Mon Sep 17 00:00:00 2001 From: François Garillot Date: Thu, 5 Sep 2013 18:18:43 +0200 Subject: SI-7767 avoid rejecting Scaladoc comments in early initializers review by @retronym --- src/compiler/scala/tools/nsc/ast/parser/Parsers.scala | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index 5476afa75e..996287dea8 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -2772,6 +2772,8 @@ self => List(copyValDef(vdef)(mods = mods | Flags.PRESUPER)) case tdef @ TypeDef(mods, name, tparams, rhs) => List(treeCopy.TypeDef(tdef, mods | Flags.PRESUPER, name, tparams, rhs)) + case docdef @ DocDef(comm, rhs) => + List(treeCopy.DocDef(docdef, comm, rhs)) case stat if !stat.isEmpty => syntaxError(stat.pos, "only type definitions and concrete field definitions allowed in early object initialization section", false) List() -- cgit v1.2.3 From 23918873cbe055f22d40fa4c96651fd93186e687 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Mon, 9 Sep 2013 10:33:42 +0200 Subject: SI-7767 Test case for Scaladoc on early initializers --- test/scaladoc/run/t7767.check | 1 + test/scaladoc/run/t7767.scala | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 test/scaladoc/run/t7767.check create mode 100644 test/scaladoc/run/t7767.scala diff --git a/test/scaladoc/run/t7767.check b/test/scaladoc/run/t7767.check new file mode 100644 index 0000000000..619c56180b --- /dev/null +++ b/test/scaladoc/run/t7767.check @@ -0,0 +1 @@ +Done. diff --git a/test/scaladoc/run/t7767.scala b/test/scaladoc/run/t7767.scala new file mode 100644 index 0000000000..be5e9fe080 --- /dev/null +++ b/test/scaladoc/run/t7767.scala @@ -0,0 +1,20 @@ +import scala.tools.nsc.doc.model._ +import scala.tools.partest.ScaladocModelTest + +object Test extends ScaladocModelTest { + + // This caused an infinite recursion in method inline() in CommentFactory.scala + override def code = """ + class Docable extends { /**Doc*/ val foo = 0 } with AnyRef + """ + + // no need for special settings + def scaladocSettings = "" + + def testModel(rootPackage: Package) = { + import access._ + // if it doesn't hang, the test is passed + val comment = rootPackage._class("Docable")._value("foo").comment.map(_.body.toString.trim).getOrElse("") + assert(comment.contains("Doc"), comment) + } +} -- cgit v1.2.3