@@ -16,13 +16,14 @@ import dotty.tools.dotc.core.Symbols.{Symbol, defn}
16
16
import dotty .tools .dotc .core .StdNames .nme
17
17
import dotty .tools .dotc .core .SymDenotations .SymDenotation
18
18
import 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 }
20
20
import dotty .tools .dotc .parsing .Tokens
21
21
import dotty .tools .dotc .util .Chars
22
22
import dotty .tools .dotc .util .SourcePosition
23
23
24
24
import scala .collection .mutable
25
25
import scala .util .control .NonFatal
26
+ import dotty .tools .dotc .core .Types .TypeRef
26
27
27
28
/**
28
29
* One of the results of a completion query.
@@ -310,28 +311,30 @@ object Completion {
310
311
resultMappings
311
312
}
312
313
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)
317
320
case _ => qual
318
321
319
322
/** Completions for selections from a term.
320
323
* Direct members take priority over members from extensions
321
324
* and so do members from extensions over members from implicit conversions
322
325
*/
323
326
def selectionCompletions (qual : Tree )(using Context ): CompletionMap =
324
- val reducedQual = reduceUnderlyingMatchType (qual)
327
+ val adjustedQual = widenQualifier (qual)
325
328
326
- implicitConversionMemberCompletions(reducedQual ) ++
327
- extensionCompletions(reducedQual ) ++
328
- directMemberCompletions(reducedQual )
329
+ implicitConversionMemberCompletions(adjustedQual ) ++
330
+ extensionCompletions(adjustedQual ) ++
331
+ directMemberCompletions(adjustedQual )
329
332
330
333
/** Completions for members of `qual`'s type.
331
334
* These include inherited definitions but not members added by extensions or implicit conversions
332
335
*/
333
336
def directMemberCompletions (qual : Tree )(using Context ): CompletionMap =
334
- if qual.tpe.widenDealias. isExactlyNothing then
337
+ if qual.tpe.isExactlyNothing then
335
338
Map .empty
336
339
else
337
340
accessibleMembers(qual.tpe).groupByName
@@ -378,7 +381,7 @@ object Completion {
378
381
379
382
/** Completions from implicit conversions including old style extensions using implicit classes */
380
383
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
382
385
Map .empty
383
386
else
384
387
val membersFromConversion =
0 commit comments