Skip to content

Commit 59d86d4

Browse files
committed
change MatchTypeInDisguise scope
1 parent 530f138 commit 59d86d4

File tree

2 files changed

+17
-36
lines changed

2 files changed

+17
-36
lines changed

compiler/src/dotty/tools/dotc/interactive/Completion.scala

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ import dotty.tools.dotc.util.SourcePosition
2323

2424
import scala.collection.mutable
2525
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
3026

3127
/**
3228
* One of the results of a completion query.
@@ -369,24 +365,8 @@ object Completion {
369365

370366
/** Completions for derived members of `MatchType`'s type. */
371367
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-
388368
qual.tpe.widenDealias match
389-
case MatchTypeInDisguise(mt) => accessibleMembers(mt.reduced).groupByName
369+
case ctx.typer.MatchTypeInDisguise(mt) => accessibleMembers(mt.reduced).groupByName
390370
case _ => Map.empty
391371

392372
/** Completions from extension methods */

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,6 +1499,22 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
14991499
assignType(cpy.Closure(tree)(env1, meth1, target), meth1, target)
15001500
}
15011501

1502+
/** Extractor for match types hidden behind an AppliedType/MatchAlias */
1503+
object MatchTypeInDisguise {
1504+
def unapply(tp: AppliedType)(using Context): Option[MatchType] = tp match {
1505+
case AppliedType(tycon: TypeRef, args) =>
1506+
tycon.info match {
1507+
case MatchAlias(alias) =>
1508+
alias.applyIfParameterized(args) match {
1509+
case mt: MatchType => Some(mt)
1510+
case _ => None
1511+
}
1512+
case _ => None
1513+
}
1514+
case _ => None
1515+
}
1516+
}
1517+
15021518
def typedMatch(tree: untpd.Match, pt: Type)(using Context): Tree =
15031519
tree.selector match {
15041520
case EmptyTree =>
@@ -1526,21 +1542,6 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
15261542
val selType = rawSelectorTpe match
15271543
case c: ConstantType if tree.isInline => c
15281544
case otherTpe => otherTpe.widen
1529-
/** Extractor for match types hidden behind an AppliedType/MatchAlias */
1530-
object MatchTypeInDisguise {
1531-
def unapply(tp: AppliedType): Option[MatchType] = tp match {
1532-
case AppliedType(tycon: TypeRef, args) =>
1533-
tycon.info match {
1534-
case MatchAlias(alias) =>
1535-
alias.applyIfParameterized(args) match {
1536-
case mt: MatchType => Some(mt)
1537-
case _ => None
1538-
}
1539-
case _ => None
1540-
}
1541-
case _ => None
1542-
}
1543-
}
15441545

15451546
/** Does `tree` has the same shape as the given match type?
15461547
* We only support typed patterns with empty guards, but

0 commit comments

Comments
 (0)