Skip to content

Commit 64cecda

Browse files
authored
Merge pull request #9501 from dotty-staging/fix-9489
Fix #9489: skip redundancy check for Type[T]
2 parents 8eea8d8 + 978fa33 commit 64cecda

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -839,12 +839,14 @@ class SpaceEngine(using Context) extends SpaceLogic {
839839
}
840840

841841
private def redundancyCheckable(sel: Tree): Boolean =
842-
// Ignore Expr for unreachability as a special case.
842+
// Ignore Expr[T] and Type[T] for unreachability as a special case.
843843
// Quote patterns produce repeated calls to the same unapply method, but with different implicit parameters.
844844
// Since we assume that repeated calls to the same unapply method overlap
845845
// and implicit parameters cannot normally differ between two patterns in one `match`,
846-
// the easiest solution is just to ignore Expr.
847-
!sel.tpe.hasAnnotation(defn.UncheckedAnnot) && !sel.tpe.widen.isRef(defn.QuotedExprClass)
846+
// the easiest solution is just to ignore Expr[T] and Type[T].
847+
!sel.tpe.hasAnnotation(defn.UncheckedAnnot)
848+
&& !sel.tpe.widen.isRef(defn.QuotedExprClass)
849+
&& !sel.tpe.widen.isRef(defn.QuotedTypeClass)
848850

849851
def checkRedundancy(_match: Match): Unit = {
850852
val Match(sel, cases) = _match

tests/patmat/i9489.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import scala.quoted._
2+
3+
def summonTypedType[T : Type](using QuoteContext): String = '[T] match {
4+
case '[Boolean] => "Boolean"
5+
case '[Byte] => "Byte"
6+
case _ => "Other"
7+
}

0 commit comments

Comments
 (0)