Skip to content

Conversation

@mpskowron
Copy link

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.

@mpskowron mpskowron changed the title Modified singletonWitnessAs to use valueOf instead of constValue Modified singletonWitnessAs to use valueOf instead of constValue for Scala 3 Jul 26, 2021
@codecov
Copy link

codecov bot commented Jul 26, 2021

Codecov Report

Merging #998 (f76973a) into master (01c5220) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           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.

@mergify mergify bot added the core label Sep 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant