diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index 513e00347251..e793c1977e80 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -5892,7 +5892,7 @@ object Types extends TypeUtils { /** Copy type aliases refinements to `toTp` from `fromTp` */ def withRefinements(toType: Type, fromTp: Type): Type = fromTp.dealias match - case RefinedType(fromParent, name, info: TypeAlias) if tp0.member(name).exists => + case RefinedType(fromParent, name, info: AliasingBounds) if tp0.member(name).exists => val parent1 = withRefinements(toType, fromParent) RefinedType(toType, name, info) case _ => toType diff --git a/tests/pos/i20080.scala b/tests/pos/i20080.scala new file mode 100644 index 000000000000..dbf6843fcbc4 --- /dev/null +++ b/tests/pos/i20080.scala @@ -0,0 +1,32 @@ + +trait Zippable[-A, -B]: + type Out + def zip(left: A, right: B): Out + +object Zippable extends ZippableLowPrio: + given append[A <: Tuple, B]: (Zippable[A, B] { type Out = Tuple.Append[A, B] }) = + (left, right) => left :* right + +trait ZippableLowPrio: + given pair[A, B]: (Zippable[A, B] { type Out = (A, B) }) = + (left, right) => (left, right) + + +object Minimization: + + trait Fun1: + type Out + def apply(x: Any): Out + + type M[X] = X match + case String => X + + def test[A] = + + val _: Fun1 { type Out = M[A] } = new Fun1: + type Out = M[A] + def apply(x: Any): Out = ??? + + val _: Fun1 { type Out = M[A] } = x => ??? + + val _: Fun1 { type Out = A match {case String => A} } = x => ???