Skip to content

Commit

Permalink
fix: Not enough restrictive StrictEqual instance
Browse files Browse the repository at this point in the history
Issue was blocking migration to Scala 3.3.3 due to a compilation error.
  • Loading branch information
Iltotore committed Mar 4, 2024
1 parent 8a88093 commit 3b504ae
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import mill._, define._, api.Result
import scalalib._, scalalib.scalafmt._, scalalib.publish._, scalajslib._, scalanativelib._

object versions {
val scala = "3.3.1"
val scala = "3.3.3"
val scalaJS = "1.13.2"
val scalaNative = "0.4.15"
}
Expand Down
6 changes: 4 additions & 2 deletions main/src/io/github/iltotore/iron/constraint/any.scala
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,14 @@ object any:

object StrictEqual:

private trait StrictEqualConstraint[A, V] extends Constraint[A, StrictEqual[V]]:
trait StrictEqualConstraint[A, V] extends Constraint[A, StrictEqual[V]]:
override inline def message: String = "Should strictly equal to " + stringValue[V]

inline given [A, V]: StrictEqualConstraint[A, V] with
class AnyStrictEqualConstraint[A, V] extends StrictEqualConstraint[A, V]:
override inline def test(value: A): Boolean = value == constValue[V]

inline given [A, V](using inline v: ValueOf[V]): AnyStrictEqualConstraint[A, V] = new AnyStrictEqualConstraint

inline given bigDecimalDouble[V <: Float | Double]: StrictEqualConstraint[BigDecimal, V] with
override inline def test(value: BigDecimal): Boolean = value == BigDecimal(doubleValue[V])

Expand Down

0 comments on commit 3b504ae

Please sign in to comment.