-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
Description
To reproduce, compile with dotc -Ytest-pickler -color:never
.
trait Duplicate[T <: Tuple] {
type Res <: Tuple
def apply(t: T): Res
}
object Duplicate {
import Tuple.{ Head, Tail }
type Aux[T <: Tuple, R] = Duplicate[T] { type Res = R }
given [T <: NonEmptyTuple, TD <: Tuple] as Aux[T, (Head[T], Head[T]) *: TD]
given (td: Aux[Tail[T], TD]) = new Duplicate[T] {
type Res = (Head[T], Head[T]) *: TD
def apply(t: T): Res = (t.head, t.head) *: td(t.tail)
}
given as Aux[Unit, Unit] = new Duplicate[Unit] {
type Res = Unit
def apply(t: Unit): Unit = ()
}
}
def (x: T) duplicate[T <: Tuple, R] given (d: Duplicate.Aux[T, R]): R = d(x)
val x: (1, 2, 3) = (1, 2, 3)
val z: ((1, 1), (2, 2), (3, 3)) = x.duplicate
Crash
exception occurred while compiling ../pg/Main.scala
stale symbol; module class Main$package$#2546 in module class <empty>, defined in Period(1..9, run = 2), is referred to in run Period(1..1, run = 3)
class dotty.tools.dotc.reporting.diagnostic.messages$Error at ?: pickling difference for module class Main$package$ in ../pg/Main.scala, for details:
diff before-pickling.txt after-pickling.txt while compiling ../pg/Main.scala
Exception in thread "main" class dotty.tools.dotc.reporting.diagnostic.messages$Error at ?: pickling difference for module class Main$package$ in ../pg/Main.scala, for details:
diff before-pickling.txt after-pickling.txt
at dotty.tools.dotc.reporting.Reporting.error(Reporter.scala:137)
at dotty.tools.dotc.core.Contexts$Context.error(Contexts.scala:71)
at dotty.tools.dotc.transform.Pickler.testSame(Pickler.scala:119)
at dotty.tools.dotc.transform.Pickler.testUnpickler$$anonfun$4(Pickler.scala:111)
at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at scala.collection.TraversableLike$WithFilter.$anonfun$foreach$1(TraversableLike.scala:792)
at scala.collection.mutable.HashMap.$anonfun$foreach$1(HashMap.scala:149)
at scala.collection.mutable.HashTable.foreachEntry(HashTable.scala:237)
at scala.collection.mutable.HashTable.foreachEntry$(HashTable.scala:230)
at scala.collection.mutable.HashMap.foreachEntry(HashMap.scala:44)
at scala.collection.mutable.HashMap.foreach(HashMap.scala:149)
at scala.collection.TraversableLike$WithFilter.foreach(TraversableLike.scala:791)
at dotty.tools.dotc.transform.Pickler.testUnpickler(Pickler.scala:112)
at dotty.tools.dotc.transform.Pickler.runOn(Pickler.scala:95)
at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:158)
at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:36)
at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:33)
at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:198)
at dotty.tools.dotc.Run.runPhases$5(Run.scala:170)
at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:178)
at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:65)
at dotty.tools.dotc.Run.compileUnits(Run.scala:185)
at dotty.tools.dotc.Run.compileSources(Run.scala:120)
at dotty.tools.dotc.Run.compile(Run.scala:104)
at dotty.tools.dotc.Driver.doCompile(Driver.scala:35)
at dotty.tools.dotc.Driver.process(Driver.scala:180)
at dotty.tools.dotc.Driver.process(Driver.scala:149)
at dotty.tools.dotc.Driver.process(Driver.scala:161)
at dotty.tools.dotc.Driver.main(Driver.scala:188)
at dotty.tools.dotc.Main.main(Main.scala)
So basically, a *: b *: Unit
gets messed up to (a, b)
.