Skip to content

Pickler regression in valerylobachev/data-dictionary-builder - crashes on tuple extraction #24207

@WojciechMazur

Description

@WojciechMazur

Based on the OpenCB failure in valerylobachev/data-dictionary-builder when investigating performance issues - the project build was stuck in the typer, commenting out parts of the code uncovered crash during pickler

Compiler version

Last good release: 3.8.0-RC1-bin-20250818-aaa39c5-NIGHTLY
First bad release: 3.8.0-RC1-bin-20250819-1f13619-NIGHTLY
Bisect points to 1f13619 / #23769

Minimized code

class Generator:
  private def generateTable(table: Table) = 
    val (ownRelations, _) = calculateOwnRelations(table)
    None

  private def calculateOwnRelations(table: Table) =
    val ownRelations = table.relations.filter(_.association.isDefined)
    (ownRelations, Nil)

case class Table(relations: Seq[TableRelation])
case class TableRelation(association: Option[Association])
trait Association

Output (click arrow to expand)

error when pickling type (table : Table)
error when pickling type (table.relations : Seq[TableRelation])
error when pickling tree this of class class dotty.tools.dotc.ast.Trees$This
error when pickling tree this.type of class class dotty.tools.dotc.ast.Trees$SingletonTypeTree
error when pickling tree this.type | pred.type of class class dotty.tools.dotc.ast.Trees$AppliedTypeTree
error when pickling tree new _root_.scala.annotation.retains[this.type | pred.type] of class class dotty.tools.dotc.ast.Trees$TypeApply
error when pickling tree new _root_.scala.annotation.retains[this.type | pred.type]() of class class dotty.tools.dotc.ast.Trees$Apply
error when pickling type Seq[TableRelation]
error when pickling type (Seq[TableRelation], scala.collection.immutable.Nil.type)
error when pickling tree Tuple2.unapply[Seq[TableRelation], scala.collection.immutable.Nil.type](ownRelations @ _, _) of class class dotty.tools.dotc.ast.Trees$UnApply
error when pickling tree case Tuple2.unapply[Seq[TableRelation], scala.collection.immutable.Nil.type](ownRelations @ _, _) => ownRelations:Seq[TableRelation] of class class dotty.tools.dotc.ast.Trees$CaseDef
error when pickling tree Generator.this.calculateOwnRelations(table):(Seq[TableRelation], scala.collection.immutable.Nil.type) @unchecked match 
  {
    case Tuple2.unapply[Seq[TableRelation], scala.collection.immutable.Nil.type](ownRelations @ _, _) => ownRelations:Seq[TableRelation]
  } of class class dotty.tools.dotc.ast.Trees$Match
error when pickling tree val ownRelations: Seq[TableRelation] =
  this.calculateOwnRelations(table):(Seq[TableRelation], scala.collection.immutable.Nil.type) @unchecked match 
    {
      case Tuple2.unapply[Seq[TableRelation], scala.collection.immutable.Nil.type](ownRelations @ _, _) => ownRelations:Seq[TableRelation]
    } of class class dotty.tools.dotc.ast.Trees$ValDef
error when pickling tree {
  val ownRelations: Seq[TableRelation] =
    this.calculateOwnRelations(table):(Seq[TableRelation], scala.collection.immutable.Nil.type) @unchecked match 
      {
        case Tuple2.unapply[Seq[TableRelation], scala.collection.immutable.Nil.type](ownRelations @ _, _) => ownRelations:Seq[TableRelation]
      }
  None
} of class class dotty.tools.dotc.ast.Trees$Block
error when pickling tree private[this] def generateTable(table: Table): None.type =
  {
    val ownRelations: Seq[TableRelation] =
      this.calculateOwnRelations(table):(Seq[TableRelation], scala.collection.immutable.Nil.type) @unchecked match 
        {
          case Tuple2.unapply[Seq[TableRelation], scala.collection.immutable.Nil.type](ownRelations @ _, _) => ownRelations:Seq[TableRelation]
        }
    None
  } of class class dotty.tools.dotc.ast.Trees$DefDef
