sbt / zinc

Scala incremental compiler library, used by sbt and other build tools
Apache License 2.0
335 stars 121 forks source link

MatchError in ApiPhase #963

Closed dwijnand closed 1 month ago

dwijnand commented 3 years ago

steps

Sorry, I don't have exact steps, but after this happening a few times in a row in the same hour I thought I'd still report it to get the ball rolling. Basically I rebased a branch and compiled...

problem

[error] ## Exception when compiling 566 sources to /d/scala/build/quick/classes/library
[error] scala.MatchError: /d/scala/src/library/scala/collection/Seq.scala (of class scala.reflect.io.PlainFile)
[error] xsbt.API$ApiPhase.processScalaUnit(API.scala:62)
[error] xsbt.API$ApiPhase.processUnit(API.scala:57)
[error] xsbt.API$ApiPhase.apply(API.scala:53)
[error] scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:454)
[error] scala.tools.nsc.Global$GlobalPhase.run(Global.scala:401)
[error] xsbt.API$ApiPhase.run(API.scala:35)
[error] scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1515)
[error] scala.tools.nsc.Global$Run.compileUnits(Global.scala:1499)
[error] scala.tools.nsc.Global$Run.compileSources(Global.scala:1491)
[error] scala.tools.nsc.Global$Run.compileFiles(Global.scala:1605)
[error] xsbt.CachedCompiler0.run(CompilerBridge.scala:163)
[error] xsbt.CachedCompiler0.run(CompilerBridge.scala:134)
[error] xsbt.CompilerBridge.run(CompilerBridge.scala:39)
[error] sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:92)

expectation

Non-partial pattern matches...

notes

After a rm build/quick/classes/library/scala/collection/Seq* it fixed it self, thankfully:

> mimaReportBinaryIssues
[info] root: mimaPreviousArtifacts not set, not analyzing binary compatibility
[info] running scala.tools.docutil.ManMaker "fsc, scala, scalac, scaladoc, scalap" /d/scala/target/scalaDist/resource_managed/main/doc/tools /d/scala/target/scalaDist/resource_managed/main/genman
[info] compiling 11 Scala sources to /d/scala/build/quick/classes/library ...
[info] compiling 17 Scala sources to /d/scala/build/quick/classes/library ...
[info] compiling 2 Scala sources to /d/scala/build/quick/classes/reflect ...
[info] compiling 7 Scala sources to /d/scala/build/quick/classes/compiler ...
[error] scala-library: Failed binary compatibility check against org.scala-lang:scala-library:2.13.4! Found 31 potential problems (filtered 1)
eed3si9n commented 3 years ago

PlainFile vs virtual file it seems:

https://github.com/sbt/zinc/blob/39292eea5a7ab0ba31371af5616fa66486f6f378/internal/compiler-bridge/src/main/scala/xsbt/API.scala#L62

som-snytt commented 2 years ago

Me too.

sbt:root> junit/testOnly test.scala.sys.process.ProcessTest
[info] compiling 3 Scala sources to /home/amarki/projects/scala/build/quick/classes/library ...
[error] ## Exception when compiling 569 sources to /home/amarki/projects/scala/build/quick/classes/library
[error] scala.MatchError: /home/amarki/projects/scala/src/library/scala/sys/process/ProcessBuilder.scala (of class scala.reflect.io.PlainFile)
[error] xsbt.API$ApiPhase.processScalaUnit(API.scala:62)
[error] xsbt.API$ApiPhase.processUnit(API.scala:57)
[error] xsbt.API$ApiPhase.apply(API.scala:53)
[error] scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:467)
[error] scala.tools.nsc.Global$GlobalPhase.run(Global.scala:414)
[error] xsbt.API$ApiPhase.run(API.scala:35)
[error] scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1530)
[error] scala.tools.nsc.Global$Run.compileUnits(Global.scala:1514)
[error] scala.tools.nsc.Global$Run.compileSources(Global.scala:1506)
[error] scala.tools.nsc.Global$Run.compileFiles(Global.scala:1619)
[error] xsbt.CachedCompiler0.run(CompilerBridge.scala:163)

Restarting sbt didn't help, but taking the hint, deleting the package classes worked. I'm pretty sure it started after an edit of the source file.

som-snytt commented 2 years ago

Tonight my me-too moment was also with Seq.scala.

One may ask, well how often does one edit Seq.scala. Actually, I was editing Iterator.scala too.