Closed
Description
Compiler version
3.1.2 and current main branch
Minimized code
trait Pack:
type Reader
object PackTest extends Pack:
type Reader
object Init:
def get[P <: Pack](param: P): param.Reader = ???
trait Test:
val pack: PackTest.type = PackTest
val reader = Init.get[pack.type](pack)
Output (click arrow to expand)
error when pickling type param.type
error when pickling type param.Reader
error when pickling tree param.Reader
error when pickling tree val reader: param.Reader = Init.get[this.pack.type](this.pack)
error when pickling tree () extends Object {
val pack: PackTest.type = PackTest
val reader: param.Reader = Init.get[this.pack.type](this.pack)
}
error when pickling tree @SourceFile("Test.scala") trait Test() extends Object {
val pack: PackTest.type = PackTest
val reader: param.Reader = Init.get[this.pack.type](this.pack)
}
error when pickling tree package <empty> {
@SourceFile("Test.scala") trait Test() extends Object {
val pack: PackTest.type = PackTest
val reader: param.Reader = Init.get[this.pack.type](this.pack)
}
}
exception occurred while compiling Test.scala
Exception in thread "main" java.lang.AssertionError: assertion failed: orphan parameter reference: TermParamRef(param)
java.lang.AssertionError: assertion failed: orphan parameter reference: TermParamRef(param) while compiling Test.scala
at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
at dotty.tools.dotc.core.tasty.TreePickler.pickleNewType(TreePickler.scala:288)
at dotty.tools.dotc.core.tasty.TreePickler.pickleType(TreePickler.scala:157)
at dotty.tools.dotc.core.tasty.TreePickler.pickleExternalRef$1(TreePickler.scala:197)
at dotty.tools.dotc.core.tasty.TreePickler.pickleNewType(TreePickler.scala:219)
at dotty.tools.dotc.core.tasty.TreePickler.pickleType(TreePickler.scala:157)
at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:603)
at dotty.tools.dotc.core.tasty.TreePickler.pickleTpt(TreePickler.scala:315)
at dotty.tools.dotc.core.tasty.TreePickler.pickleDef$$anonfun$1(TreePickler.scala:332)
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.dotc.Main.main(Main.scala)
As can be seen in the output, the type of reader
is param.Reader
whereas, I assume, the type should be this.pack.Reader
.