From b2f30edc13a3af7fdfec6812b61fce8ca83cde91 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Sun, 5 Mar 2017 19:21:28 +0900 Subject: [PATCH] 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. --- compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala b/compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala index 7f44af486ac6..599522b7439e 100644 --- a/compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala +++ b/compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala @@ -350,7 +350,7 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder case tp: NamedType => val sym = tp.symbol // Normalize package prefix to avoid instability of representation - val prefix = if (sym.isClass && sym.owner.is(Package)) + val prefix = if (sym.owner.is(Package)) sym.owner.thisType else tp.prefix @@ -358,7 +358,7 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder case TypeApplications.AppliedType(tycon, args) => def processArg(arg: Type): api.Type = arg match { case arg @ TypeBounds(lo, hi) => // Handle wildcard parameters - if (lo.eq(defn.NothingType) && hi.eq(defn.AnyType)) + if (lo.isDirectRef(defn.NothingClass) && hi.isDirectRef(defn.AnyClass)) Constants.emptyType else { val name = "_"