Skip to content

error when pickling tree: assertion failed: method $anonfun #15786

Open
@theosotr

Description

@theosotr

Compiler version

Scala compiler version 3.1.3 -- Copyright 2002-2022, LAMP/EPFL

Minimized code

class A(val f: () => Int) {
  def mA(p: Int = 0): Int = p
}

trait B {
  def mB(p1: Int): Unit
}

class C[T](val f1: B, val f2: T)

val f = new A(() => {
  val x: B = null
  C[Int](x, 0).f1.mB(1);
  1
}).mA()

Output

exception occurred while compiling Main.scala
java.lang.AssertionError: assertion failed: method $anonfun while compiling Main.scala
Exception in thread "main" java.lang.AssertionError: assertion failed: method $anonfun
        at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleDef(TreePickler.scala:324)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:559)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$9$$anonfun$1(TreePickler.scala:468)
        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:333)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$9(TreePickler.scala:468)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$adapted$8(TreePickler.scala:468)
        at scala.Function0.apply$mcV$sp(Function0.scala:39)
        at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:55)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:468)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$3$$anonfun$1(TreePickler.scala:427)
        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:333)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$3(TreePickler.scala:427)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$adapted$3(TreePickler.scala:428)
        at scala.Function0.apply$mcV$sp(Function0.scala:39)
        at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:55)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:428)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:409)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$3$$anonfun$1(TreePickler.scala:427)
        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:333)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$3(TreePickler.scala:427)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$adapted$3(TreePickler.scala:428)
        at scala.Function0.apply$mcV$sp(Function0.scala:39)
        at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:55)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:428)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTreeUnlessEmpty(TreePickler.scala:318)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleDef$$anonfun$1(TreePickler.scala:334)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleDef$$anonfun$adapted$1(TreePickler.scala:336)
        at scala.Function0.apply$mcV$sp(Function0.scala:39)
        at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:55)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleDef(TreePickler.scala:336)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:544)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleStats$$anonfun$2(TreePickler.scala:359)
        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:333)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleStats(TreePickler.scala:359)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$26(TreePickler.scala:585)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$adapted$24(TreePickler.scala:586)
        at scala.Function0.apply$mcV$sp(Function0.scala:39)
        at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:55)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:586)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleDef$$anonfun$1(TreePickler.scala:331)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleDef$$anonfun$adapted$1(TreePickler.scala:336)
        at scala.Function0.apply$mcV$sp(Function0.scala:39)
        at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:55)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleDef(TreePickler.scala:336)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:561)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleStats$$anonfun$2(TreePickler.scala:359)
        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:333)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleStats(TreePickler.scala:359)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$29(TreePickler.scala:601)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$adapted$27(TreePickler.scala:601)
        at scala.Function0.apply$mcV$sp(Function0.scala:39)
        at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:55)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:601)
        at dotty.tools.dotc.core.tasty.TreePickler.pickle$$anonfun$1(TreePickler.scala:772)
        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:333)
        at dotty.tools.dotc.core.tasty.TreePickler.pickle(TreePickler.scala:772)
        at dotty.tools.dotc.transform.Pickler.run$$anonfun$1$$anonfun$1(Pickler.scala:72)
        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:333)
        at dotty.tools.dotc.transform.Pickler.run$$anonfun$1(Pickler.scala:109)
        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:333)
        at dotty.tools.dotc.transform.Pickler.run(Pickler.scala:109)
        at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:311)
        at scala.collection.immutable.List.map(List.scala:246)
        at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:312)
        at dotty.tools.dotc.transform.Pickler.runOn(Pickler.scala:114)
        at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:225)
        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:1328)
        at dotty.tools.dotc.Run.runPhases$1(Run.scala:236)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:244)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:253)
        at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:68)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:253)
        at dotty.tools.dotc.Run.compileSources(Run.scala:186)
        at dotty.tools.dotc.Run.compile(Run.scala:170)
        at dotty.tools.dotc.Driver.doCompile(Driver.scala:35)
        at dotty.tools.dotc.Driver.process(Driver.scala:195)
        at dotty.tools.dotc.Driver.process(Driver.scala:163)
        at dotty.tools.dotc.Driver.process(Driver.scala:175)
        at dotty.tools.dotc.Driver.main(Driver.scala:205)
        at dotty.tools.MainGenericCompiler$.run$1(MainGenericCompiler.scala:162)
        at dotty.tools.MainGenericCompiler$.main(MainGenericCompiler.scala:186)
        at dotty.tools.MainGenericCompiler.main(MainGenericCompiler.scala)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions