refined
refined copied to clipboard
Modified singletonWitnessAs to use valueOf instead of constValue for Scala 3
This doesn't compile for Scala 3.0.1
import eu.timepit.refined.generic.Equal
import eu.timepit.refined.collection.Size
import eu.timepit.refined.refineV
val size = 2
val arr = refineV[Size[Equal[size.type]]](Array(1, 2))
Error message:
|val arr = refineV[Size[Equal[size.type]]](Array(1, 2))
| ^
| not a constant type: (size : Int); cannot take constValue
| This location contains code that was inlined from WitnessAs.scala:39
However, this does compile:
import eu.timepit.refined.generic.Equal
import eu.timepit.refined.collection.Size
import eu.timepit.refined.refineV
import eu.timepit.refined.internal.WitnessAs
inline given singletonWitnessAs[B, A <: B: ValueOf]: WitnessAs[A, B] = {
val a = valueOf[A]
WitnessAs(a, a)
}
val size = 2
val arr = refineV[Size[Equal[size.type]]](Array(1, 2))
Using refined with modified "signletonWitnessAs" also compiles. I don't know if this is correct fix for the issue, hope it is.
Codecov Report
Merging #998 (f76973a) into master (01c5220) will not change coverage. The diff coverage is
n/a
.
@@ Coverage Diff @@
## master #998 +/- ##
=======================================
Coverage 92.39% 92.39%
=======================================
Files 63 63
Lines 815 815
Branches 6 6
=======================================
Hits 753 753
Misses 62 62
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 01c5220...f76973a. Read the comment docs.