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._
2424import dotty .tools .dotc .util .{NameTransformer , NoSourcePosition , SourcePosition }
2525
2626import scala .collection .mutable
27+ import scala .util .control .NonFatal
2728
2829/**
2930 * One of the results of a completion query.
@@ -223,11 +224,11 @@ object Completion {
223224 // import java.lang.annotation
224225 // is shadowed by
225226 // 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
231232
232233 denotss.find(! _.ctx.isImportContext) match {
233234 // 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 {
985985 (" annotation" , Module , " scala.annotation" )
986986 )
987987 )
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+ )
988997}
You can’t perform that action at this time.
0 commit comments