From dbf7f023cc4e1f902d8edd96fe07740572d63a59 Mon Sep 17 00:00:00 2001 From: Liu Fengyun Date: Wed, 5 Aug 2020 15:34:52 +0200 Subject: [PATCH 1/2] Fix #9489: skip redundancy check for Type[T] --- .../src/dotty/tools/dotc/transform/patmat/Space.scala | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala b/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala index 0ac620b804c4..de36804d9a15 100644 --- a/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala +++ b/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala @@ -839,12 +839,14 @@ class SpaceEngine(using Context) extends SpaceLogic { } private def redundancyCheckable(sel: Tree): Boolean = - // Ignore Expr for unreachability as a special case. + // Ignore Expr[T] and Type[T] for unreachability as a special case. // Quote patterns produce repeated calls to the same unapply method, but with different implicit parameters. // Since we assume that repeated calls to the same unapply method overlap // and implicit parameters cannot normally differ between two patterns in one `match`, - // the easiest solution is just to ignore Expr. - !sel.tpe.hasAnnotation(defn.UncheckedAnnot) && !sel.tpe.widen.isRef(defn.QuotedExprClass) + // the easiest solution is just to ignore Expr[T] and Type[T]. + !sel.tpe.hasAnnotation(defn.UncheckedAnnot) + && !sel.tpe.widen.isRef(defn.QuotedExprClass) + && !sel.tpe.widen.isRef(defn.QuotedTypeClass) def checkRedundancy(_match: Match): Unit = { val Match(sel, cases) = _match From 978fa3378d2d9b6317d83530baa220c83da84be9 Mon Sep 17 00:00:00 2001 From: Liu Fengyun Date: Wed, 5 Aug 2020 15:35:56 +0200 Subject: [PATCH 2/2] Add test --- tests/patmat/i9489.scala | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 tests/patmat/i9489.scala diff --git a/tests/patmat/i9489.scala b/tests/patmat/i9489.scala new file mode 100644 index 000000000000..30ae98e72f64 --- /dev/null +++ b/tests/patmat/i9489.scala @@ -0,0 +1,7 @@ +import scala.quoted._ + +def summonTypedType[T : Type](using QuoteContext): String = '[T] match { + case '[Boolean] => "Boolean" + case '[Byte] => "Byte" + case _ => "Other" +}