Skip to content

Quoted types fail unpickling #3823

Closed
Closed
@nicolasstucki

Description

@nicolasstucki

The following code fails when running the unpickling the quote inside the show

import dotty.tools.dotc.quoted.Runners._
import scala.quoted._
object Test {
  def main(args: Array[String]): Unit = {
    def f[T](x: Expr[T])(t: Type[T]) = '{//'
      val z: t.unary_~ = ~x
    }
    println(f('(2))('[Int]).show)
  }
}

It fails with

Caused by: scala.MatchError: 255 (of class java.lang.Integer)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthType$1(TreeUnpickler.scala:231)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readType(TreeUnpickler.scala:361)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTpt(TreeUnpickler.scala:1057)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readNewDef(TreeUnpickler.scala:690)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readIndexedDef(TreeUnpickler.scala:635)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readIndexedStat(TreeUnpickler.scala:813)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.$anonfun$readIndexedStats$1(TreeUnpickler.scala:851)
	at dotty.tools.dotc.core.tasty.TastyReader.until(TastyReader.scala:125)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readIndexedStats(TreeUnpickler.scala:851)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readStats(TreeUnpickler.scala:855)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readBlock$1(TreeUnpickler.scala:939)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthTerm$1(TreeUnpickler.scala:962)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTerm(TreeUnpickler.scala:1047)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.$anonfun$readNewDef$4(TreeUnpickler.scala:656)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$LazyReader.complete(TreeUnpickler.scala:1119)
	at dotty.tools.dotc.ast.Trees$WithLazyField.forceIfLazy(Trees.scala:800)
	at dotty.tools.dotc.ast.Trees$WithLazyField.forceIfLazy$(Trees.scala:798)
	at dotty.tools.dotc.ast.Trees$ValDef.forceIfLazy(Trees.scala:656)
	at dotty.tools.dotc.ast.Trees$ValOrDefDef.rhs(Trees.scala:346)
	at dotty.tools.dotc.ast.Trees$ValOrDefDef.rhs$(Trees.scala:346)
	at dotty.tools.dotc.ast.Trees$ValDef.rhs(Trees.scala:656)
	at dotty.tools.dotc.core.quoted.PickledQuotes$.unpickleQuote(PickledQuotes.scala:45)
	at dotty.tools.dotc.core.quoted.PickledQuotes$.quotedToTree(PickledQuotes.scala:35)
	at dotty.tools.dotc.quoted.ExprCompiler$ExprFrontend.$anonfun$runOn$1(ExprCompiler.scala:61)
	at scala.collection.immutable.List.map(List.scala:283)
	at dotty.tools.dotc.quoted.ExprCompiler$ExprFrontend.runOn(ExprCompiler.scala:57)
	at dotty.tools.dotc.Run.$anonfun$compileUnits$3(Run.scala:125)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.util.Stats$.trackTime(Stats.scala:47)
	at dotty.tools.dotc.Run.$anonfun$compileUnits$2(Run.scala:123)
	at dotty.tools.dotc.Run.$anonfun$compileUnits$2$adapted(Run.scala:121)
	at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:32)
	at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:29)
	at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:191)
	at dotty.tools.dotc.Run.runPhases$1(Run.scala:121)
	at dotty.tools.dotc.Run.$anonfun$compileUnits$1(Run.scala:141)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:88)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:107)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:99)
	at dotty.tools.dotc.quoted.ExprCompiler$ExprRun.compileExpr(ExprCompiler.scala:91)
	at dotty.tools.dotc.quoted.QuoteDriver.show(QuoteDriver.scala:42)
	at dotty.tools.dotc.quoted.Runners$$anon$1.show(Runners.scala:27)
	at scala.quoted.Expr.show(Expr.scala:8)
...

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions