@@ -23,6 +23,10 @@ import dotty.tools.dotc.util.SourcePosition
2323
2424import scala .collection .mutable
2525import 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
2630
2731/**
2832 * One of the results of a completion query.
@@ -302,6 +306,7 @@ object Completion {
302306 def selectionCompletions (qual : Tree )(using Context ): CompletionMap =
303307 implicitConversionMemberCompletions(qual) ++
304308 extensionCompletions(qual) ++
309+ matchTypeCompletions(qual) ++
305310 directMemberCompletions(qual)
306311
307312 /** Completions for members of `qual`'s type.
@@ -362,6 +367,28 @@ object Completion {
362367 implicitConversionTargets(qual)(using ctx.fresh.setExploreTyperState()).flatMap(accessibleMembers)
363368 membersFromConversion.toSeq.groupByName
364369
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+
365392 /** Completions from extension methods */
366393 private def extensionCompletions (qual : Tree )(using Context ): CompletionMap =
367394 def asDefLikeType (tpe : Type ): Type = tpe match
0 commit comments