From c211343350145a2385d9e6112da253dd62e2cc7a Mon Sep 17 00:00:00 2001 From: Liu Fengyun Date: Thu, 4 Mar 2021 13:28:52 +0100 Subject: [PATCH] Fix #9781: add test --- tests/pos/i9781.scala | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tests/pos/i9781.scala diff --git a/tests/pos/i9781.scala b/tests/pos/i9781.scala new file mode 100644 index 000000000000..ecc268e8b28b --- /dev/null +++ b/tests/pos/i9781.scala @@ -0,0 +1,19 @@ +trait Txn[T <: Txn[T]] + +trait Elem[T <: Txn[T]] + +sealed trait State[+T] +final case class Done[T <: Txn[T]](elem: Elem[T]) extends State[T] +case object Busy extends State[Nothing] + +trait Test[Out <: Txn[Out]] { + def apply(opt: Option[State[Out]]): Any = opt match { + case Some(state) => + state match { + case Done(out) => "foo" // problem here + case Busy => throw new IllegalStateException("Cyclic object graph") + } + + case None => "bar" + } +}