Pickler crashes with unresolved local type in closure
See original GitHub issueCompiler version
Fails in 3.1.1 Works in 3.1.2 Works In 3.1.3-RC4 Fails in 3.1.3-RC5 Fails in 3.2.0-RC1
Minimized code
trait MatchResult[+T]
@main def Test() = {
def convert[T <: Seq[_], U <: MatchResult[_]](fn: T => U)(implicit x: Seq[_] = Seq.empty): U = ???
def resultOf[T](v: T): MatchResult[T] = ???
convert { _ =>
type R = String
resultOf[R](???)
// this would not lead to crash:
// val x = resultOf[R](???)
// x
}
}
Output (click arrow to expand)
java.lang.AssertionError: assertion failed: unresolved symbols: type R (line 11) #6547 when pickling /home/wmazur/projects/virtuslab/community-build3/test.scala
at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
at dotty.tools.dotc.core.tasty.TreePickler.pickle(TreePickler.scala:783)
at dotty.tools.dotc.transform.Pickler.run$$anonfun$1$$anonfun$1(Pickler.scala:72)
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:110)
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:110)
at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:311)
at scala.collection.immutable.List.map(List.scala:246)
at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:312)
at dotty.tools.dotc.transform.Pickler.runOn(Pickler.scala:115)
at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:234)
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:1328)
at dotty.tools.dotc.Run.runPhases$1(Run.scala:245)
at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:253)
at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:262)
at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:68)
at dotty.tools.dotc.Run.compileUnits(Run.scala:262)
at dotty.tools.dotc.Run.compileSources(Run.scala:186)
at dotty.tools.dotc.Run.compile(Run.scala:170)
at dotty.tools.dotc.Driver.doCompile(Driver.scala:35)
at dotty.tools.xsbt.CompilerBridgeDriver.run(CompilerBridgeDriver.java:88)
at dotty.tools.xsbt.CompilerBridge.run(CompilerBridge.java:22)
at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:91)
at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.compileSources$1(BloopHighLevelCompiler.scala:133)
at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.$anonfun$compile$7(BloopHighLevelCompiler.scala:151)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.$anonfun$compile$1(BloopHighLevelCompiler.scala:71)
at bloop.tracing.BraveTracer.traceInternal(BraveTracer.scala:65)
at bloop.tracing.BraveTracer.trace(BraveTracer.scala:39)
at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.timed$1(BloopHighLevelCompiler.scala:70)
at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.$anonfun$compile$6(BloopHighLevelCompiler.scala:151)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
at monix.eval.internal.TaskRunLoop$.monix$eval$internal$TaskRunLoop$$loop$1(TaskRunLoop.scala:187)
at monix.eval.internal.TaskRunLoop$RestartCallback$1.onSuccess(TaskRunLoop.scala:119)
at monix.eval.Task$.$anonfun$forkedUnit$2(Task.scala:1463)
at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1395)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
Error: Unexpected error when compiling project_6d5831c594_6d5831c594-15348604ae: 'assertion failed: unresolved symbols: type R (line 11) #6547 when pickling /home/wmazur/projects/virtuslab/community-build3/test.scala'
Code after typer phase (click arrow to expand)
Differences in enclosing packages and imports originate from minimalizing issue in the original repo
package <empty> {
import util.WithTemporaryCollection.*
import org.specs2.matcher.MatchResult
final class ChangeStreamSpec() extends Object() {
def resultOf[T >: Nothing <: Any](v: T): org.specs2.matcher.MatchResult[T]
=
???
trait Coll() extends Object {}
def convert[T >: Nothing <: Seq[? >: Nothing <: Any],
U >: Nothing <: org.specs2.matcher.MatchResult[? >: Nothing <: Any]
](fn: T => U)(implicit x: Seq[ChangeStreamSpec.this.Coll]): U = ???
def convert$default$2[T >: Nothing <: Seq[? >: Nothing <: Any],
U >: Nothing <: org.specs2.matcher.MatchResult[? >: Nothing <: Any]
](fn: T => U): Seq[ChangeStreamSpec.this.Coll] @uncheckedVariance =
Seq.empty[ChangeStreamSpec.this.Coll]
{
val fn$1: Seq[?] => org.specs2.matcher.MatchResult[R] =
{
{
def $anonfun(_$1: Seq[?]): org.specs2.matcher.MatchResult[R] =
{
type R = String
this.resultOf[R](???):org.specs2.matcher.MatchResult[String]
}
closure($anonfun)
}
}
this.convert[Seq[?], org.specs2.matcher.MatchResult[R]](fn$1)(
this.convert$default$2[Seq[?], org.specs2.matcher.MatchResult[R]](fn$1)
)
}
}
}
Issue Analytics
- State:
- Created a year ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Compiler crashes on simple closure · Issue #62391 · apple/swift
The compiler crashes while compiling a simple closure returning an opaque return type. Maybe, this has to do with the fact that it...
Read more >Preventing Timing Problems When Using Closures
Making false assumptions about when a closure is called can lead to data inconsistency and app crashes. Understand the Results of Synchronous and...
Read more >Changelog — Python 3.11.1 documentation
gh-98692: Fix the Python Launcher for Windows ignoring unrecognized shebang lines instead of treating them as local paths.
Read more >Both directions of I-76 closed from Sterling to Nebraska border ...
#I76 eastbound: Road closed due to a crash between US 385 and the Nebraska Border. Closed due to multiple crashes and slide-offs http://co.c-tr....
Read more >Multiple crashes forced closure of I-90 near North Bend ...
The Washington State Department of Transportation (WSDOT) said it had to close eastbound lanes after several car crashes. Just a half hour later ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Seems like this started working after #14026.
The breakage between 3.1.3-RC4 and RC5 was caused by #15388
The corresponding PR #15343 is what broke it on
main
Hmm. Same result, but perhaps they’re different causes, different issue numbers.