diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index ad243e1d211b..8a0b0f12c167 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -4586,14 +4586,6 @@ object Types { object MatchType { def apply(bound: Type, scrutinee: Type, cases: List[Type])(using Context): MatchType = unique(new CachedMatchType(bound, scrutinee, cases)) - - /** Extractor for `case _ =>` match type patterns */ - object WildcardPattern { - def unapply(tp: Type)(using Context): Option[Type] = tp match { - case HKTypeLambda(LambdaParam(tl1, 0) :: Nil, defn.MatchCase(TypeParamRef(tl2, 0), bodyTp)) => Some(bodyTp) - case _ => None - } - } } // ------ ClassInfo, Type Bounds -------------------------------------------------- diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index 4be607e421fd..bcec1f88a534 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -2582,7 +2582,7 @@ object Parsers { in.token match { case USCORE if in.lookahead.isArrow => val start = in.skipToken() - typeBounds().withSpan(Span(start, in.lastOffset, start)) + Ident(tpnme.WILDCARD).withSpan(Span(start, in.lastOffset, start)) case _ => infixType() } diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 61d959fb6cf4..be97d8757be7 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -459,6 +459,8 @@ class Typer extends Namer if ctx.mode.is(Mode.Pattern) then if name == nme.WILDCARD then return tree.withType(pt) + if name == tpnme.WILDCARD then + return tree.withType(defn.AnyType) if untpd.isVarPattern(tree) && name.isTermName then return typed(desugar.patternVar(tree), pt) else if ctx.mode.is(Mode.QuotedPattern) then @@ -1482,13 +1484,11 @@ class Typer extends Namer val Typed(_, tpt) = tpd.unbind(tpd.unsplice(pat1)) instantiateMatchTypeProto(pat1, pt) match { case defn.MatchCase(patternTp, _) => tpt.tpe frozen_=:= patternTp - case MatchType.WildcardPattern(_) => tpt.tpe frozen_=:= defn.AnyType case _ => false } case (id @ Ident(nme.WILDCARD), pt) => pt match { case defn.MatchCase(patternTp, _) => defn.AnyType frozen_=:= patternTp - case MatchType.WildcardPattern(_) => true case _ => false } case _ => false @@ -1600,7 +1600,6 @@ class Typer extends Namer def caseRest(pat: Tree)(using Context) = { val pt1 = instantiateMatchTypeProto(pat, pt) match { case defn.MatchCase(_, bodyPt) => bodyPt - case MatchType.WildcardPattern(bodyPt) => bodyPt case pt => pt } val pat1 = indexPattern(tree).transform(pat)