error when pickling tree () extends Object() {
  private[this] def generateTable(table: Table): None.type =
    {
      val ownRelations: Seq[TableRelation] =
        this.calculateOwnRelations(table):(Seq[TableRelation], scala.collection.immutable.Nil.type) @unchecked match 
          {
            case Tuple2.unapply[Seq[TableRelation], scala.collection.immutable.Nil.type](ownRelations @ _, _) => ownRelations:Seq[TableRelation]
          }
      None
    }
  private[this] def calculateOwnRelations(table: Table): (Seq[TableRelation], scala.collection.immutable.Nil.type) =
    {
      val ownRelations: Seq[TableRelation] = table.relations.filter((_$1: TableRelation) => _$1.association.isDefined)
      Tuple2.apply[Seq[TableRelation], scala.collection.immutable.Nil.type](ownRelations, Nil)
    }
} of class class dotty.tools.dotc.ast.Trees$Template
error when pickling tree @SourceFile("test.scala") class Generator() extends Object() {
  private[this] def generateTable(table: Table): None.type =
    {
      val ownRelations: Seq[TableRelation] =
        this.calculateOwnRelations(table):(Seq[TableRelation], scala.collection.immutable.Nil.type) @unchecked match 
          {
            case Tuple2.unapply[Seq[TableRelation], scala.collection.immutable.Nil.type](ownRelations @ _, _) => ownRelations:Seq[TableRelation]
          }
      None
    }
  private[this] def calculateOwnRelations(table: Table): (Seq[TableRelation], scala.collection.immutable.Nil.type) =
    {
      val ownRelations: Seq[TableRelation] = table.relations.filter((_$1: TableRelation) => _$1.association.isDefined)
      Tuple2.apply[Seq[TableRelation], scala.collection.immutable.Nil.type](ownRelations, Nil)
    }
} of class class dotty.tools.dotc.ast.Trees$TypeDef
error when pickling tree package <empty> {
  @SourceFile("test.scala") class Generator() extends Object() {
    private[this] def generateTable(table: Table): None.type =
      {
        val ownRelations: Seq[TableRelation] =
          this.calculateOwnRelations(table):(Seq[TableRelation], scala.collection.immutable.Nil.type) @unchecked match 
            {
              case Tuple2.unapply[Seq[TableRelation], scala.collection.immutable.Nil.type](ownRelations @ _, _) => ownRelations:Seq[TableRelation]
            }
        None
      }
    private[this] def calculateOwnRelations(table: Table): (Seq[TableRelation], scala.collection.immutable.Nil.type) =
      {
        val ownRelations: Seq[TableRelation] = table.relations.filter((_$1: TableRelation) => _$1.association.isDefined)
        Tuple2.apply[Seq[TableRelation], scala.collection.immutable.Nil.type](ownRelations, Nil)
      }
  }
} of class class dotty.tools.dotc.ast.Trees$PackageDef

  unhandled exception while running pickler on /Users/wmazur/projects/scala/community-build3/test.scala

  An unhandled exception was thrown in the compiler.
  Please file a crash report here:
  https://github.com/scala/scala3/issues/new/choose
  For non-enriched exceptions, compile with -Xno-enrich-error-messages.


     while compiling: /Users/wmazur/projects/scala/community-build3/test.scala
        during phase: pickler
                mode: Mode(ImplicitsEnabled)
     library version: version (unknown)
    compiler version: version 3.8.0-RC1-bin-20250819-1f13619-NIGHTLY-git-1f13619
            settings: -classpath /Users/wmazur/Library/Caches/Coursier/v1/https/repo.scala-lang.org/artifactory/maven-nightlies/org/scala-lang/scala3-library_3/3.8.0-RC1-bin-20250819-1f13619-NIGHTLY/scala3-library_3-3.8.0-RC1-bin-20250819-1f13619-NIGHTLY.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo.scala-lang.org/artifactory/maven-nightlies/org/scala-lang/scala-library/3.8.0-RC1-bin-20250819-1f13619-NIGHTLY/scala-library-3.8.0-RC1-bin-20250819-1f13619-NIGHTLY.jar -d /Users/wmazur/projects/scala/community-build3/.scala-build/community-build3_484a8f3fc4-9d23cdd7be/classes/main -sourceroot /Users/wmazur/projects/scala/community-build3

