From ae3b2716b6d00be325f5e107a00901c909d8967f Mon Sep 17 00:00:00 2001 From: Eugene Flesselle Date: Wed, 24 Apr 2024 19:47:51 +0200 Subject: [PATCH] Normalize for underlyingClassRef Related to #20258 Here too, I would be fine with not normalizing, but in that case pos/i15827 should become a neg test. --- compiler/src/dotty/tools/dotc/core/Types.scala | 3 ++- tests/pos/i15827b/A_1.scala | 8 ++++++++ tests/pos/i15827b/B_2.scala | 3 +++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 tests/pos/i15827b/A_1.scala create mode 100644 tests/pos/i15827b/B_2.scala diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index 870e985fd48e..a34a5206a011 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -1584,7 +1584,8 @@ object Types extends TypeUtils { else if (tp.symbol.isAliasType) tp.underlying.underlyingClassRef(refinementOK) else NoType case tp: AppliedType => - if (tp.tycon.isLambdaSub) NoType + if tp.isMatchAlias then tp.tryNormalize.underlyingClassRef(refinementOK) + else if (tp.tycon.isLambdaSub) NoType else tp.superType.underlyingClassRef(refinementOK) case tp: AnnotatedType => tp.parent.underlyingClassRef(refinementOK) diff --git a/tests/pos/i15827b/A_1.scala b/tests/pos/i15827b/A_1.scala new file mode 100644 index 000000000000..b8734fbdaa2f --- /dev/null +++ b/tests/pos/i15827b/A_1.scala @@ -0,0 +1,8 @@ + +case class Foo() + +type T = Tuple.Elem[(Foo, Any), 0] +type U = Tuple.Elem[(Any, T), 1] + +val _ = new T() // ok +val _ = new U() // ok diff --git a/tests/pos/i15827b/B_2.scala b/tests/pos/i15827b/B_2.scala new file mode 100644 index 000000000000..e39f0727b544 --- /dev/null +++ b/tests/pos/i15827b/B_2.scala @@ -0,0 +1,3 @@ + +val _ = new T() // was error +val _ = new U() // was error