From 0e9b21ae8631f3747b4015264762761eeb16f889 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Tue, 18 Jul 2023 19:06:44 +0100 Subject: [PATCH] Fix a case of MT reduction using abstract types The original motivation wasn't with a test case. And reproducing it is not convincing. So I'd rather revert and fix this issue. --- compiler/src/dotty/tools/dotc/core/TypeComparer.scala | 2 +- compiler/test/dotc/pos-test-pickling.blacklist | 1 + tests/pos/i18202.scala | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 tests/pos/i18202.scala diff --git a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala index db1bf85ade93..670ce4961ee5 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala @@ -1030,7 +1030,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling tp1.cases.corresponds(tp2.cases)(isSubType) case _ => false } - (!caseLambda.exists || canWidenAbstract) && recur(tp1.underlying, tp2) || compareMatch + recur(tp1.underlying, tp2) || compareMatch case tp1: AnnotatedType if tp1.isRefining => isNewSubType(tp1.parent) case JavaArrayType(elem1) => diff --git a/compiler/test/dotc/pos-test-pickling.blacklist b/compiler/test/dotc/pos-test-pickling.blacklist index f1e6ce805b27..09b3ec010034 100644 --- a/compiler/test/dotc/pos-test-pickling.blacklist +++ b/compiler/test/dotc/pos-test-pickling.blacklist @@ -53,6 +53,7 @@ i15827.scala i17149.scala tuple-fold.scala mt-redux-norm.perspective.scala +i18202.scala # Opaque type i5720.scala diff --git a/tests/pos/i18202.scala b/tests/pos/i18202.scala new file mode 100644 index 000000000000..345888f88921 --- /dev/null +++ b/tests/pos/i18202.scala @@ -0,0 +1,7 @@ +import compiletime.ops.int.* + +type TupleIndex[T <: Tuple, A, I <: Int] <: (Any, Int) = T match + case A *: _ => (A, I) + case _ *: t => TupleIndex[t, A, S[I]] + +def tupleIndex[T <: Tuple, A](using i: ValueOf[Tuple.Elem[TupleIndex[T, A, 0], 1]]): Int = i.value