From cb3e536f954d7e9a3eea528b07ffb768537f1383 Mon Sep 17 00:00:00 2001 From: Felix Mulder Date: Fri, 10 Feb 2017 15:29:35 +0100 Subject: Fix cheeky comment in nested scope --- .../dotty/tools/dotc/parsing/DocstringTests.scala | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'compiler/test/dotty') diff --git a/compiler/test/dotty/tools/dotc/parsing/DocstringTests.scala b/compiler/test/dotty/tools/dotc/parsing/DocstringTests.scala index 930ec117a..81ac77761 100644 --- a/compiler/test/dotty/tools/dotc/parsing/DocstringTests.scala +++ b/compiler/test/dotty/tools/dotc/parsing/DocstringTests.scala @@ -488,4 +488,34 @@ class DocstringTests extends DocstringTest { checkDocString(c.rawComment.map(_.raw), "/** Class1 */") } } + + @Test def nestedComment = { + val source = + """ + |trait T { + | /** Cheeky comment */ + |} + |class C + """.stripMargin + + import dotty.tools.dotc.ast.untpd._ + checkFrontend(source) { + case p @ PackageDef(_, Seq(_, c: TypeDef)) => + assert(c.rawComment == None, s"class C is not supposed to have a docstring (${c.rawComment.get}) in:$source") + } + } + + @Test def eofComment = { + val source = + """ + |class C + |/** Cheeky comment */ + """.stripMargin + + import dotty.tools.dotc.ast.untpd._ + checkFrontend(source) { + case p @ PackageDef(_, Seq(c: TypeDef)) => + assert(c.rawComment == None, s"class C is not supposed to have a docstring (${c.rawComment.get}) in:$source") + } + } } /* End class */ -- cgit v1.2.3