Closed
Description
It seems that currently compiler is more strict and does not handle well recursive/lazy references to type classes. In case Codec#AvroType
is not an abstract type member the snippet would compile.
Compiler version
3.1.2, works with 3.1.1
First bad commit ae1b00d
Minimized code
//> using scala "3.1.2"
// //> using scala "3.1.1" // Last stable working version
trait Error
sealed abstract class Codec[A] {
type AvroType
def encode(a: A): Either[Error, AvroType]
def decode(value: Any): Either[Error, A]
}
object Codec {
type Aux[AvroType0, A] = Codec[A] {
type AvroType = AvroType0
}
final def instance[AvroType0, A](
encode: A => Either[Error, AvroType0],
decode: Any => Either[Error, A]
): Codec.Aux[AvroType0, A] = ???
implicit final def option[A](implicit codec: Codec[A]): Codec[Option[A]] = ???
given Codec.Aux[Int, Int] = ???
}
@main def test() = {
implicit val codec: Codec[Option[Int]] =
Codec.instance(
Codec.option[Int].encode,
Codec.option[Int].decode
)
}
Output
[error] ./test.scala:29:7: pickling reference to as yet undefined ($1$ : Codec[Option[Int]]) with symbol value $1$
[error] Codec.option[Int].encode,
[error] ^
Error compiling project (Scala 3.1.2, JVM)
Expectation
The snippet should compile like in the 3.1.1