@@ -23,6 +23,10 @@ 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 .MatchType
27
+ import dotty .tools .dotc .core .Types .AppliedType
28
+ import dotty .tools .dotc .core .Types .TypeRef
29
+ import dotty .tools .dotc .core .Types .MatchAlias
26
30
27
31
/**
28
32
* One of the results of a completion query.
@@ -302,6 +306,7 @@ object Completion {
302
306
def selectionCompletions (qual : Tree )(using Context ): CompletionMap =
303
307
implicitConversionMemberCompletions(qual) ++
304
308
extensionCompletions(qual) ++
309
+ matchTypeCompletions(qual) ++
305
310
directMemberCompletions(qual)
306
311
307
312
/** Completions for members of `qual`'s type.
@@ -362,6 +367,28 @@ object Completion {
362
367
implicitConversionTargets(qual)(using ctx.fresh.setExploreTyperState()).flatMap(accessibleMembers)
363
368
membersFromConversion.toSeq.groupByName
364
369
370
+ /** Completions for derived members of `MatchType`'s type. */
371
+ def matchTypeCompletions (qual : Tree )(using Context ): CompletionMap =
372
+ /** Extractor for match types hidden behind an AppliedType/MatchAlias */
373
+ object MatchTypeInDisguise {
374
+ def unapply (tp : AppliedType ): Option [MatchType ] = tp match {
375
+ case AppliedType (tycon : TypeRef , args) =>
376
+ tycon.info match {
377
+ case MatchAlias (alias) =>
378
+ alias.applyIfParameterized(args) match {
379
+ case mt : MatchType => Some (mt)
380
+ case _ => None
381
+ }
382
+ case _ => None
383
+ }
384
+ case _ => None
385
+ }
386
+ }
387
+
388
+ qual.tpe.widenDealias match
389
+ case MatchTypeInDisguise (mt) => accessibleMembers(mt.reduced).groupByName
390
+ case _ => Map .empty
391
+
365
392
/** Completions from extension methods */
366
393
private def extensionCompletions (qual : Tree )(using Context ): CompletionMap =
367
394
def asDefLikeType (tpe : Type ): Type = tpe match
0 commit comments