"No singleton value available for A" when A is clearly a singleton

355 Views Asked by At

I can't figure out why this code wouldn't compile and fail with a:

No singleton value available for A
where: A is a type variable with constraint >: ("yo" : String) and <: Singleton

case class Wrapper[A <: Singleton](a: A)(using ValueOf[A])

def test[A <: Singleton](blabla: Wrapper[A]): Unit = ()

test(Wrapper("yo"))

Is this expected or a bug in Scala 3?

Note that if I extract Wrapper("yo") then it works:

case class Wrapper[A <: Singleton](a: A)(using ValueOf[A])

def test[A <: Singleton](blabla: Wrapper[A]): Unit = ()

val value = Wrapper("yo")
test(value)
0

There are 0 best solutions below