Skip to content

Commit 50435c2

Browse files
committed
fix scala#2143: remove widenForMatchSelector in typing patmat
1 parent df22149 commit 50435c2

File tree

3 files changed

+2
-14
lines changed

3 files changed

+2
-14
lines changed

compiler/src/dotty/tools/dotc/transform/patmat/Space.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
354354
case Bind(_, pat) => project(pat)
355355
case UnApply(_, _, pats) =>
356356
if (pat.tpe.classSymbol.is(CaseClass))
357-
Kon(pat.tpe.stripAnnots, pats.map(pat => project(pat, roundUp)))
357+
Kon(pat.tpe.stripAnnots.dealias, pats.map(pat => project(pat, roundUp)))
358358
else if (roundUp) Typ(pat.tpe.stripAnnots, false)
359359
else Empty
360360
case Typed(pat @ UnApply(_, _, _), _) => project(pat)

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -187,17 +187,6 @@ object Inferencing {
187187
approxAbove - approxBelow
188188
}
189189

190-
/** Recursively widen and also follow type declarations and type aliases. */
191-
def widenForMatchSelector(tp: Type)(implicit ctx: Context): Type = tp.widen match {
192-
case tp: TypeRef if !tp.symbol.isClass =>
193-
widenForMatchSelector(tp.superType)
194-
case tp: HKApply =>
195-
widenForMatchSelector(tp.superType)
196-
case tp: AnnotatedType =>
197-
tp.derivedAnnotatedType(widenForMatchSelector(tp.tpe), tp.annot)
198-
case tp => tp
199-
}
200-
201190
/** Following type aliases and stripping refinements and annotations, if one arrives at a
202191
* class type reference where the class has a companion module, a reference to
203192
* that companion module. Otherwise NoType

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -834,8 +834,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
834834
typed(desugar.makeCaseLambda(tree.cases, protoFormals.length, unchecked) withPos tree.pos, pt)
835835
case _ =>
836836
val sel1 = typedExpr(tree.selector)
837-
val selType = widenForMatchSelector(
838-
fullyDefinedType(sel1.tpe, "pattern selector", tree.pos))
837+
val selType = fullyDefinedType(sel1.tpe, "pattern selector", tree.pos).widen
839838

840839
val cases1 = typedCases(tree.cases, selType, pt.notApplied)
841840
val cases2 = harmonize(cases1).asInstanceOf[List[CaseDef]]

0 commit comments

Comments
 (0)