Skip to content

orphan parameter reference when pickling sealed trait with generous use of F-bounds #9759

Closed
@smarter

Description

@smarter

Minimized code

sealed trait Expr[A <: Expr[A]]

case class Equals[A <: Value[A]](lhs: Expr[A], rhs: Expr[A]) extends Expr[Value.Boolean]

sealed trait Value[A <: Value[A]] extends Expr[A]
object Value {
  case class String(value: java.lang.String) extends Value[String]
  case class Int(value: Long) extends Value[Int]
  case class Boolean(value: java.lang.Boolean) extends Value[Boolean]
}

object Main extends App {
  def evaluate[A <: Value[A]](expr: Expr[A]): A = expr match {
    case Equals(Value.String(lhs), Value.String(rhs)) => Value.Boolean(lhs == rhs)
  }
}

Output (click arrow to expand)

java.lang.AssertionError: assertion failed: orphan parameter reference: TypeParamRef(A) while compiling try/ni.scala
Exception in thread "main" java.lang.AssertionError: assertion failed: orphan parameter reference: TypeParamRef(A)
        at dotty.DottyPredef$.assertFail(DottyPredef.scala:17)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleNewType(TreePickler.scala:300)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleType(TreePickler.scala:175)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleNewType(TreePickler.scala:302)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleType(TreePickler.scala:175)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleNewType$$anonfun$11$$anonfun$1(TreePickler.scala:192)
        at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:333)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleNewType$$anonfun$1(TreePickler.scala:192)
        at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
        at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:70)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleNewType(TreePickler.scala:192)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleType(TreePickler.scala:175)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleNewType$$anonfun$7(TreePickler.scala:275)
        at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
        at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:70)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleNewType(TreePickler.scala:275)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleType(TreePickler.scala:175)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleNewType$$anonfun$5(TreePickler.scala:267)
        at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
        at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:70)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleNewType(TreePickler.scala:269)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleType(TreePickler.scala:175)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$20(TreePickler.scala:533)
        at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
        at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:70)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:534)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTpt(TreePickler.scala:327)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$38$$anonfun$1(TreePickler.scala:444)
        at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:333)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$4(TreePickler.scala:444)
        at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
        at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:70)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:445)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$22(TreePickler.scala:541)
        at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
        at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:70)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:548)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$6(TreePickler.scala:467)
        at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
        at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:70)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:467)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$13(TreePickler.scala:505)
        at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
        at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:70)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:505)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$40$$anonfun$1(TreePickler.scala:501)
        at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:333)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$12(TreePickler.scala:501)
        at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
        at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:70)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:502)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTreeUnlessEmpty(TreePickler.scala:330)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleDef$$anonfun$2(TreePickler.scala:345)
        at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
        at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:70)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleDef(TreePickler.scala:347)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:561)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleStats$$anonfun$2(TreePickler.scala:371)
        at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:333)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleStats(TreePickler.scala:371)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$26(TreePickler.scala:587)
        at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
        at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:70)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:588)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleDef$$anonfun$2(TreePickler.scala:342)
        at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
        at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:70)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleDef(TreePickler.scala:347)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:563)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleStats$$anonfun$2(TreePickler.scala:371)
        at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:333)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleStats(TreePickler.scala:371)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$28(TreePickler.scala:597)
        at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
        at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:70)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:597)
        at dotty.tools.dotc.core.tasty.TreePickler.pickle$$anonfun$1(TreePickler.scala:766)
        at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:333)
        at dotty.tools.dotc.core.tasty.TreePickler.pickle(TreePickler.scala:766)
        at dotty.tools.dotc.transform.Pickler.run$$anonfun$3$$anonfun$2(Pickler.scala:69)
        at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:333)
        at dotty.tools.dotc.transform.Pickler.run$$anonfun$1(Pickler.scala:105)
        at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:333)
        at dotty.tools.dotc.transform.Pickler.run(Pickler.scala:105)
        at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:296)
        at scala.collection.immutable.List.map(List.scala:246)
        at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:297)
        at dotty.tools.dotc.transform.Pickler.runOn(Pickler.scala:110)
        at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:185)
        at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
        at dotty.tools.dotc.Run.runPhases$5(Run.scala:195)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:203)
        at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
        at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:63)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:210)
        at dotty.tools.dotc.Run.compileSources(Run.scala:147)
        at dotty.tools.dotc.Run.compile(Run.scala:129)
        at dotty.tools.dotc.Driver.doCompile(Driver.scala:38)
        at dotty.tools.dotc.Driver.process(Driver.scala:195)
        at dotty.tools.dotc.Driver.process(Driver.scala:164)
        at dotty.tools.dotc.Driver.process(Driver.scala:176)
        at dotty.tools.dotc.Driver.main(Driver.scala:203)
        at dotty.tools.dotc.Main.main(Main.scala)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions