diff --git a/compile/interface/src/main/scala/xsbt/API.scala b/compile/interface/src/main/scala/xsbt/API.scala index b64770cb5..b20219823 100644 --- a/compile/interface/src/main/scala/xsbt/API.scala +++ b/compile/interface/src/main/scala/xsbt/API.scala @@ -72,9 +72,9 @@ final class API(val global: CallbackGlobal) extends Compat // call back to the xsbti.SafeLazy class in main sbt code to construct a SafeLazy instance // we pass a thunk, whose class is loaded by the interface class loader (this class's loader) - // SafeLazy ensures that once the value is forced, the thunk is nulled out and so + // SafeLazy ensures that once the value is forced, the thunk is nulled out and so // references to the thunk's classes are not retained. Specifically, it allows the interface classes - // (those in this subproject) to be garbage collected after compilation. + // (those in this subproject) to be garbage collected after compilation. private[this] val safeLazy = Class.forName("xsbti.SafeLazy").getMethod("apply", classOf[xsbti.F0[_]]) private def lzy[S <: AnyRef](s: => S): xsbti.api.Lazy[S] = { @@ -196,7 +196,7 @@ final class API(val global: CallbackGlobal) extends Compat case Nullary(un) => un case _ => t } - + private def typeDef(in: Symbol, s: Symbol): xsbti.api.TypeMember = { val (typeParams, tpe) = @@ -312,9 +312,13 @@ final class API(val global: CallbackGlobal) extends Compat private def processType(in: Symbol, t: Type): xsbti.api.Type = typeCache.getOrElseUpdate((in, t), makeType(in, t)) private def makeType(in: Symbol, t: Type): xsbti.api.Type = { - def dealias(t: Type) = t match { case TypeRef(_, sym, _) if sym.isAliasType => t.normalize; case _ => t } - dealias(t) match + val dealiased = t match { + case TypeRef(_, sym, _) if sym.isAliasType => t.dealias + case _ => t + } + + dealiased match { case NoPrefix => Constants.emptyType case ThisType(sym) => new xsbti.api.Singleton(thisPath(sym)) diff --git a/sbt/src/sbt-test/source-dependencies/abstract-type-override/build.sbt b/sbt/src/sbt-test/source-dependencies/abstract-type-override/build.sbt new file mode 100644 index 000000000..92d209377 --- /dev/null +++ b/sbt/src/sbt-test/source-dependencies/abstract-type-override/build.sbt @@ -0,0 +1,7 @@ +InputKey[Unit]("check-number-of-compiler-iterations") <<= inputTask { (argTask: TaskKey[Seq[String]]) => + (argTask, compile in Compile) map { (args: Seq[String], a: sbt.inc.Analysis) => + assert(args.size == 1) + val expectedIterationsNumber = args(0).toInt + assert(a.compilations.allCompilations.size == expectedIterationsNumber, "a.compilations.allCompilations.size = %d (expected %d)".format(a.compilations.allCompilations.size, expectedIterationsNumber)) + } +} diff --git a/sbt/src/sbt-test/source-dependencies/abstract-type-override/changes/Bar1.scala b/sbt/src/sbt-test/source-dependencies/abstract-type-override/changes/Bar1.scala new file mode 100644 index 000000000..fb8320f6e --- /dev/null +++ b/sbt/src/sbt-test/source-dependencies/abstract-type-override/changes/Bar1.scala @@ -0,0 +1,4 @@ +object Bar { + def bar: Outer.TypeInner = null + // comment to trigger recompilation +} diff --git a/sbt/src/sbt-test/source-dependencies/abstract-type-override/src/main/scala/Bar.scala b/sbt/src/sbt-test/source-dependencies/abstract-type-override/src/main/scala/Bar.scala new file mode 100644 index 000000000..93e2de3bc --- /dev/null +++ b/sbt/src/sbt-test/source-dependencies/abstract-type-override/src/main/scala/Bar.scala @@ -0,0 +1,3 @@ +object Bar { + def bar: Outer.TypeInner = null +} diff --git a/sbt/src/sbt-test/source-dependencies/abstract-type-override/src/main/scala/Foo.scala b/sbt/src/sbt-test/source-dependencies/abstract-type-override/src/main/scala/Foo.scala new file mode 100644 index 000000000..44e7145e1 --- /dev/null +++ b/sbt/src/sbt-test/source-dependencies/abstract-type-override/src/main/scala/Foo.scala @@ -0,0 +1,5 @@ +object Outer { + class Inner { type Xyz } + + type TypeInner = Inner { type Xyz = Int } +} diff --git a/sbt/src/sbt-test/source-dependencies/abstract-type-override/src/main/scala/Impl.scala b/sbt/src/sbt-test/source-dependencies/abstract-type-override/src/main/scala/Impl.scala new file mode 100644 index 000000000..b691898dd --- /dev/null +++ b/sbt/src/sbt-test/source-dependencies/abstract-type-override/src/main/scala/Impl.scala @@ -0,0 +1,3 @@ +class Impl { + def bleep = Bar.bar +} diff --git a/sbt/src/sbt-test/source-dependencies/abstract-type-override/test b/sbt/src/sbt-test/source-dependencies/abstract-type-override/test new file mode 100644 index 000000000..b0bec415e --- /dev/null +++ b/sbt/src/sbt-test/source-dependencies/abstract-type-override/test @@ -0,0 +1,14 @@ +# Test for separate compilation and proper value of +# the OVERRIDE flag when abstract types, type alias +# and structural type are involved +# See https://github.com/sbt/sbt/issues/726 for details + +# introduces first compile iteration +> compile +# this change adds a comment and does not change api so introduces +# only one additional compile iteration +$ copy-file changes/Bar1.scala src/main/scala/Bar.scala +# second iteration +#> compile +# check if there are only two compile iterations performed +> check-number-of-compiler-iterations 2