Closed
Description
Compiler version
3.7.1
Minimized example
with scala repl -S 3.7.1 -experimental -Xprint:pickler
import scala.annotation.unroll
case class Foo(x: Int, @unroll y: Option[String] = None)
Output
final module class Foo() extends AnyRef(), scala.deriving.Mirror.Product {
this: Foo.type =>
private def writeReplace(): AnyRef =
new scala.runtime.ModuleSerializationProxy(classOf[Foo.type])
def apply(x: Int, y: Option[String]): Foo = new Foo(x, y)
def unapply(x$1: Foo): Foo = x$1
override def toString: String = "Foo"
def $lessinit$greater$default$2: Option[String] @uncheckedVariance = None
type MirroredMonoType = Foo
def fromProduct(x$0: Product): Foo.MirroredMonoType =
{
val arity: Int = x$0.productArity
val x$1: Int = x$0.productElement(0).$asInstanceOf[Int]
val y$1: Option[String] =
(if arity > 1 then x$0.productElement(1) else
Foo.$lessinit$greater$default$2).$asInstanceOf[Option[String]]
new Foo(x$1, y$1)
}
}
Expectation
this was very confusing that only fromProduct
seemed to be unrolled correctly, until i remembered that fromProduce is unrolled in the PostTyper phase, and so it appears that the main unroll phase wasn't even ran. And upon checking, indeed the ReplCompiler frontend stops after PostTyper and does not include UnrollDefinitions