@@ -16,13 +16,14 @@ import dotty.tools.dotc.core.Symbols.{Symbol, defn}
1616import dotty .tools .dotc .core .StdNames .nme
1717import dotty .tools .dotc .core .SymDenotations .SymDenotation
1818import dotty .tools .dotc .core .TypeError
19- import dotty .tools .dotc .core .Types .{ExprType , MethodOrPoly , NameFilter , NoType , TermRef , Type }
19+ import dotty .tools .dotc .core .Types .{AppliedType , ExprType , MethodOrPoly , NameFilter , NoType , TermRef , Type }
2020import dotty .tools .dotc .parsing .Tokens
2121import dotty .tools .dotc .util .Chars
2222import dotty .tools .dotc .util .SourcePosition
2323
2424import scala .collection .mutable
2525import scala .util .control .NonFatal
26+ import dotty .tools .dotc .core .Types .TypeRef
2627
2728/**
2829 * One of the results of a completion query.
@@ -310,28 +311,30 @@ object Completion {
310311 resultMappings
311312 }
312313
313- /** Replaces underlying type with reduced one, when it's MatchType */
314- def reduceUnderlyingMatchType (qual : Tree )(using Context ): Tree =
315- qual.tpe.widen match
316- case ctx.typer.MatchTypeInDisguise (mt) => qual.withType(mt)
314+ /** Widen only those types which are applied or are exactly nothing
315+ */
316+ def widenQualifier (qual : Tree )(using Context ): Tree =
317+ qual.tpe.widenDealias match
318+ case widenedType if widenedType.isExactlyNothing => qual.withType(widenedType)
319+ case appliedType : AppliedType => qual.withType(appliedType)
317320 case _ => qual
318321
319322 /** Completions for selections from a term.
320323 * Direct members take priority over members from extensions
321324 * and so do members from extensions over members from implicit conversions
322325 */
323326 def selectionCompletions (qual : Tree )(using Context ): CompletionMap =
324- val reducedQual = reduceUnderlyingMatchType (qual)
327+ val adjustedQual = widenQualifier (qual)
325328
326- implicitConversionMemberCompletions(reducedQual ) ++
327- extensionCompletions(reducedQual ) ++
328- directMemberCompletions(reducedQual )
329+ implicitConversionMemberCompletions(adjustedQual ) ++
330+ extensionCompletions(adjustedQual ) ++
331+ directMemberCompletions(adjustedQual )
329332
330333 /** Completions for members of `qual`'s type.
331334 * These include inherited definitions but not members added by extensions or implicit conversions
332335 */
333336 def directMemberCompletions (qual : Tree )(using Context ): CompletionMap =
334- if qual.tpe.widenDealias. isExactlyNothing then
337+ if qual.tpe.isExactlyNothing then
335338 Map .empty
336339 else
337340 accessibleMembers(qual.tpe).groupByName
@@ -378,7 +381,7 @@ object Completion {
378381
379382 /** Completions from implicit conversions including old style extensions using implicit classes */
380383 private def implicitConversionMemberCompletions (qual : Tree )(using Context ): CompletionMap =
381- if qual.tpe.widenDealias. isExactlyNothing || qual.tpe.isNullType then
384+ if qual.tpe.isExactlyNothing || qual.tpe.isNullType then
382385 Map .empty
383386 else
384387 val membersFromConversion =
0 commit comments