diff --git a/build.sbt b/build.sbt index 93bf2fda7..63eac9dc4 100644 --- a/build.sbt +++ b/build.sbt @@ -315,7 +315,11 @@ lazy val moduleJvmSettings = Def.settings( ProblemFilters.exclude[DirectMissingMethodProblem]( "eu.timepit.refined.jsonpath.string.jsonPathValidate"), ProblemFilters.exclude[MissingTypesProblem]("eu.timepit.refined.jsonpath.string$*"), - ProblemFilters.exclude[MissingClassProblem]("eu.timepit.refined.jsonpath.StringValidate") + ProblemFilters.exclude[MissingClassProblem]("eu.timepit.refined.jsonpath.StringValidate"), + ProblemFilters.exclude[ReversedMissingMethodProblem]( + "eu.timepit.refined.NumericInference.greaterEqualInference"), + ProblemFilters.exclude[ReversedMissingMethodProblem]( + "eu.timepit.refined.NumericInference.lessEqualInference") ) } ) diff --git a/modules/core/shared/src/main/scala/eu/timepit/refined/numeric.scala b/modules/core/shared/src/main/scala/eu/timepit/refined/numeric.scala index 8e44a11e1..dd25820b6 100644 --- a/modules/core/shared/src/main/scala/eu/timepit/refined/numeric.scala +++ b/modules/core/shared/src/main/scala/eu/timepit/refined/numeric.scala @@ -195,4 +195,10 @@ private[refined] trait NumericInference { nc: Numeric[C] ): Greater[A] ==> Greater[B] = Inference(nc.gt(wa.value, nc.fromInt(tb())), s"greaterInferenceWitNat(${wa.value}, ${tb()})") + + implicit def greaterEqualInference[A]: Greater[A] ==> GreaterEqual[A] = + Inference(true, "greaterEqualInference") + + implicit def lessEqualInference[A]: Less[A] ==> LessEqual[A] = + Inference(true, "lessEqualInference") } diff --git a/modules/core/shared/src/test/scala/eu/timepit/refined/NumericInferenceSpec.scala b/modules/core/shared/src/test/scala/eu/timepit/refined/NumericInferenceSpec.scala index fea94d4a6..565fec758 100644 --- a/modules/core/shared/src/test/scala/eu/timepit/refined/NumericInferenceSpec.scala +++ b/modules/core/shared/src/test/scala/eu/timepit/refined/NumericInferenceSpec.scala @@ -91,6 +91,14 @@ class NumericInferenceSpec extends Properties("NumericInference") { Inference[Interval.Closed[_5, _10], LessEqual[_11]].isValid } + property("Greater[A] ==> GreaterEqual[A]") = secure { + Inference[Greater[W.`0`.T], GreaterEqual[W.`0`.T]].isValid + } + + property("Less[A] ==> LessEqual[A]") = secure { + Inference[Less[W.`0`.T], LessEqual[W.`0`.T]].isValid + } + /* property("Interval.Closed[Nat] ==> GreaterEqual[Nat]") = secure { Inference[Interval.Closed[_5, _10], GreaterEqual[_4]].isValid