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