aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFelix Mulder <felix.mulder@gmail.com>2016-03-08 21:23:15 +0100
committerFelix Mulder <felix.mulder@gmail.com>2016-04-07 08:40:27 +0200
commit7f20aef772c1bdc6e0a699a82f179d93934a1555 (patch)
treede3c92c9097bc3d5b8e557ea85a849e69b9f0fc8 /src
parent3b4906d9dc5621d595259254057dd5649e4f9862 (diff)
downloaddotty-7f20aef772c1bdc6e0a699a82f179d93934a1555.tar.gz
dotty-7f20aef772c1bdc6e0a699a82f179d93934a1555.tar.bz2
dotty-7f20aef772c1bdc6e0a699a82f179d93934a1555.zip
Fix traits w/o bodies not getting the correct docstring
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/parsing/Scanners.scala15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/dotty/tools/dotc/parsing/Scanners.scala b/src/dotty/tools/dotc/parsing/Scanners.scala
index 0529b5cfa..438c54398 100644
--- a/src/dotty/tools/dotc/parsing/Scanners.scala
+++ b/src/dotty/tools/dotc/parsing/Scanners.scala
@@ -185,14 +185,12 @@ object Scanners {
/** The currently closest docstring, replaced every time a new docstring is
* encountered
*/
- var closestDocString: Option[Comment] = None
+ val closestDocString: mutable.Queue[Comment] = mutable.Queue.empty
/** Returns `closestDocString`'s raw string and sets it to `None` */
- def getDocString(): Option[String] = {
- val current = closestDocString.map(_.chrs)
- closestDocString = None
- current
- }
+ def getDocString(): Option[String] =
+ if (closestDocString.isEmpty) None
+ else Some(closestDocString.dequeue.chrs)
/** A buffer for comments */
val commentBuf = new StringBuilder
@@ -570,9 +568,8 @@ object Scanners {
val pos = Position(start, charOffset, start)
val comment = Comment(pos, flushBuf(commentBuf))
- closestDocString =
- if (comment.isDocComment) Option(comment)
- else closestDocString
+ if (comment.isDocComment)
+ closestDocString.enqueue(comment)
if (keepComments)
revComments = comment :: revComments