Scalac crash in BCodeSkelBuilder - Error while emitting
benwaffle opened this issue · 0 comments
benwaffle commented
Compiling this file:
package example
import com.softwaremill.quicklens.{ModifyPimp, QuicklensEach}
object Hello extends Greeting with App {
case class Foo(field: String)
def doit = {
val lang2 = "hey"
Seq(Foo("asdf"))
.modify(_.eachWhere(_.field != lang2).field)
.setTo(lang2)
}
println(greeting)
}
trait Greeting {
lazy val greeting: String = "hello"
}
results in:
sbt:bug> run
[error] Error while emitting Hello.scala
[error] value lang2
[error] one error found
[error] (Compile / compileIncremental) Compilation failed
[error] Total time: 1 s, completed Apr 1, 2022, 4:13:28 PM
I'm not sure if this is a bug in quicklens or scalac.
You can use https://github.com/benwaffle/quicklens-scalac-bug to try it locally.
scalac debug output:
sbt:bug> set scalacOptions += "-Vdebug"
[info] Defining scalacOptions
[info] The new value will be used by Compile / scalacOptions
[info] Reapplying settings...
[info] set current project to bug (in build file:/Users/ben/Downloads/quicklens-bug/bug/)
sbt:bug> run
[info] compiling 1 Scala source to /Users/ben/Downloads/quicklens-bug/bug/target/scala-2.13/classes ..
[info] [running phase parser on Hello.scala]
[info] [running phase namer on Hello.scala]
[info] [running phase packageobjects on Hello.scala]
[info] [running phase typer on Hello.scala]
[info] [running phase superaccessors on Hello.scala]
[info] [running phase extmethods on Hello.scala]
[info] [running phase pickler on Hello.scala]
[info] [running phase xsbt-api on Hello.scala]
[info] [running phase xsbt-dependency on Hello.scala]
[info] [running phase refchecks on Hello.scala]
[info] [running phase patmat on Hello.scala]
[info] [running phase uncurry on Hello.scala]
[info] [running phase fields on Hello.scala]
[info] [running phase tailcalls on Hello.scala]
[info] [running phase specialize on Hello.scala]
[info] [running phase explicitouter on Hello.scala]
[info] [running phase erasure on Hello.scala]
[info] [running phase posterasure on Hello.scala]
[info] [running phase lambdalift on Hello.scala]
[info] [running phase constructors on Hello.scala]
[info] [running phase flatten on Hello.scala]
[info] [running phase mixin on Hello.scala]
[info] [running phase cleanup on Hello.scala]
[info] [running phase delambdafy on Hello.scala]
[info] [running phase jvm on Hello.scala]
java.util.NoSuchElementException: value lang2
| => rat scala.collection.mutable.AnyRefMap$ExceptionDefault.apply(AnyRefMap.scala:508)
at scala.collection.mutable.AnyRefMap$ExceptionDefault.apply(AnyRefMap.scala:507)
at scala.collection.mutable.AnyRefMap.apply(AnyRefMap.scala:207)
at scala.tools.nsc.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder$locals$.load(BCodeSkelBuilder.scala:428)
at scala.tools.nsc.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoad(BCodeBodyBuilder.scala:375)
at scala.tools.nsc.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.$anonfun$genLoadArguments$1(BCodeBodyBuilder.scala:940)
at scala.tools.nsc.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoadArguments(BCodeBodyBuilder.scala:940)
at scala.tools.nsc.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genApply(BCodeBodyBuilder.scala:632)
at scala.tools.nsc.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoad(BCodeBodyBuilder.scala:317)
at scala.tools.nsc.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genBlock(BCodeBodyBuilder.scala:819)
at scala.tools.nsc.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoad(BCodeBodyBuilder.scala:387)
at scala.tools.nsc.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.$anonfun$genLoadArguments$1(BCodeBodyBuilder.scala:940)
at scala.tools.nsc.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoadArguments(BCodeBodyBuilder.scala:940)
at scala.tools.nsc.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genApply(BCodeBodyBuilder.scala:670)
at scala.tools.nsc.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoad(BCodeBodyBuilder.scala:317)
at scala.tools.nsc.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoad(BCodeBodyBuilder.scala:270)
at scala.tools.nsc.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoadQualifier(BCodeBodyBuilder.scala:905)
at scala.tools.nsc.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genTypeApply$1(BCodeBodyBuilder.scala:547)
at scala.tools.nsc.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genApply(BCodeBodyBuilder.scala:578)
at scala.tools.nsc.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoad(BCodeBodyBuilder.scala:317)
at scala.tools.nsc.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.emitNormalMethodBody$1(BCodeSkelBuilder.scala:640)
at scala.tools.nsc.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.genDefDef(BCodeSkelBuilder.scala:672)
at scala.tools.nsc.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.gen(BCodeSkelBuilder.scala:545)
at scala.tools.nsc.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.gen(BCodeSkelBuilder.scala:547)
at scala.tools.nsc.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.genPlainClass(BCodeSkelBuilder.scala:157)
at scala.tools.nsc.backend.jvm.CodeGen.genClass(CodeGen.scala:76)
at scala.tools.nsc.backend.jvm.CodeGen.genClassDef$1(CodeGen.scala:40)
at scala.tools.nsc.backend.jvm.CodeGen.$anonfun$genUnit$3(CodeGen.scala:60)
at scala.tools.nsc.backend.jvm.CodeGen.genClassDefs$1(CodeGen.scala:60)
at scala.tools.nsc.backend.jvm.CodeGen.$anonfun$genUnit$2(CodeGen.scala:59)
at scala.tools.nsc.backend.jvm.CodeGen.genClassDefs$1(CodeGen.scala:59)
at scala.tools.nsc.backend.jvm.CodeGen.$anonfun$genUnit$4(CodeGen.scala:65)
at scala.tools.nsc.backend.jvm.CodeGen.genUnit(CodeGen.scala:65)
at scala.tools.nsc.backend.jvm.GenBCode$BCodePhase.apply(GenBCode.scala:74)
at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:459)
at scala.tools.nsc.Global$GlobalPhase.run(Global.scala:406)
at scala.tools.nsc.backend.jvm.GenBCode$BCodePhase.super$run(GenBCode.scala:80)
at scala.tools.nsc.backend.jvm.GenBCode$BCodePhase.$anonfun$run$1(GenBCode.scala:80)
at scala.tools.nsc.backend.jvm.GenBCode$BCodePhase.run(GenBCode.scala:78)
at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1524)
at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1508)
at scala.tools.nsc.Global$Run.compileSources(Global.scala:1500)
at scala.tools.nsc.Global$Run.compileFiles(Global.scala:1613)
at xsbt.CachedCompiler0.run(CompilerBridge.scala:163)
at xsbt.CachedCompiler0.run(CompilerBridge.scala:134)
at xsbt.CompilerBridge.run(CompilerBridge.scala:39)
at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:91)
at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$7(MixedAnalyzingCompiler.scala:192)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
at sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:247)
at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:182)
at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4$adapted(MixedAnalyzingCompiler.scala:163)
at sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:239)
at sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:163)
at sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:210)
at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:528)
at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:528)
at sbt.internal.inc.Incremental$.$anonfun$apply$5(Incremental.scala:177)
at sbt.internal.inc.Incremental$.$anonfun$apply$5$adapted(Incremental.scala:175)
at sbt.internal.inc.Incremental$$anon$2.run(Incremental.scala:461)
at sbt.internal.inc.IncrementalCommon$CycleState.next(IncrementalCommon.scala:116)
at sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:56)
at sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:52)
at sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:263)
at sbt.internal.inc.Incremental$.$anonfun$incrementalCompile$8(Incremental.scala:416)
at sbt.internal.inc.Incremental$.withClassfileManager(Incremental.scala:503)
at sbt.internal.inc.Incremental$.incrementalCompile(Incremental.scala:403)
at sbt.internal.inc.Incremental$.apply(Incremental.scala:169)
at sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:528)
at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:482)
at sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:332)
at sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:420)
at sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:137)
at sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:2366)
at sbt.Defaults$.$anonfun$compileIncrementalTask$2(Defaults.scala:2316)
at sbt.internal.server.BspCompileTask$.$anonfun$compute$1(BspCompileTask.scala:30)
at sbt.internal.io.Retry$.apply(Retry.scala:46)
at sbt.internal.io.Retry$.apply(Retry.scala:28)
at sbt.internal.io.Retry$.apply(Retry.scala:23)
at sbt.internal.server.BspCompileTask$.compute(BspCompileTask.scala:30)
at sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:2314)
at scala.Function1.$anonfun$compose$1(Function1.scala:49)
at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
at sbt.std.Transform$$anon$4.work(Transform.scala:68)
at sbt.Execute.$anonfun$submit$2(Execute.scala:282)
at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23)
at sbt.Execute.work(Execute.scala:291)
at sbt.Execute.$anonfun$submit$1(Execute.scala:282)
at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
at sbt.CompletionService$$anon$2.call(CompletionService.scala:64)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
at java.base/java.lang.Thread.run(Thread.java:832)
[error] Error while emitting Hello.scala
[error] value lang2
[warn] !!! No enclosing class. Discarding dependency on package example (currentOwner = package class <root>).
[warn] one warning found
[error] one error found
[error] (Compile / compileIncremental) Compilation failed
[error] Total time: 3 s, completed Apr 1, 2022, 4:16:01 PM