File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed
compiler/src/dotty/tools/dotc/interactive
language-server/test/dotty/tools/languageserver Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ import dotty.tools.dotc.printing.Texts._
24
24
import dotty .tools .dotc .util .{NameTransformer , NoSourcePosition , SourcePosition }
25
25
26
26
import scala .collection .mutable
27
+ import scala .util .control .NonFatal
27
28
28
29
/**
29
30
* One of the results of a completion query.
@@ -223,11 +224,11 @@ object Completion {
223
224
// import java.lang.annotation
224
225
// is shadowed by
225
226
// import scala.annotation
226
- def isJavaLangAndScala = denotss match
227
- case List (first, second) =>
228
- isScalaPackage(first) && isJavaLangPackage(second ) ||
229
- isScalaPackage(second) && isJavaLangPackage(first)
230
- case _ => false
227
+ def isJavaLangAndScala =
228
+ try
229
+ denotss.forall(denots => isScalaPackage(denots ) || isJavaLangPackage(denots))
230
+ catch
231
+ case NonFatal (_) => false
231
232
232
233
denotss.find(! _.ctx.isImportContext) match {
233
234
// most deeply nested member or local definition if not shadowed by an import
Original file line number Diff line number Diff line change @@ -985,4 +985,13 @@ class CompletionTest {
985
985
(" annotation" , Module , " scala.annotation" )
986
986
)
987
987
)
988
+
989
+ @ Test def importAnnotationAfterImport : Unit =
990
+ code """ import java.lang.annotation; import annot ${m1}"""
991
+ .withSource
992
+ .completion(m1,
993
+ Set (
994
+ (" annotation" , Module , " scala.annotation" )
995
+ )
996
+ )
988
997
}
You can’t perform that action at this time.
0 commit comments