Closed
Description
Since #13650, compiling perspective
results in a crash (it was disabled in the community build by 5793f90)
A self-contained version of the offending code is below.
/cc @Katrix
Compiler version
3.1.1-RC1-bin-SNAPSHOT-git-8c3e7a2
Minimized code
type Const[A] = [_] =>> A
type FunctionK[A[_], B[_]] = [Z] => A[Z] => B[Z]
type ~>:[A[_], B[_]] = FunctionK[A, B]
type ~>#:[F[_], R] = F ~>: Const[R]
type #~>#:[T, R] = Const[T] ~>: Const[R]
object FunctionK:
def liftConst[A, B](f: A => B): A #~>#: B = [Z] => (a: A) => f(a)
trait FoldableK[F[_[_], _]]:
extension[A[_], C](fa: F[A, C])
def foldMapK[B](f: A ~>#: B): B
extension[A, C](fa: F[Const[A], C])
def toListK: List[A] = fa.foldMapK(FunctionK.liftConst(List(_: A)))
Output (click arrow to expand)
error when pickling type Z
error when pickling type Const[List[A]][Z]
error when pickling tree Const[List[A]][Z]
error when pickling tree FoldableK.this.foldMapK[([_] =>> A), C](fa)[Const[List[A]][Z]]
error when pickling tree FoldableK.this.foldMapK[([_] =>> A), C](fa)[Const[List[A]][Z]](
FunctionK.liftConst[A, List[A]](
{
def $anonfun(_$11: A): List[A] = List.apply[A]([_$11:A : A]*)
closure($anonfun)
}
)
)
error when pickling tree extension [A >: Nothing <: Any, C >: Nothing <: Any](fa: FoldableK.this.F[Const[A], C]) def toListK: List[A] =
this.foldMapK[([_] =>> A), C](fa)[Const[List[A]][Z]](
FunctionK.liftConst[A, List[A]](
{
def $anonfun(_$11: A): List[A] = List.apply[A]([_$11:A : A]*)
closure($anonfun)
}
)
)
error when pickling tree [F[_[_ >: Nothing <: Any] >: Nothing <: Any, _ >: Nothing <: Any] >: Nothing <: Any]() extends Object {
F[_$7[_$8],_$9]
extension [A[_ >: Nothing <: Any] >: Nothing <: Any, C >: Nothing <: Any](fa: FoldableK.this.F[A, C]) def foldMapK[
B >: Nothing <: Any
](f: ~>#:[A, B]): B
extension [A >: Nothing <: Any, C >: Nothing <: Any](fa: FoldableK.this.F[Const[A], C]) def toListK: List[A] =
this.foldMapK[([_] =>> A), C](fa)[Const[List[A]][Z]](
FunctionK.liftConst[A, List[A]](
{
def $anonfun(_$11: A): List[A] = List.apply[A]([_$11:A : A]*)
closure($anonfun)
}
)
)
}
error when pickling tree @SourceFile("FoldableK.scala") trait FoldableK[F[_[_ >: Nothing <: Any] >: Nothing <: Any, _ >: Nothing <: Any] >: Nothing <: Any
]
() extends Object {
F[_$7[_$8],_$9]
extension [A[_ >: Nothing <: Any] >: Nothing <: Any, C >: Nothing <: Any](fa: FoldableK.this.F[A, C]) def foldMapK[
B >: Nothing <: Any
](f: ~>#:[A, B]): B
extension [A >: Nothing <: Any, C >: Nothing <: Any](fa: FoldableK.this.F[Const[A], C]) def toListK: List[A] =
this.foldMapK[([_] =>> A), C](fa)[Const[List[A]][Z]](
FunctionK.liftConst[A, List[A]](
{
def $anonfun(_$11: A): List[A] = List.apply[A]([_$11:A : A]*)
closure($anonfun)
}
)
)
}
error when pickling tree package <empty> {
@SourceFile("FoldableK.scala") trait FoldableK[
F[_[_ >: Nothing <: Any] >: Nothing <: Any, _ >: Nothing <: Any] >: Nothing <: Any
]() extends Object {
F[_$7[_$8],_$9]
extension [A[_ >: Nothing <: Any] >: Nothing <: Any, C >: Nothing <: Any](fa: FoldableK.this.F[A, C]) def foldMapK[
B >: Nothing <: Any
](f: ~>#:[A, B]): B
extension [A >: Nothing <: Any, C >: Nothing <: Any](fa: FoldableK.this.F[Const[A], C]) def toListK: List[A] =
this.foldMapK[([_] =>> A), C](fa)[Const[List[A]][Z]](
FunctionK.liftConst[A, List[A]](
{
def $anonfun(_$11: A): List[A] = List.apply[A]([_$11:A : A]*)
closure($anonfun)
}
)
)
}
}
exception occurred while compiling FoldableK.scala
java.lang.AssertionError: assertion failed: orphan parameter reference: TypeParamRef(Z) while compiling FoldableK.scala
Exception in thread "main" java.lang.AssertionError: assertion failed: orphan parameter reference: TypeParamRef(Z)
at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
at dotty.tools.dotc.core.tasty.TreePickler.pickleNewType(TreePickler.scala:289)
at dotty.tools.dotc.core.tasty.TreePickler.pickleType(TreePickler.scala:160)
at dotty.tools.dotc.core.tasty.TreePickler.pickleNewType$$anonfun$11$$anonfun$1(TreePickler.scala:181)
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.pickleNewType$$anonfun$2(TreePickler.scala:181)
at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:58)
at dotty.tools.dotc.core.tasty.TreePickler.pickleNewType(TreePickler.scala:181)
at dotty.tools.dotc.core.tasty.TreePickler.pickleType(TreePickler.scala:160)
at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:604)
at dotty.tools.dotc.core.tasty.TreePickler.pickleTpt(TreePickler.scala:316)
at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$39$$anonfun$1(TreePickler.scala:435)
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$4(TreePickler.scala:435)
at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:58)
at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:436)
at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$3(TreePickler.scala:427)
at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:58)
at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:429)
at dotty.tools.dotc.core.tasty.TreePickler.pickleTreeUnlessEmpty(TreePickler.scala:319)
at dotty.tools.dotc.core.tasty.TreePickler.pickleDef$$anonfun$1(TreePickler.scala:335)
at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:58)
at dotty.tools.dotc.core.tasty.TreePickler.pickleDef(TreePickler.scala:337)
at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:560)
at dotty.tools.dotc.core.tasty.TreePickler.pickleStats$$anonfun$2(TreePickler.scala:360)
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:360)
at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$26(TreePickler.scala:586)
at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:58)
at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:587)
at dotty.tools.dotc.core.tasty.TreePickler.pickleDef$$anonfun$1(TreePickler.scala:332)
at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:58)
at dotty.tools.dotc.core.tasty.TreePickler.pickleDef(TreePickler.scala:337)
at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:562)
at dotty.tools.dotc.core.tasty.TreePickler.pickleStats$$anonfun$2(TreePickler.scala:360)
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:360)
at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$29(TreePickler.scala:602)
at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:58)
at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:602)
at dotty.tools.dotc.core.tasty.TreePickler.pickle$$anonfun$1(TreePickler.scala:773)
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:773)
at dotty.tools.dotc.transform.Pickler.run$$anonfun$3$$anonfun$2(Pickler.scala:69)
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:106)
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:106)
at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:308)
at scala.collection.immutable.List.map(List.scala:246)
at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:309)
at dotty.tools.dotc.transform.Pickler.runOn(Pickler.scala:111)
at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:261)
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:1323)
at dotty.tools.dotc.Run.runPhases$5(Run.scala:272)
at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:280)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:68)
at dotty.tools.dotc.Run.compileUnits(Run.scala:289)
at dotty.tools.dotc.Run.compileSources(Run.scala:222)
at dotty.tools.dotc.Run.compile(Run.scala:206)
at dotty.tools.dotc.Driver.doCompile(Driver.scala:39)
at dotty.tools.dotc.Driver.process(Driver.scala:199)
at dotty.tools.dotc.Driver.process(Driver.scala:167)
at dotty.tools.dotc.Driver.process(Driver.scala:179)
at dotty.tools.dotc.Driver.main(Driver.scala:209)
at dotty.tools.dotc.Main.main(Main.scala)