diff --git a/sbt/src/sbt-test/compiler-project/inc-pickled-refinement/build.sbt b/sbt/src/sbt-test/compiler-project/inc-pickled-refinement/build.sbt new file mode 100644 index 000000000..92d209377 --- /dev/null +++ b/sbt/src/sbt-test/compiler-project/inc-pickled-refinement/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/compiler-project/inc-pickled-refinement/changes/Impl1.scala b/sbt/src/sbt-test/compiler-project/inc-pickled-refinement/changes/Impl1.scala new file mode 100644 index 000000000..bfccb2ad3 --- /dev/null +++ b/sbt/src/sbt-test/compiler-project/inc-pickled-refinement/changes/Impl1.scala @@ -0,0 +1,5 @@ +package test3 + +class Impl extends B with A with C { + def bleep = println("fooo") +} diff --git a/sbt/src/sbt-test/compiler-project/inc-pickled-refinement/src/main/scala/A.scala b/sbt/src/sbt-test/compiler-project/inc-pickled-refinement/src/main/scala/A.scala new file mode 100644 index 000000000..c8ff70770 --- /dev/null +++ b/sbt/src/sbt-test/compiler-project/inc-pickled-refinement/src/main/scala/A.scala @@ -0,0 +1,3 @@ +package test3 + +trait A diff --git a/sbt/src/sbt-test/compiler-project/inc-pickled-refinement/src/main/scala/B.scala b/sbt/src/sbt-test/compiler-project/inc-pickled-refinement/src/main/scala/B.scala new file mode 100644 index 000000000..ba1f01398 --- /dev/null +++ b/sbt/src/sbt-test/compiler-project/inc-pickled-refinement/src/main/scala/B.scala @@ -0,0 +1,9 @@ +package test3 + +trait B { self: A with C => + class Inner { + def b = B.this + } + + def ref: Impl = throw new RuntimeException +} diff --git a/sbt/src/sbt-test/compiler-project/inc-pickled-refinement/src/main/scala/C.scala b/sbt/src/sbt-test/compiler-project/inc-pickled-refinement/src/main/scala/C.scala new file mode 100644 index 000000000..fb40860b2 --- /dev/null +++ b/sbt/src/sbt-test/compiler-project/inc-pickled-refinement/src/main/scala/C.scala @@ -0,0 +1,3 @@ +package test3 + +trait C { } diff --git a/sbt/src/sbt-test/compiler-project/inc-pickled-refinement/src/main/scala/Impl.scala b/sbt/src/sbt-test/compiler-project/inc-pickled-refinement/src/main/scala/Impl.scala new file mode 100644 index 000000000..ba3fa6a3c --- /dev/null +++ b/sbt/src/sbt-test/compiler-project/inc-pickled-refinement/src/main/scala/Impl.scala @@ -0,0 +1,5 @@ +package test3 + +class Impl extends B with A with C { + def bleep = println("foo") +} diff --git a/sbt/src/sbt-test/compiler-project/inc-pickled-refinement/test b/sbt/src/sbt-test/compiler-project/inc-pickled-refinement/test new file mode 100644 index 000000000..7cb9c59f9 --- /dev/null +++ b/sbt/src/sbt-test/compiler-project/inc-pickled-refinement/test @@ -0,0 +1,14 @@ +# Tests if refinement types are pickled correctly so they +# do not introduce unnecessary compile iterations +# See https://issues.scala-lang.org/browse/SI-6596, +# https://github.com/harrah/xsbt/issues/610 + +# introduces first compile iteration +> compile +# this change is local to method and does not change api so introduces +# only one additional compile iteration +$ copy-file changes/Impl1.scala src/main/scala/Impl.scala +# second iteration +> compile +# check if there are only two compile iterations performed +> check-number-of-compiler-iterations 2