Observe the following code:
import scala.language.implicitConversions
abstract class Basic(protected val s: String)
{ class Elem }
sealed trait ISA[T]
{ def apply(): Seq[T] }
object ISA
{ def nil[T]: ISA[T] = new ISA[T] { def apply(): Seq[T] = Seq() }
implicit def bare[T](t: T): ISA[T] = new ISA[T] { def apply(): Seq[T] = Seq(t) } }
case class Table(format: Table.Format) { }
object Table
{ val empty = Table(Format.empty)
case class Format(w1: ISA[Format.Width], w2: ISA[Format.Width], w3: ISA[Format.Width] = ISA.nil) { }
object Format
{ import ISA._
val empty = Format(nil,nil)
type Width = Width.Elem
object Width extends Basic("") } }
This compiles with Scala 2.13.8 and fails in Scala 3.1.2 (also in 3.1.3-RC4) with an:
java.lang.AssertionError: assertion failed: orphan parameter reference: TypeParamRef(T)
Btw, repairing is easy, there are several possibilities:
- replace line 22 with
val empty = Format(nil,nil,nil)
- remove default parameter in line 18
- move line 16 to the end of the object definition.
But, i don’t understand why this goes wrong. And the compiler should not blow up. Can anyone reproduce? Shall i file a compiler bug?