Skip to content

Commit b2f30ed

Browse files
committed
Fix incremental overcompilation due to instabilities
The output of ExtractAPI should be stable, otherwise sbt might incorrectly conclude that some API changed because its hash is different, even though the source hasn't changed. This commit fixes two cases where this might happen: - package prefixes in NamedTypes are unstable, we already worked around this by normalizing them, but only for classes, we now always do it. - We use a simplified representation for `_ >: Nothing <: Any`, this is now checked using `isDirectRef` instead of referential equality on types since there is more than one way to represent `Nothing` and `Any`. Both of these issues were found while compiling dotty with `dotty-compiler-bootstrapped/compile` and making small changes.
1 parent c90ea6b commit b2f30ed

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,15 +350,15 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
350350
case tp: NamedType =>
351351
val sym = tp.symbol
352352
// Normalize package prefix to avoid instability of representation
353-
val prefix = if (sym.isClass && sym.owner.is(Package))
353+
val prefix = if (sym.owner.is(Package))
354354
sym.owner.thisType
355355
else
356356
tp.prefix
357357
new api.Projection(simpleType(prefix), sym.name.toString)
358358
case TypeApplications.AppliedType(tycon, args) =>
359359
def processArg(arg: Type): api.Type = arg match {
360360
case arg @ TypeBounds(lo, hi) => // Handle wildcard parameters
361-
if (lo.eq(defn.NothingType) && hi.eq(defn.AnyType))
361+
if (lo.isDirectRef(defn.NothingClass) && hi.isDirectRef(defn.AnyClass))
362362
Constants.emptyType
363363
else {
364364
val name = "_"

0 commit comments

Comments
 (0)