@@ -545,7 +545,7 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
545
545
* C --> C if current owner is C !!!
546
546
*
547
547
*/
548
- def showType (tp : Type ): String = {
548
+ def showType (tp : Type , showTypeArgs : Boolean = false ): String = {
549
549
val enclosingCls = ctx.owner.enclosingClass
550
550
551
551
def isOmittable (sym : Symbol ) =
@@ -564,25 +564,25 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
564
564
case _ => tp.show
565
565
}
566
566
567
- def refine (tp : Type ): String = tp match {
567
+ def refine (tp : Type ): String = tp.stripAnnots match {
568
568
case tp : RefinedType => refine(tp.parent)
569
- case tp : AppliedType => refine(tp.typeConstructor)
569
+ case tp : AppliedType =>
570
+ refine(tp.typeConstructor) + (
571
+ if (showTypeArgs) tp.argInfos.map(refine).mkString(" [" , " ," , " ]" )
572
+ else " "
573
+ )
570
574
case tp : ThisType => refine(tp.tref)
571
575
case tp : NamedType =>
572
576
val pre = refinePrefix(tp.prefix)
573
577
if (tp.name == tpnme.higherKinds) pre
574
578
else if (pre.isEmpty) tp.name.show.stripSuffix(" $" )
575
579
else pre + " ." + tp.name.show.stripSuffix(" $" )
580
+ case tp : OrType => refine(tp.tp1) + " | " + refine(tp.tp2)
581
+ case _ : TypeBounds => " _"
576
582
case _ => tp.show.stripSuffix(" $" )
577
583
}
578
584
579
- val text = tp.stripAnnots match {
580
- case tp : OrType => showType(tp.tp1) + " | " + showType(tp.tp2)
581
- case tp => refine(tp)
582
- }
583
-
584
- if (text.isEmpty) enclosingCls.show.stripSuffix(" $" )
585
- else text
585
+ refine(tp)
586
586
}
587
587
588
588
/** Whether the counterexample is satisfiable. The space is flattened and non-empty. */
@@ -646,7 +646,7 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
646
646
else if (tp.classSymbol.is(CaseClass ) && ! hasCustomUnapply(tp.classSymbol))
647
647
// use constructor syntax for case class
648
648
showType(tp) + params(tp).map(_ => " _" ).mkString(" (" , " , " , " )" )
649
- else if (decomposed) " _: " + showType(tp)
649
+ else if (decomposed) " _: " + showType(tp, showTypeArgs = true )
650
650
else " _"
651
651
case Prod (tp, fun, sym, params, _) =>
652
652
if (ctx.definitions.isTupleType(tp))
@@ -677,7 +677,6 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
677
677
}) ||
678
678
tpw.isRef(defn.BooleanClass ) ||
679
679
tpw.typeSymbol.is(JavaEnum ) ||
680
- canDecompose(tpw) ||
681
680
(defn.isTupleType(tpw) && tpw.argInfos.exists(isCheckable(_)))
682
681
}
683
682
@@ -719,7 +718,12 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
719
718
}
720
719
721
720
private def redundancyCheckable (sel : Tree ): Boolean =
722
- ! sel.tpe.hasAnnotation(defn.UncheckedAnnot )
721
+ // Ignore Expr for unreachability as a special case.
722
+ // Quote patterns produce repeated calls to the same unapply method, but with different implicit parameters.
723
+ // Since we assume that repeated calls to the same unapply method overlap
724
+ // and implicit parameters cannot normally differ between two patterns in one `match`,
725
+ // the easiest solution is just to ignore Expr.
726
+ ! sel.tpe.hasAnnotation(defn.UncheckedAnnot ) && ! sel.tpe.widen.isRef(defn.QuotedExprClass )
723
727
724
728
def checkRedundancy (_match : Match ): Unit = {
725
729
val Match (sel, cases) = _match
0 commit comments