Skip to content

Commit 6ac2be5

Browse files
authored
Merge pull request #13831 from ghostbuster91/fix-13624
Fix missing code-completion on standalone annotations
2 parents 49b6c08 + b0de71e commit 6ac2be5

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3472,7 +3472,11 @@ object Parsers {
34723472
givenDef(start, mods, atSpan(in.skipToken()) { Mod.Given() })
34733473
case _ =>
34743474
syntaxErrorOrIncomplete(ExpectedStartOfTopLevelDefinition())
3475-
EmptyTree
3475+
mods.annotations match {
3476+
case head :: Nil => head
3477+
case Nil => EmptyTree
3478+
case all => Block(all, errorTermTree)
3479+
}
34763480
}
34773481

34783482
/** ClassDef ::= id ClassConstr TemplateOpt

language-server/test/dotty/tools/languageserver/CompletionTest.scala

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,4 +946,21 @@ class CompletionTest {
946946
("MyAnnotation", Module, "Foo.MyAnnotation")
947947
)
948948
)
949+
950+
@Test def i13624_annotation : Unit =
951+
code"""@annotation.implicitNot${m1}
952+
|@annotation.implicitNotFound @mai${m2}"""
953+
.withSource
954+
.completion(m1,
955+
Set(
956+
("implicitNotFound", Class, "scala.annotation.implicitNotFound"),
957+
("implicitNotFound", Module, "scala.annotation.implicitNotFound")
958+
)
959+
)
960+
.completion(m2,
961+
Set(
962+
("main", Class, "scala.main"),
963+
("main", Module, "main")
964+
)
965+
)
949966
}

0 commit comments

Comments
 (0)