You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make RefinedBase extend NewtypeBase to support unwrapping (getting value) for Refined and InlinedRefined types with Coercible
Version
unreleased
Description
typeMyType=MyType.TypeobjectMyTypeextendsInlinedRefined[String] {
overrideinlinedefinvalidReason(a: String):String="It has to be a non-empty String but got ["+ a +"]"overrideinlinedefpredicate(a: String):Boolean= a !=""overrideinlinedefinlinedPredicate(inlinea: String):Boolean= a !=""
}
typeSomething=Something.TypeobjectSomethingextendsInlinedRefined[Int] {
privatedefinlinedPredicate0(a: Expr[Int])(usingQuotes):Expr[Boolean] = {
importquotes.reflect.*
a.asTerm match {
caseInlined(_, _, Literal(IntConstant(num))) =>try {
validate(num)
Expr(true)
} catch {
case_: Throwable=>Expr(false)
}
case _ =>
report.error(
"Something must be a Int literal.",
a,
)
Expr(false)
}
}
overrideinlinedefinlinedPredicate(inlinea: Int):Boolean=${ inlinedPredicate0('a) }
overridedefinvalidReason(a: Int):String=s"The number is a negative Int. [a: ${a.toString}"overridedefpredicate(a: Int):Boolean=try {
validate(a)
true
} catch {
case_: Throwable=>false
}
}
Summary
Make
RefinedBase
extendNewtypeBase
to support unwrapping (getting value) forRefined
andInlinedRefined
types withCoercible
Version
unreleased
Description
The text was updated successfully, but these errors were encountered: