Skip to content

Quoted matching with abstract type leads to unresolved symbols when pickling #9465

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
szeiger opened this issue Jul 29, 2020 · 1 comment · Fixed by #9508
Closed

Quoted matching with abstract type leads to unresolved symbols when pickling #9465

szeiger opened this issue Jul 29, 2020 · 1 comment · Fixed by #9508
Assignees

Comments

@szeiger
Copy link
Contributor

szeiger commented Jul 29, 2020

This crashes the compiler. Tested with 0.25.0 and 0.26.0-RC1.

Minimized code

import scala.quoted._

sealed trait Coll[A] {
  type C[X] // must be abstract
  def map[B]: C[Any] // needs both the type param and a return type that refers to C 
}

object QuoteTest {
  def compile[T : Type](expr: Expr[T])(using QuoteContext): Expr[Any] = expr match {
    case '{ ($coll: Coll[$foo]).map[$b] } => '{ null }
  }
}

Output

[error] java.lang.AssertionError: assertion failed: unresolved symbols: value foo(line 9) when pickling /mnt/c/Users/szeiger/code/dottyquery/src/main/scala/QuoteTest.scala
[error] dotty.DottyPredef$.assertFail(DottyPredef.scala:17)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickle(TreePickler.scala:738)
[error] dotty.tools.dotc.transform.Pickler.run$$anonfun$9$$anonfun$8(Pickler.scala:63)
[error] dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.immutable.List.foreach(List.scala:333)
[error] dotty.tools.dotc.transform.Pickler.run$$anonfun$1(Pickler.scala:87)
[error] dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.immutable.List.foreach(List.scala:333)
[error] dotty.tools.dotc.transform.Pickler.run(Pickler.scala:87)
[error] dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:318)
[error] scala.collection.immutable.List.map(List.scala:246)
[error] dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:319)
[error] dotty.tools.dotc.transform.Pickler.runOn(Pickler.scala:91)
[error] dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:180)
[error] dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
[error] dotty.tools.dotc.Run.runPhases$5(Run.scala:190)
[error] dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:198)
[error] dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
[error] dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:64)
[error] dotty.tools.dotc.Run.compileUnits(Run.scala:205)
[error] dotty.tools.dotc.Run.compileSources(Run.scala:142)
[error] dotty.tools.dotc.Run.compile(Run.scala:124)
[error] dotty.tools.dotc.Driver.doCompile(Driver.scala:38)
[error] dotty.tools.dotc.Driver.process(Driver.scala:194)
[error] dotty.tools.dotc.Main.process(Main.scala)
@nicolasstucki
Copy link
Contributor

Slight minimization

import scala.quoted._

trait Coll[A] {
  type C[X] // must be abstract
  def map[B]: C[Any] // needs both the type param and a return type that refers to C
}

object QuoteTest {
  def compile(expr: Expr[Any])(using QuoteContext): Expr[Any] = expr match {
    case '{ (??? : Coll[$y]).map[$b] } => ???
  }
}

nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Aug 6, 2020
@nicolasstucki nicolasstucki linked a pull request Aug 6, 2020 that will close this issue
nicolasstucki added a commit that referenced this issue Aug 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants