From 5fbb49d4567cb69890e0720971dbb8b4d3a1c2ac Mon Sep 17 00:00:00 2001 From: Aleksander Boruch-Gruszecki Date: Tue, 1 Dec 2020 14:01:02 +0100 Subject: [PATCH] Document why docstringMap is useful --- compiler/src/dotty/tools/dotc/parsing/Scanners.scala | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala index 97878c199af4..567bdb9b5e4e 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala @@ -178,7 +178,12 @@ object Scanners { error(s"illegal combination of -rewrite targets: ${enabled(0).name} and ${enabled(1).name}") } - /** All doc comments kept by their end position in a `Map` */ + /** All doc comments kept by their end position in a `Map`. + * + * Note: the map is necessary since the comments are looked up after an + * entire definition is parsed, and a definition can contain nested + * definitions with their own docstrings. + */ private var docstringMap: SortedMap[Int, Comment] = SortedMap.empty /* A Buffer for comment positions */