Skip to content

MatchError: PolyType in TreePickler.pickleNewType #5638

@panacekcz

Description

@panacekcz

Happens when in a match, the result of unapply has a get method that has type parameters.

Code:

class Opt{
  def isEmpty: Boolean = false
  def get[T]: Int = 1
}
object Extract{
  def unapply(x: Int): Opt = new Opt
}
object O {
  def m(x: Int) = x match {
    case Extract(r) => r
  }   
}

Dotc output:

exception occurred while compiling Poly.scala
scala.MatchError: PolyType(List(T), List(TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Any))), TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),module scala),class Int)) (of class dotty.tools.dotc.core.Types$PolyType) while compiling Poly.scala
Exception in thread "main" scala.MatchError: PolyType(List(T), List(TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Any))), TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),module scala),class Int)) (of class dotty.tools.dotc.core.Types$PolyType)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleNewType(TreePickler.scala:155)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleType(TreePickler.scala:142)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:344)
	at dotty.tools.dotc.core.tasty.TreePickler.$anonfun$pickleTree$4(TreePickler.scala:383)
	at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:42)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:382)
	at dotty.tools.dotc.core.tasty.TreePickler.$anonfun$pickleTree$26(TreePickler.scala:474)
	at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:42)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:473)
	at dotty.tools.dotc.core.tasty.TreePickler.$anonfun$pickleTree$31(TreePickler.scala:488)
	at dotty.tools.dotc.core.tasty.TreePickler.$anonfun$pickleTree$31$adapted(TreePickler.scala:488)
	at scala.collection.immutable.List.foreach(List.scala:392)
	at dotty.tools.dotc.core.tasty.TreePickler.$anonfun$pickleTree$29(TreePickler.scala:488)
	at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:42)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:481)
	at dotty.tools.dotc.core.tasty.TreePickler.$anonfun$pickleTree$16(TreePickler.scala:446)
	at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:42)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:446)
	at dotty.tools.dotc.core.tasty.TreePickler.$anonfun$pickleTree$15(TreePickler.scala:442)
	at dotty.tools.dotc.core.tasty.TreePickler.$anonfun$pickleTree$15$adapted(TreePickler.scala:442)
	at scala.collection.immutable.List.foreach(List.scala:392)
	at dotty.tools.dotc.core.tasty.TreePickler.$anonfun$pickleTree$14(TreePickler.scala:442)
	at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:42)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:436)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTreeUnlessEmpty(TreePickler.scala:291)
	at dotty.tools.dotc.core.tasty.TreePickler.$anonfun$pickleDef$2(TreePickler.scala:304)
	at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:42)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleDef(TreePickler.scala:297)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:500)
	at dotty.tools.dotc.core.tasty.TreePickler.$anonfun$pickleStats$2(TreePickler.scala:325)
	at dotty.tools.dotc.core.tasty.TreePickler.$anonfun$pickleStats$2$adapted(TreePickler.scala:325)
	at scala.collection.immutable.List.foreach(List.scala:392)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleStats(TreePickler.scala:325)
	at dotty.tools.dotc.core.tasty.TreePickler.$anonfun$pickleTree$38(TreePickler.scala:531)
	at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:42)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:512)
	at dotty.tools.dotc.core.tasty.TreePickler.$anonfun$pickleDef$2(TreePickler.scala:301)
	at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:42)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleDef(TreePickler.scala:297)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:502)
	at dotty.tools.dotc.core.tasty.TreePickler.$anonfun$pickleStats$2(TreePickler.scala:325)
	at dotty.tools.dotc.core.tasty.TreePickler.$anonfun$pickleStats$2$adapted(TreePickler.scala:325)
	at scala.collection.immutable.List.foreach(List.scala:392)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleStats(TreePickler.scala:325)
	at dotty.tools.dotc.core.tasty.TreePickler.$anonfun$pickleTree$41(TreePickler.scala:538)
	at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:42)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:538)
	at dotty.tools.dotc.core.tasty.TreePickler.$anonfun$pickle$1(TreePickler.scala:687)
	at dotty.tools.dotc.core.tasty.TreePickler.$anonfun$pickle$1$adapted(TreePickler.scala:687)
	at scala.collection.immutable.List.foreach(List.scala:392)
	at dotty.tools.dotc.core.tasty.TreePickler.pickle(TreePickler.scala:687)
	at dotty.tools.dotc.transform.Pickler.$anonfun$run$3(Pickler.scala:60)
	at dotty.tools.dotc.transform.Pickler.$anonfun$run$3$adapted(Pickler.scala:53)
	at scala.collection.immutable.List.foreach(List.scala:392)
	at dotty.tools.dotc.transform.Pickler.$anonfun$run$2(Pickler.scala:53)
	at dotty.tools.dotc.transform.Pickler.$anonfun$run$2$adapted(Pickler.scala:52)
	at scala.collection.immutable.List.foreach(List.scala:392)
	at dotty.tools.dotc.transform.Pickler.run(Pickler.scala:52)
	at dotty.tools.dotc.core.Phases$Phase.$anonfun$runOn$1(Phases.scala:297)
	at scala.collection.immutable.List.map(List.scala:286)
	at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:295)
	at dotty.tools.dotc.transform.Pickler.runOn(Pickler.scala:87)
	at dotty.tools.dotc.Run.$anonfun$compileUnits$3(Run.scala:172)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
	at dotty.tools.dotc.util.Stats$.trackTime(Stats.scala:49)
	at dotty.tools.dotc.Run.$anonfun$compileUnits$2(Run.scala:169)
	at dotty.tools.dotc.Run.$anonfun$compileUnits$2$adapted(Run.scala:167)
	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$1(Run.scala:167)
	at dotty.tools.dotc.Run.$anonfun$compileUnits$1(Run.scala:192)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:90)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:147)
	at dotty.tools.dotc.Run.compileSources(Run.scala:134)
	at dotty.tools.dotc.Run.compile(Run.scala:118)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:33)
	at dotty.tools.dotc.Driver.process(Driver.scala:166)
	at dotty.tools.dotc.Driver.process(Driver.scala:135)
	at dotty.tools.dotc.Driver.process(Driver.scala:147)
	at dotty.tools.dotc.Driver.main(Driver.scala:174)
	at dotty.tools.dotc.Main.main(Main.scala)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions