Skip to content

Commit ee37bea

Browse files
committed
No completions on package symbols
1 parent bfae5dd commit ee37bea

File tree

2 files changed

+29
-14
lines changed

2 files changed

+29
-14
lines changed

compiler/src/dotty/tools/dotc/interactive/Completion.scala

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,7 @@ object Completion:
245245
case tpd.Select(qual @ tpd.This(_), _) :: _ if qual.span.isSynthetic => completer.scopeCompletions.names
246246
case StringContextApplication(qual) =>
247247
completer.scopeCompletions.names ++ completer.selectionCompletions(qual)
248-
case tpd.Select(qual, _) :: _ if qual.typeOpt.hasSimpleKind =>
249-
completer.selectionCompletions(qual)
250-
case tpd.Select(qual, _) :: _ => Map.empty
248+
case tpd.Select(qual, _) :: _ => completer.selectionCompletions(qual)
251249
case (tree: tpd.ImportOrExport) :: _ => completer.directMemberCompletions(tree.expr)
252250
case _ => completer.scopeCompletions.names
253251

@@ -478,17 +476,16 @@ object Completion:
478476
def selectionCompletions(qual: tpd.Tree)(using Context): CompletionMap =
479477
val adjustedQual = widenQualifier(qual)
480478

481-
val implicitConversionMembers = implicitConversionMemberCompletions(adjustedQual)
482-
val extensionMembers = extensionCompletions(adjustedQual)
483-
val directMembers = directMemberCompletions(adjustedQual)
484-
val namedTupleMembers = namedTupleCompletions(adjustedQual)
485-
486-
List(
487-
implicitConversionMembers,
488-
extensionMembers,
489-
directMembers,
490-
namedTupleMembers
491-
).reduce(_ ++ _)
479+
if qual.symbol.is(Package) then
480+
directMemberCompletions(adjustedQual)
481+
else if qual.typeOpt.hasSimpleKind then
482+
implicitConversionMemberCompletions(adjustedQual) ++
483+
extensionCompletions(adjustedQual) ++
484+
directMemberCompletions(adjustedQual) ++
485+
namedTupleCompletions(adjustedQual)
486+
else
487+
Map.empty
488+
492489

493490
/** Completions for members of `qual`'s type.
494491
* These include inherited definitions but not members added by extensions or implicit conversions

presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionSuite.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2257,3 +2257,21 @@ class CompletionSuite extends BaseCompletionSuite:
22572257
|""".stripMargin,
22582258
""
22592259
)
2260+
2261+
@Test def `no-extension-completion-on-packages` =
2262+
check(
2263+
"""object M:
2264+
| scala.runt@@
2265+
|""".stripMargin,
2266+
"""runtime scala
2267+
|PartialFunction scala""".stripMargin // those are the actual members of scala
2268+
)
2269+
2270+
@Test def `no-extension-completions-on-package-objects` =
2271+
check(
2272+
"""package object magic { def test: Int = ??? }
2273+
|object M:
2274+
| magic.@@
2275+
|""".stripMargin,
2276+
"test: Int"
2277+
)

0 commit comments

Comments
 (0)