diff --git a/modules/core/shared/src/main/scala/eu/timepit/refined/api/RefinedLT.scala b/modules/core/shared/src/main/scala/eu/timepit/refined/api/RefinedLT.scala deleted file mode 100644 index 9c2cba8c5..000000000 --- a/modules/core/shared/src/main/scala/eu/timepit/refined/api/RefinedLT.scala +++ /dev/null @@ -1,36 +0,0 @@ -package eu.timepit.refined.api - -import eu.timepit.refined.internal._ -import eu.timepit.refined.macros.RefineMacro -import scala.reflect.macros.blackbox -import shapeless.Nat - -/** - * Similar to `Refined[T, P]`, except manifests implicitly, - * if and only if the value of literal type `L` satisfies `P` at - * compile time. - */ -case class RefinedLT[L, P] private (expr: String) - -trait RefinedLTP1 { - implicit def refinedLTNat[L <: Nat, P]( - implicit - w: WitnessAs[L, Int], - v: Validate[Int, P] - ): RefinedLT[L, P] = - macro RefineMacro.implRefLT[L, Int, P] -} - -object RefinedLT extends RefinedLTP1 { - def manifest[L: c.WeakTypeTag, T: c.WeakTypeTag, P: c.WeakTypeTag]( - c: blackbox.Context - )(w: c.Expr[WitnessAs[L, T]], v: c.Expr[Validate[T, P]]): c.Expr[RefinedLT[L, P]] = - c.universe.reify(RefinedLT[L, P](v.splice.showExpr(w.splice.snd))) - - implicit def refinedLT[L, T, P]( - implicit - w: WitnessAs[L, T], - v: Validate[T, P] - ): RefinedLT[L, P] = - macro RefineMacro.implRefLT[L, T, P] -} diff --git a/modules/core/shared/src/main/scala/eu/timepit/refined/generic.scala b/modules/core/shared/src/main/scala/eu/timepit/refined/generic.scala index edc61b996..34fb48b31 100644 --- a/modules/core/shared/src/main/scala/eu/timepit/refined/generic.scala +++ b/modules/core/shared/src/main/scala/eu/timepit/refined/generic.scala @@ -1,8 +1,6 @@ package eu.timepit.refined -import eu.timepit.refined.api.{Inference, RefinedLT, Validate} -import eu.timepit.refined.api.Inference.==> -import eu.timepit.refined.generic._ +import eu.timepit.refined.api.Validate import eu.timepit.refined.internal.WitnessAs import shapeless._ import shapeless.ops.coproduct.ToHList @@ -10,7 +8,7 @@ import shapeless.ops.hlist.ToList import shapeless.ops.record.Keys /** Module for generic predicates. */ -object generic extends GenericInference { +object generic { /** Predicate that checks if a value is equal to `U`. */ final case class Equal[U](u: U) @@ -101,11 +99,3 @@ object generic extends GenericInference { Validate.alwaysPassed(Supertype()) } } - -private[refined] trait GenericInference { - implicit def equalValidateInference[U, P]( - implicit - tvp: RefinedLT[U, P] - ): Equal[U] ==> P = - Inference(s"equalValidateInference(${tvp.expr})") -} diff --git a/modules/core/shared/src/main/scala/eu/timepit/refined/macros/RefineMacro.scala b/modules/core/shared/src/main/scala/eu/timepit/refined/macros/RefineMacro.scala index e187520d4..f098df0f8 100644 --- a/modules/core/shared/src/main/scala/eu/timepit/refined/macros/RefineMacro.scala +++ b/modules/core/shared/src/main/scala/eu/timepit/refined/macros/RefineMacro.scala @@ -1,9 +1,9 @@ package eu.timepit.refined.macros -import eu.timepit.refined.api.{RefinedLT, RefType, Validate} +import eu.timepit.refined.api.{RefType, Validate} import eu.timepit.refined.char.{Digit, Letter, LowerCase, UpperCase, Whitespace} import eu.timepit.refined.collection.NonEmpty -import eu.timepit.refined.internal.{Resources, WitnessAs} +import eu.timepit.refined.internal.Resources import eu.timepit.refined.numeric.{Negative, NonNegative, NonPositive, Positive} import scala.reflect.macros.blackbox @@ -38,27 +38,6 @@ class RefineMacro(val c: blackbox.Context) extends MacroUtils with LiteralMatche ): c.Expr[FTP] = c.Expr[FTP](impl(t)(rt, v).tree) - def implRefLT[L: c.WeakTypeTag, T: c.WeakTypeTag, P: c.WeakTypeTag]( - w: c.Expr[WitnessAs[L, T]], - v: c.Expr[Validate[T, P]] - ): c.Expr[RefinedLT[L, P]] = { - // doing eval(v) before eval(w) is important for... reasons. - val validate = eval(v) - val litval = w.tree match { - case q"$_.WitnessAs.natWitnessAs[..$_]($_, new $_.Inst[..$_]($lv).asInstanceOf[..$_], $_)" => { - // trying to eval the Nat witness directly confuses the typer, it is - // tripping on some type recursion involving _5 and Succ[_4] in same expression - eval(c.Expr[T](lv)) - } - case _ => eval(w).snd - } - val res = validate.validate(litval) - if (res.isFailed) { - abort(validate.showResult(litval, res)) - } - RefinedLT.manifest[L, T, P](c)(w, v) - } - private def validateInstance[T, P](v: c.Expr[Validate[T, P]])( implicit T: c.WeakTypeTag[T], 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 0ef95ba66..a6801329a 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 @@ -13,7 +13,7 @@ import shapeless.test.illTyped class AutoSpec extends Properties("auto") { property("autoInfer") = secure { val a: Char Refined Equal[W.`'0'`.T] = '0' - val b: Char Refined Digit = a + val b: Char Refined Digit = '0' illTyped( "val c: Char Refined Letter = a", """type mismatch.*""" diff --git a/modules/core/shared/src/test/scala/eu/timepit/refined/CollectionInferenceSpec.scala b/modules/core/shared/src/test/scala/eu/timepit/refined/CollectionInferenceSpec.scala index 2991b2d46..f2abe1335 100644 --- a/modules/core/shared/src/test/scala/eu/timepit/refined/CollectionInferenceSpec.scala +++ b/modules/core/shared/src/test/scala/eu/timepit/refined/CollectionInferenceSpec.scala @@ -13,10 +13,11 @@ import shapeless.test.illTyped class CollectionInferenceSpec extends Properties("CollectionInference") { import shim.Inference +/* property("Exists[A] ==> Exists[B]") = secure { Inference[Contains[W.`'5'`.T], Exists[Digit]].isValid } - +*/ property("Exists ==> NonEmpty") = secure { Inference[Exists[Digit], NonEmpty].isValid } diff --git a/modules/core/shared/src/test/scala/eu/timepit/refined/GenericInferenceSpec.scala b/modules/core/shared/src/test/scala/eu/timepit/refined/GenericInferenceSpec.scala deleted file mode 100644 index 589aa4478..000000000 --- a/modules/core/shared/src/test/scala/eu/timepit/refined/GenericInferenceSpec.scala +++ /dev/null @@ -1,29 +0,0 @@ -package eu.timepit.refined - -//import eu.timepit.refined.api.Inference -import eu.timepit.refined.generic.Equal -import eu.timepit.refined.numeric.Greater -import eu.timepit.refined.string.StartsWith -import org.scalacheck.Prop._ -import org.scalacheck.Properties -import shapeless.Nat - -class GenericInferenceSpec extends Properties("GenericInference") { - import shim.Inference - - property("Equal[S1] ==> StartsWith[S2]") = secure { - Inference[Equal[W.`"abcd"`.T], StartsWith[W.`"ab"`.T]].isValid - } - - property("Equal[S1] =!> StartsWith[S2]") = secure { - Inference[Equal[W.`"abcd"`.T], StartsWith[W.`"cd"`.T]].notValid - } - - property("Equal[Nat] ==> Greater[I]") = secure { - Inference[Equal[Nat._10], Greater[W.`5`.T]].isValid - } - - property("Equal[Nat] =!> Greater[I]") = secure { - Inference[Equal[Nat._5], Greater[W.`10`.T]].notValid - } -}