diff --git a/compiler/src/dotty/tools/dotc/core/TypeOps.scala b/compiler/src/dotty/tools/dotc/core/TypeOps.scala index 8cfb7759b6d0..05f8b8b850f3 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeOps.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeOps.scala @@ -673,8 +673,8 @@ object TypeOps: tp // break cycles case tp: TypeRef if isBounds(tp.underlying) => - val lo = this(tp.info.loBound) - val hi = this(tp.info.hiBound) + val lo = this(tp.info.loBound.subst(tp.symbol :: Nil, WildcardType :: Nil)) + val hi = this(tp.info.hiBound.subst(tp.symbol :: Nil, WildcardType :: Nil)) // See tests/patmat/gadt.scala tests/patmat/exhausting.scala tests/patmat/t9657.scala val exposed = expose(lo, hi) typr.println(s"$tp exposed to =====> $exposed") diff --git a/tests/patmat/i9631.scala b/tests/patmat/i9631.scala new file mode 100644 index 000000000000..17600db8517a --- /dev/null +++ b/tests/patmat/i9631.scala @@ -0,0 +1,12 @@ +trait Txn[T <: Txn[T]] + +sealed trait SkipList[T <: Txn[T]] + +trait Set[T <: Txn[T]] extends SkipList[T] + +object HASkipList { + def debug[T <: Txn[T]](in: SkipList[T]): Unit = in match { + case impl: Set[T] => + case _ => + } +} diff --git a/tests/pos/i9631.scala b/tests/pos/i9631.scala new file mode 100644 index 000000000000..5806bda33b4f --- /dev/null +++ b/tests/pos/i9631.scala @@ -0,0 +1,19 @@ +trait Txn[T <: Txn[T]] + +object SkipList { + trait Set[T <: Txn[T], A] extends SkipList[T, A, A] +} +sealed trait SkipList[T <: Txn[T], A, E] + +object HASkipList { + def debug[T <: Txn[T], A](in: SkipList[T, A, _], key: A)(implicit tx: T): Int = in match { + case impl: Impl[T, A, _] => impl.foo(key) + case _ => -1 + } + + private trait Impl[T <: Txn[T], A, E] { + self: SkipList[T, A, E] => + + def foo(key: A)(implicit tx: T): Int + } +}