Skip to content

Commit 3ea9831

Browse files
committed
Fix "closest" computation for docstrings
1 parent db387a2 commit 3ea9831

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

compiler/src/dotty/tools/dotc/parsing/Scanners.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,9 @@ object Scanners {
192192
/** Returns the closest docstring preceding the position supplied */
193193
def getDocComment(pos: Int): Option[Comment] = {
194194
def closest(c: Comment, docstrings: List[Comment]): Comment = docstrings match {
195-
case x :: xs if (c.pos.end < x.pos.end && x.pos.end <= pos) => closest(x, xs)
195+
case x :: xs =>
196+
if (c.pos.end < x.pos.end && x.pos.end <= pos) closest(x, xs)
197+
else closest(c, xs)
196198
case Nil => c
197199
}
198200

0 commit comments

Comments
 (0)