diff options
author | Rahul Goma Phulore <rahul.phulore.999@gmail.com> | 2017-11-26 21:02:58 +0000 |
---|---|---|
committer | Rahul Goma Phulore <rahul.phulore.999@gmail.com> | 2017-11-26 21:02:58 +0000 |
commit | c560260df88d597fb8858603deb233c8212163b9 (patch) | |
tree | 95498c404dce5ad93f879bbd9742b2c24a1bac84 | |
parent | 192173d811f870e6e9c705c80118e27dc63a898b (diff) | |
download | magnolia-c560260df88d597fb8858603deb233c8212163b9.tar.gz magnolia-c560260df88d597fb8858603deb233c8212163b9.tar.bz2 magnolia-c560260df88d597fb8858603deb233c8212163b9.zip |
Avoid instantiating Unit when producing error stack
Fixes https://github.com/propensive/magnolia/issues/41.
-rw-r--r-- | core/shared/src/main/scala/magnolia.scala | 3 | ||||
-rw-r--r-- | tests/src/main/scala/tests.scala | 10 |
2 files changed, 12 insertions, 1 deletions
diff --git a/core/shared/src/main/scala/magnolia.scala b/core/shared/src/main/scala/magnolia.scala index 6400002..d400bc3 100644 --- a/core/shared/src/main/scala/magnolia.scala +++ b/core/shared/src/main/scala/magnolia.scala @@ -215,7 +215,8 @@ object Magnolia { typeOf[Int], typeOf[Long], typeOf[Char], - typeOf[Boolean]) + typeOf[Boolean], + typeOf[Unit]) val isValueClass = genericType <:< typeOf[AnyVal] && !primitives.exists(_ =:= genericType) diff --git a/tests/src/main/scala/tests.scala b/tests/src/main/scala/tests.scala index e453502..cf31836 100644 --- a/tests/src/main/scala/tests.scala +++ b/tests/src/main/scala/tests.scala @@ -161,6 +161,16 @@ object Tests extends TestApp { | in parameter 'alpha' of product type Beta |""")) + test("not attempt to instantiate Unit when producing error stack") { + scalac""" + import magnolia.examples._ + case class Gamma(unit: Unit) + Show.gen[Gamma] + """ + }.assert(_ == TypecheckError(txt"""magnolia: could not find typeclass for type Unit + | in parameter 'unit' of product type Gamma + |""")) + test("typenames and labels are not encoded") { implicitly[Show[String, `%%`]].show(`%%`(1, "two")) }.assert(_ == "%%(/=1,#=two)") |