AnyVal and Opaque type can't derive derivings.Mirror?

Viewed 146
  1. Scala3's derivings.Mirror does not seem to be able to derive value classes or opaque types that inherit from AnyVal. Is there any way to achieve this other than parsing the signature in the macro?
  case class Foo(value: String)
  case class Bar(value: String) extends AnyVal
  opaque type Hoo = Long

  inline def derive[A] {
    summonFrom[Result[A]] {
      case x: Result[A] => x
      case _: Mirror.Of[A] => ???
      case _ => error("Derive failed")
    }
  }

  derive[Foo] // success
  derive[Bar] // Derive failed
  derive[Foo] // Derive failed
  1. Why is there no Mirror in the case class that inherits from AnyVal?
case class Id(value: String) extends AnyVal // Don't match `_: Mirror.Of[Id]`
  1. Is it possible to explore implicit conversions from arbitrary types in Summoning Implicits Selectively and derive the type before the conversion?
  inline def derive[A] {
    summonFrom[Result[A]] {
      case x: `[T] => scala.Conversion[Result[T], Result[A]] => x[T](derive[T])
      case _ => error("Derive failed")
    }
  }

I don't know the difference between macro and compile operation...

0 Answers
Related