From befe9a74443254ee6c4e91e037154b77f4fe9d3d Mon Sep 17 00:00:00 2001 From: Liu Fengyun Date: Fri, 4 Sep 2020 15:40:29 +0200 Subject: [PATCH 1/3] Add further minimized test --- tests/patmat/i9631.scala | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 tests/patmat/i9631.scala 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 _ => + } +} From a5b60252e097943df9e18c3c54c1b39a0afc96ee Mon Sep 17 00:00:00 2001 From: Liu Fengyun Date: Fri, 4 Sep 2020 17:37:37 +0200 Subject: [PATCH 2/3] Fix #9631: handle F-bounds in type expansion --- compiler/src/dotty/tools/dotc/core/TypeOps.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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") From 4ad9d8a45923953eec1f924cd9a2148f2c18cee2 Mon Sep 17 00:00:00 2001 From: Liu Fengyun Date: Fri, 4 Sep 2020 17:41:46 +0200 Subject: [PATCH 3/3] Add original test --- tests/pos/i9631.scala | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tests/pos/i9631.scala 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 + } +}