From 8fb0f81bd66962c2106fe36771ac9af8de754906 Mon Sep 17 00:00:00 2001 From: "Frank S. Thomas" Date: Sun, 3 Feb 2019 17:52:12 +0100 Subject: [PATCH 1/2] Add type param to autoUnwrap to improve type inference closes #608 --- .../src/main/scala/eu/timepit/refined/auto.scala | 2 +- .../src/test/scala/eu/timepit/refined/AutoSpec.scala | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/core/shared/src/main/scala/eu/timepit/refined/auto.scala b/modules/core/shared/src/main/scala/eu/timepit/refined/auto.scala index c4a326071..d1f8a2365 100644 --- a/modules/core/shared/src/main/scala/eu/timepit/refined/auto.scala +++ b/modules/core/shared/src/main/scala/eu/timepit/refined/auto.scala @@ -53,7 +53,7 @@ object auto { * Note: This conversion is not needed if `F[T, _] <: T` holds (which * is the case for `shapeless.tag.@@`, for example). */ - implicit def autoUnwrap[F[_, _], T](tp: F[T, _])(implicit rt: RefType[F]): T = + implicit def autoUnwrap[F[_, _], T, P](tp: F[T, P])(implicit rt: RefType[F]): T = rt.unwrap(tp) /** diff --git a/modules/core/shared/src/test/scala/eu/timepit/refined/AutoSpec.scala b/modules/core/shared/src/test/scala/eu/timepit/refined/AutoSpec.scala index e7f2a89df..5fec037ad 100644 --- a/modules/core/shared/src/test/scala/eu/timepit/refined/AutoSpec.scala +++ b/modules/core/shared/src/test/scala/eu/timepit/refined/AutoSpec.scala @@ -22,12 +22,18 @@ class AutoSpec extends Properties("auto") { a == b } - property("autoUnwrap") = secure { - val a: Char Refined Letter = 'A' - val b: Char = a + property("autoUnwrap: PosInt: Int") = secure { + val a: PosInt = PosInt.unsafeFrom(1) + val b: Int = a a.value == b } + property("autoUnwrap: PosInt + PosInt") = secure { + val a = PosInt.unsafeFrom(1) + val b = PosInt.unsafeFrom(2) + (a + b) == 3 + } + property("autoRefineV") = secure { val a: Char Refined Equal[W.`'0'`.T] = '0' illTyped("val b: Char Refined Equal[W.`'0'`.T] = '1'", """Predicate failed: \(1 == 0\).""") From 653e7a2f69edc5a473d9aeaa062725b1e0f0c190 Mon Sep 17 00:00:00 2001 From: "Frank S. Thomas" Date: Sun, 3 Feb 2019 21:17:37 +0100 Subject: [PATCH 2/2] Add release notes --- notes/0.9.5.markdown | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 notes/0.9.5.markdown diff --git a/notes/0.9.5.markdown b/notes/0.9.5.markdown new file mode 100644 index 000000000..c78afedde --- /dev/null +++ b/notes/0.9.5.markdown @@ -0,0 +1,18 @@ +### Bug fixes + +* Add type parameter for the predicate type to `auto.autoUnwrap` in + order to improve type inference. + ([#608][#608], [#612][#612] by [@fthomas][@fthomas]) + +### Updates + +* Update Cats to 1.6.0. ([#609][#609] by [@scala-steward][@scala-steward]) +* Update scodec to 1.11.2. ([#611][#611] by [@scala-steward][@scala-steward]) + +[#608]: https://github.com/fthomas/refined/issues/608 +[#609]: https://github.com/fthomas/refined/pull/609 +[#611]: https://github.com/fthomas/refined/pull/611 +[#612]: https://github.com/fthomas/refined/pull/612 + +[@fthomas]: https://github.com/fthomas +[@scala-steward]: https://github.com/scala-steward