From 8248da283c4a823f977ed99a233d39b572ba66b9 Mon Sep 17 00:00:00 2001 From: Michael Pilquist Date: Thu, 16 Dec 2021 07:53:13 -0500 Subject: [PATCH] Add fromProductTyped tests --- tests/neg/deriving-from-product-typed.scala | 10 ++++++++++ tests/run/deriving-from-product-typed.scala | 11 +++++++++++ 2 files changed, 21 insertions(+) create mode 100644 tests/neg/deriving-from-product-typed.scala create mode 100644 tests/run/deriving-from-product-typed.scala diff --git a/tests/neg/deriving-from-product-typed.scala b/tests/neg/deriving-from-product-typed.scala new file mode 100644 index 000000000000..91537af9d08c --- /dev/null +++ b/tests/neg/deriving-from-product-typed.scala @@ -0,0 +1,10 @@ +import deriving.Mirror + +case class A(x: Int, y: String) +case class B(a: Any, b: Any) +object A: + def f = summon[Mirror.ProductOf[A]].fromProductTyped((1, 2)) // error + def g = summon[Mirror.ProductOf[A]].fromTuple((1, 2)) // error + def h = summon[Mirror.ProductOf[B]].fromProductTyped(A(1, "")) + def i = summon[Mirror.ProductOf[A]].fromProductTyped(B(1, "")) // error + diff --git a/tests/run/deriving-from-product-typed.scala b/tests/run/deriving-from-product-typed.scala new file mode 100644 index 000000000000..7b68c40c7ad1 --- /dev/null +++ b/tests/run/deriving-from-product-typed.scala @@ -0,0 +1,11 @@ +case class A(x: Option[Int], y: Option[Any]) +case class B(x: Some[Int], y: Some[Boolean]) + +object Test extends App: + import deriving.* + + val ma = summon[Mirror.ProductOf[A]] + + ma.fromProductTyped(B(Some(1), Some(true))) + ma.fromProductTyped((Some(1), Some(false))) +