Skip to content

Commit

Permalink
Merge pull request #612 from fthomas/topic/fix-608
Browse files Browse the repository at this point in the history
Add type param to autoUnwrap to improve type inference
  • Loading branch information
fthomas authored Feb 3, 2019
2 parents 8a9656b + 653e7a2 commit 09bfce8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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\).""")
Expand Down
18 changes: 18 additions & 0 deletions notes/0.9.5.markdown
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 09bfce8

Please sign in to comment.