Skip to content

Commit 2120cde

Browse files
committed
Make internal errors in incremental compilation into actual errors
Previously they were warnings, which means we could miss them in the CI.
1 parent 4b59e10 commit 2120cde

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package dotty.tools.dotc
22
package sbt
33

4+
import ExtractDependencies.internalError
45
import ast.{Positioned, Trees, tpd, untpd}
56
import core._
67
import core.Decorators._
@@ -30,7 +31,7 @@ import scala.collection.mutable
3031
*
3132
* See the documentation of `ExtractAPICollector`, `ExtractDependencies`,
3233
* `ExtractDependenciesCollector` and
33-
* http://www.scala-sbt.org/0.13/docs/Understanding-Recompilation.html for more
34+
* http://www.scala-sbt.org/1.x/docs/Understanding-Recompilation.html for more
3435
* information on incremental recompilation.
3536
*
3637
* The following flags affect this phase:
@@ -515,7 +516,7 @@ private class ExtractAPICollector(using Context) extends ThunkHolder {
515516
case tp: TypeVar =>
516517
apiType(tp.underlying)
517518
case _ => {
518-
report.warning(i"sbt-api: Unhandled type ${tp.getClass} : $tp")
519+
internalError(i"Unhandled type $tp of class ${tp.getClass}")
519520
Constants.emptyType
520521
}
521522
}
@@ -660,9 +661,10 @@ private class ExtractAPICollector(using Context) extends ThunkHolder {
660661
// The hashCode of the name itself is not stable across compiler instances
661662
h = MurmurHash3.mix(h, n.toString.hashCode)
662663
case elem =>
663-
report.warning(
664-
i"""Internal error: Don't know how to produce a stable hash for `$elem` of unknown class ${elem.getClass}
665-
|Incremental compilation might not work correctly.""", tree.sourcePos)
664+
internalError(
665+
i"Don't know how to produce a stable hash for `$elem` of unknown class ${elem.getClass}",
666+
tree.sourcePos)
667+
666668
h = MurmurHash3.mix(h, elem.toString.hashCode)
667669
h
668670
end iteratorHash

compiler/src/dotty/tools/dotc/sbt/ExtractDependencies.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import dotty.tools.dotc.core.StdNames._
1616
import dotty.tools.dotc.core.Symbols._
1717
import dotty.tools.dotc.core.Types._
1818
import dotty.tools.dotc.transform.SymUtils._
19+
import dotty.tools.dotc.util.{SrcPos, NoSourcePosition}
1920
import dotty.tools.io
2021
import dotty.tools.io.{AbstractFile, PlainFile, ZipArchive}
2122
import xsbti.UseScope
@@ -139,7 +140,7 @@ class ExtractDependencies extends Phase {
139140
binaryDependency(pf.file, binaryClassName(classSegments))
140141

141142
case _ =>
142-
report.warning(s"sbt-deps: Ignoring dependency $depFile of class ${depFile.getClass}}")
143+
internalError(s"Ignoring dependency $depFile of unknown class ${depFile.getClass}}", dep.from.srcPos)
143144
}
144145
}
145146

@@ -163,6 +164,10 @@ class ExtractDependencies extends Phase {
163164
object ExtractDependencies {
164165
def classNameAsString(sym: Symbol)(using Context): String =
165166
sym.fullName.stripModuleClassSuffix.toString
167+
168+
/** Report an internal error in incremental compilation. */
169+
def internalError(msg: => String, pos: SrcPos = NoSourcePosition)(using Context): Unit =
170+
report.error(s"Internal error in the incremental compiler while compiling ${ctx.compilationUnit.source}: $msg", pos)
166171
}
167172

168173
private case class ClassDependency(from: Symbol, to: Symbol, context: DependencyContext)

0 commit comments

Comments
 (0)