diff --git a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala index 4c493f033edb..193c4d74d977 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala @@ -631,7 +631,11 @@ object Scanners { nextChar() if (ch == '/') { skipLine(); finishComment() } else if (ch == '*') { nextChar(); skipComment(); finishComment() } - else false + else { + // This was not a comment, remove the `/` from the buffer + commentBuf.clear() + false + } } // Lookahead --------------------------------------------------------------- diff --git a/language-server/test/dotty/tools/languageserver/HoverTest.scala b/language-server/test/dotty/tools/languageserver/HoverTest.scala index 2de9d5faafaa..b78ea0e3163a 100644 --- a/language-server/test/dotty/tools/languageserver/HoverTest.scala +++ b/language-server/test/dotty/tools/languageserver/HoverTest.scala @@ -164,6 +164,14 @@ class HoverTest { | |**Version** | - 1.0""".stripMargin)) + } + @Test def i5482: Unit = { + code"""object Test { + | def bar: Int = 2 / 1 + | /** hello */ + | def ${m1}baz${m2}: Int = ??? + |}""".withSource + .hover(m1 to m2, hoverContent("Int", "hello")) } }