@@ -242,9 +242,7 @@ object Completion:
242242 case tpd.Select (qual @ tpd.This (_), _) :: _ if qual.span.isSynthetic => completer.scopeCompletions.names
243243 case StringContextApplication (qual) =>
244244 completer.scopeCompletions.names ++ completer.selectionCompletions(qual)
245- case tpd.Select (qual, _) :: _ if qual.typeOpt.hasSimpleKind =>
246- completer.selectionCompletions(qual)
247- case tpd.Select (qual, _) :: _ => Map .empty
245+ case tpd.Select (qual, _) :: _ => completer.selectionCompletions(qual)
248246 case (tree : tpd.ImportOrExport ) :: _ => completer.directMemberCompletions(tree.expr)
249247 case _ => completer.scopeCompletions.names
250248
@@ -367,7 +365,7 @@ object Completion:
367365 * For the results of all `xyzCompletions` methods term names and type names are always treated as different keys in the same map
368366 * and they never conflict with each other.
369367 */
370- class Completer (val mode : Mode , pos : SourcePosition , untpdPath : List [untpd.Tree ], matches : Name => Boolean ):
368+ class Completer (val mode : Mode , pos : SourcePosition , untpdPath : List [untpd.Tree ], matches : Name => Boolean )( using Context ) :
371369 /** Completions for terms and types that are currently in scope:
372370 * the members of the current class, local definitions and the symbols that have been imported,
373371 * recursively adding completions from outer scopes.
@@ -381,7 +379,7 @@ object Completion:
381379 * (even if the import follows it syntactically)
382380 * - a more deeply nested import shadowing a member or a local definition causes an ambiguity
383381 */
384- def scopeCompletions ( using context : Context ) : CompletionResult =
382+ lazy val scopeCompletions : CompletionResult =
385383
386384 /** Temporary data structure representing denotations with the same name introduced in a given scope
387385 * as a member of a type, by a local definition or by an import clause
@@ -475,9 +473,15 @@ object Completion:
475473 def selectionCompletions (qual : tpd.Tree )(using Context ): CompletionMap =
476474 val adjustedQual = widenQualifier(qual)
477475
478- implicitConversionMemberCompletions(adjustedQual) ++
476+ if qual.symbol.is(Package ) then
477+ directMemberCompletions(adjustedQual)
478+ else if qual.typeOpt.hasSimpleKind then
479+ implicitConversionMemberCompletions(adjustedQual) ++
479480 extensionCompletions(adjustedQual) ++
480481 directMemberCompletions(adjustedQual)
482+ else
483+ Map .empty
484+
481485
482486 /** Completions for members of `qual`'s type.
483487 * These include inherited definitions but not members added by extensions or implicit conversions
@@ -584,8 +588,7 @@ object Completion:
584588 // There are four possible ways for an extension method to be applicable
585589
586590 // 1. The extension method is visible under a simple name, by being defined or inherited or imported in a scope enclosing the reference.
587- val termCompleter = new Completer (Mode .Term , pos, untpdPath, matches)
588- val extMethodsInScope = termCompleter.scopeCompletions.names.toList.flatMap:
591+ val extMethodsInScope = scopeCompletions.names.toList.flatMap:
589592 case (name, denots) => denots.collect:
590593 case d : SymDenotation if d.isTerm && d.termRef.symbol.is(Extension ) => (d.termRef, name.asTermName)
591594
0 commit comments