Exception in thread "main" java.lang.AssertionError: assertion failed: orphan parameter reference: TermParamRef(table)
        at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:10)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleNewType(TreePickler.scala:318)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleType(TreePickler.scala:183)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleExternalRef$1(TreePickler.scala:224)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleNewType(TreePickler.scala:245)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleType(TreePickler.scala:183)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:454)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:725)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$21(TreePickler.scala:740)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:337)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:740)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTpt(TreePickler.scala:352)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$4(TreePickler.scala:534)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:337)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:534)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:519)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleNewType(TreePickler.scala:286)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleType(TreePickler.scala:183)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleNewType$$anonfun$2(TreePickler.scala:204)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:337)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleNewType(TreePickler.scala:204)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleType(TreePickler.scala:183)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:643)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:598)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$7(TreePickler.scala:594)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:337)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:594)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTreeUnlessEmpty(TreePickler.scala:356)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleDef(TreePickler.scala:390)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:647)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$6(TreePickler.scala:571)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:337)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:571)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTreeUnlessEmpty(TreePickler.scala:356)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleDef(TreePickler.scala:390)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:662)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleStats$$anonfun$2(TreePickler.scala:423)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:337)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleStats(TreePickler.scala:423)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:698)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleDef(TreePickler.scala:381)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:664)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleStats$$anonfun$2(TreePickler.scala:423)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:337)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleStats(TreePickler.scala:423)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:714)
        at dotty.tools.dotc.core.tasty.TreePickler.pickle$$anonfun$1(TreePickler.scala:946)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:337)
        at dotty.tools.dotc.core.tasty.TreePickler.pickle(TreePickler.scala:944)
        at dotty.tools.dotc.transform.Pickler.run$$anonfun$1$$anonfun$1(Pickler.scala:306)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:337)
        at dotty.tools.dotc.transform.Pickler.run$$anonfun$1(Pickler.scala:279)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:337)
        at dotty.tools.dotc.transform.Pickler.run(Pickler.scala:278)
        at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:383)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:337)
        at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:376)
        at dotty.tools.dotc.transform.Pickler.runPhase$1(Pickler.scala:392)
        at dotty.tools.dotc.transform.Pickler.runOn(Pickler.scala:398)
        at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:380)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1327)
        at dotty.tools.dotc.Run.runPhases$1(Run.scala:373)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1$$anonfun$2(Run.scala:420)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1$$anonfun$adapted$1(Run.scala:420)
        at scala.Function0.apply$mcV$sp(Function0.scala:45)
        at dotty.tools.dotc.Run.showProgress(Run.scala:482)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:420)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:432)
        at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:69)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:432)
        at dotty.tools.dotc.Run.compileSources(Run.scala:319)
        at dotty.tools.dotc.Run.compile(Run.scala:304)
        at dotty.tools.dotc.Driver.doCompile(Driver.scala:37)
        at dotty.tools.dotc.Driver.process(Driver.scala:201)
        at dotty.tools.dotc.Driver.process(Driver.scala:169)
        at dotty.tools.dotc.Driver.process(Driver.scala:181)
        at dotty.tools.dotc.Driver.main(Driver.scala:211)
        at dotty.tools.dotc.Main.main(Main.scala)
Compilation failed

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions