Skip to content

Commit 9453f6d

Browse files
committed
fix false positives in bootstrap
1 parent 495ed99 commit 9453f6d

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -417,14 +417,13 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
417417
case Bind(_, pat) => project(pat)
418418
case UnApply(fun, _, pats) =>
419419
if (pat.tpe.classSymbol.is(CaseClass))
420-
// FIXME: why dealias is needed here?
421-
Kon(pat.tpe.stripAnnots.dealias, pats.map(pat => project(pat)))
420+
Kon(pat.tpe.stripAnnots, pats.map(pat => project(pat)))
422421
else if (fun.symbol.owner == scalaSeqFactoryClass && fun.symbol.name == nme.unapplySeq)
423422
projectList(pats)
424423
else if (fun.symbol.info.resultType.isRef(scalaSomeClass))
425-
Kon(pat.tpe.stripAnnots.dealias, pats.map(pat => project(pat)))
424+
Kon(pat.tpe.stripAnnots, pats.map(pat => project(pat)))
426425
else
427-
Fun(pat.tpe.stripAnnots.dealias, fun.tpe, pats.map(pat => project(pat)))
426+
Fun(pat.tpe.stripAnnots, fun.tpe, pats.map(pat => project(pat)))
428427
case Typed(pat @ UnApply(_, _, _), _) => project(pat)
429428
case Typed(expr, _) => Typ(expr.tpe.stripAnnots, true)
430429
case _ =>
@@ -470,7 +469,7 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
470469
/** Is `tp1` a subtype of `tp2`? */
471470
def isSubType(tp1: Type, tp2: Type): Boolean = {
472471
// check SI-9657 and tests/patmat/gadt.scala
473-
val res = erase(tp1) <:< erase(tp2)
472+
val res = tp1 <:< erase(tp2)
474473
debug.println(s"${tp1.show} <:< ${tp2.show} = $res")
475474
res
476475
}

tests/patmat/dotty.scala

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
object IntEqualityTestTreeMaker {
2+
def unapply(xs: Int): Option[Int] = ???
3+
}
4+
5+
class Test {
6+
def isBelow(n: Int, s: String): Boolean = false
7+
8+
def foo(xs: List[(Int, String)]): Unit = (xs filter (isBelow _).tupled) match {
9+
case Nil =>
10+
case matches =>
11+
}
12+
13+
def linkCompanions(xs: List[(Int, Int)]): Unit = {
14+
xs.groupBy(_._1).foreach {
15+
case (_, List(x1, x2)) =>
16+
case _ => ()
17+
}
18+
}
19+
20+
def bar(xs: List[(Int, String)]): Unit = xs match {
21+
case (x, s) :: Nil =>
22+
case Nil =>
23+
case _ =>
24+
}
25+
26+
def patmat(alts: List[List[Int]]): Unit = alts.forall {
27+
case List(IntEqualityTestTreeMaker(_)) => false
28+
case _ => true
29+
}
30+
}

0 commit comments

Comments
 (0)