Skip to content

Commit

Permalink
fix: Wrong implicits priority (#198)
Browse files Browse the repository at this point in the history
  • Loading branch information
matwojcik authored Dec 19, 2023
1 parent 3635e87 commit 86ed230
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
3 changes: 1 addition & 2 deletions scalacheck/src/io/github/iltotore/iron/scalacheck/all.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.github.iltotore.iron.scalacheck

object all:
export any.given
object all extends AnyArbitrary:
export char.given
export collection.given
export numeric.given
Expand Down
8 changes: 5 additions & 3 deletions scalacheck/src/io/github/iltotore/iron/scalacheck/any.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import org.scalacheck.Arbitrary.arbitrary

import scala.compiletime.constValue

object any extends LowPriorityArbitrary:
object any extends AnyArbitrary

trait AnyArbitrary extends LowPriorityArbitrary:

inline given strictEqual[A, V <: A]: Arbitrary[A :| StrictEqual[V]] = Arbitrary(Gen.oneOf(Seq(constValue[V]))).asInstanceOf

inline given union[A, C](using IsUnion[C]): Arbitrary[A :| C] = Arbitrary(unionGen[A, C])

trait LowPriorityArbitrary extends LowPriorityArbitrary2:
Expand All @@ -22,4 +24,4 @@ trait LowPriorityArbitrary extends LowPriorityArbitrary2:
trait LowPriorityArbitrary2:

inline given fallback[A: Arbitrary, C](using inline constraint: Constraint[A, C]): Arbitrary[A :| C] =
Arbitrary(arbitrary.filter(constraint.test(_))).asInstanceOf
Arbitrary(arbitrary.filter(constraint.test(_))).asInstanceOf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ object CollectionSuite extends TestSuite:
}
test("empty") {
test("seq") - testGen[Seq[Boolean], Empty]
test("string") - testGen[Seq[Boolean], Empty]
test("string") - testGen[String, Empty]
}
test("contain") {
test("seq") - testGen[Seq[Boolean], Contain[true]]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.github.iltotore.iron.scalacheck

import io.github.iltotore.iron.constraint.all.*
import io.github.iltotore.iron.scalacheck.all.given
import utest.*

object ImplicitsOrderingSuite extends TestSuite:

val tests: Tests = Tests {
test("should resolve implicits using all.given import") - testGen[String, Empty]
}

0 comments on commit 86ed230

Please sign in to comment.