diff options
Diffstat (limited to 'bridge')
485 files changed, 4199 insertions, 0 deletions
diff --git a/bridge/src/main/scala/xsbt/CompilerClassLoader.scala b/bridge/src/main/scala/xsbt/CompilerClassLoader.scala new file mode 100644 index 000000000..3cb3f344f --- /dev/null +++ b/bridge/src/main/scala/xsbt/CompilerClassLoader.scala @@ -0,0 +1,90 @@ +package xsbt + +import java.net.{URL, URLClassLoader} + +/** A classloader to run the compiler + * + * A CompilerClassLoader is constructed from a list of `urls` that need to be on + * the classpath to run the compiler and the classloader used by sbt. + * + * To understand why a custom classloader is needed for the compiler, let us + * describe some alternatives that wouldn't work. + * - `new URLClassLoader(urls)`: + * The compiler contains sbt phases that callback to sbt using the `xsbti.*` + * interfaces. If `urls` does not contain the sbt interfaces we'll get a + * `ClassNotFoundException` in the compiler when we try to use them, if + * `urls` does contain the interfaces we'll get a `ClassCastException` or a + * `LinkageError` because if the same class is loaded by two different + * classloaders, they are considered distinct by the JVM. + * - `new URLClassLoader(urls, sbtLoader)`: + * Because of the JVM delegation model, this means that we will only load + * a class from `urls` if it's not present in the parent `sbtLoader`, but + * sbt uses its own version of the scala compiler and scala library which + * is not the one we need to run the compiler. + * + * Our solution is to implement a subclass of URLClassLoader with no parent, instead + * we override `loadClass` to load the `xsbti.*` interfaces from `sbtLoader`. + */ +class CompilerClassLoader(urls: Array[URL], sbtLoader: ClassLoader) + extends URLClassLoader(urls, null) { + override def loadClass(className: String, resolve: Boolean): Class[_] = + if (className.startsWith("xsbti.")) { + // We can't use the loadClass overload with two arguments because it's + // protected, but we can do the same by hand (the classloader instance + // from which we call resolveClass does not matter). + val c = sbtLoader.loadClass(className) + if (resolve) + resolveClass(c) + c + } else { + super.loadClass(className, resolve) + } +} + +object CompilerClassLoader { + /** Fix the compiler bridge ClassLoader + * + * Soundtrack: https://www.youtube.com/watch?v=imamcajBEJs + * + * The classloader that we get from sbt looks like: + * + * URLClassLoader(bridgeURLs, + * DualLoader(scalaLoader, notXsbtiFilter, sbtLoader, xsbtiFilter)) + * + * DualLoader will load the `xsbti.*` interfaces using `sbtLoader` and + * everything else with `scalaLoader`. Once we have loaded the dotty Main + * class using `scalaLoader`, subsequent classes in the dotty compiler will + * also be loaded by `scalaLoader` and _not_ by the DualLoader. But the sbt + * compiler phases are part of dotty and still need access to the `xsbti.*` + * interfaces in `sbtLoader`, therefore DualLoader does not work for us + * (this issue is not present with scalac because the sbt phases are + * currently defined in the compiler bridge itself, not in scalac). + * + * CompilerClassLoader is a replacement for DualLoader. Until we can fix + * this in sbt proper, we need to use reflection to construct our own + * fixed classloader: + * + * URLClassLoader(bridgeURLs, + * CompilerClassLoader(scalaLoader.getURLs, sbtLoader)) + * + * @param bridgeLoader The classloader that sbt uses to load the compiler bridge + * @return A fixed classloader that works with dotty + */ + def fixBridgeLoader(bridgeLoader: ClassLoader) = bridgeLoader match { + case bridgeLoader: URLClassLoader => + val dualLoader = bridgeLoader.getParent + val dualLoaderClass = dualLoader.getClass + + // DualLoader#parentA and DualLoader#parentB are private + val parentAField = dualLoaderClass.getDeclaredField("parentA") + parentAField.setAccessible(true) + val parentBField = dualLoaderClass.getDeclaredField("parentB") + parentBField.setAccessible(true) + val scalaLoader = parentAField.get(dualLoader).asInstanceOf[URLClassLoader] + val sbtLoader = parentBField.get(dualLoader).asInstanceOf[URLClassLoader] + + val bridgeURLs = bridgeLoader.getURLs + new URLClassLoader(bridgeURLs, + new CompilerClassLoader(scalaLoader.getURLs, sbtLoader)) + } +} diff --git a/bridge/src/main/scala/xsbt/CompilerInterface.scala b/bridge/src/main/scala/xsbt/CompilerInterface.scala new file mode 100644 index 000000000..ee272b8b1 --- /dev/null +++ b/bridge/src/main/scala/xsbt/CompilerInterface.scala @@ -0,0 +1,70 @@ +/* sbt -- Simple Build Tool + * Copyright 2008, 2009 Mark Harrah + */ +package xsbt + +import xsbti.{ AnalysisCallback, Logger, Problem, Reporter, Severity, DependencyContext } +import xsbti.api.SourceAPI +import xsbti.compile._ +import Log.debug +import java.io.File + +import dotty.tools.dotc.core.Contexts.ContextBase +import dotty.tools.dotc.{ Main => DottyMain } +import dotty.tools.dotc.interfaces._ + +import java.net.URLClassLoader + +final class CompilerInterface { + def newCompiler(options: Array[String], output: Output, initialLog: Logger, + initialDelegate: Reporter, resident: Boolean): CachedCompiler = { + // The classloader that sbt uses to load the compiler bridge is broken + // (see CompilerClassLoader#fixBridgeLoader for details). To workaround + // this we construct our own ClassLoader and then run the following code + // with it: + // new CachedCompilerImpl(options, output, resident) + + val bridgeLoader = getClass.getClassLoader + val fixedLoader = CompilerClassLoader.fixBridgeLoader(bridgeLoader) + val cciClass = fixedLoader.loadClass("xsbt.CachedCompilerImpl") + cciClass.getConstructors.head + .newInstance(options, output, resident: java.lang.Boolean) + .asInstanceOf[CachedCompiler] + } + + def run(sources: Array[File], changes: DependencyChanges, callback: AnalysisCallback, log: Logger, + delegate: Reporter, progress: CompileProgress, cached: CachedCompiler): Unit = + cached.run(sources, changes, callback, log, delegate, progress) +} + +class CachedCompilerImpl(args: Array[String], output: Output, resident: Boolean) extends CachedCompiler { + val outputArgs = + output match { + case multi: MultipleOutput => + ??? + case single: SingleOutput => + List("-d", single.outputDirectory.getAbsolutePath.toString) + } + + def commandArguments(sources: Array[File]): Array[String] = + (outputArgs ++ args.toList ++ sources.map(_.getAbsolutePath).sortWith(_ < _)).toArray[String] + + def run(sources: Array[File], changes: DependencyChanges, callback: AnalysisCallback, log: Logger, delegate: Reporter, progress: CompileProgress): Unit = synchronized { + run(sources.toList, changes, callback, log, progress) + } + private[this] def run(sources: List[File], changes: DependencyChanges, callback: AnalysisCallback, log: Logger, compileProgress: CompileProgress): Unit = { + debug(log, args.mkString("Calling Dotty compiler with arguments (CompilerInterface):\n\t", "\n\t", "")) + val ctx = (new ContextBase).initialCtx.fresh + .setSbtCallback(callback) + val cl = getClass.getClassLoader.asInstanceOf[URLClassLoader] + + val reporter = DottyMain.process(commandArguments(sources.toArray), ctx) + if (reporter.hasErrors) { + throw new InterfaceCompileFailed(args, Array()) + } + } +} + +class InterfaceCompileFailed(override val arguments: Array[String], override val problems: Array[Problem]) extends xsbti.CompileFailed { + override val toString = "Compilation failed" +} diff --git a/bridge/src/main/scala/xsbt/Log.scala b/bridge/src/main/scala/xsbt/Log.scala new file mode 100644 index 000000000..e514d7abb --- /dev/null +++ b/bridge/src/main/scala/xsbt/Log.scala @@ -0,0 +1,10 @@ +/* sbt -- Simple Build Tool + * Copyright 2008, 2009 Mark Harrah + */ +package xsbt + +object Log { + def debug(log: xsbti.Logger, msg: => String) = log.debug(Message(msg)) + def settingsError(log: xsbti.Logger): String => Unit = + s => log.error(Message(s)) +} diff --git a/bridge/src/main/scala/xsbt/Message.scala b/bridge/src/main/scala/xsbt/Message.scala new file mode 100644 index 000000000..48f24f533 --- /dev/null +++ b/bridge/src/main/scala/xsbt/Message.scala @@ -0,0 +1,8 @@ +/* sbt -- Simple Build Tool + * Copyright 2008, 2009 Mark Harrah + */ +package xsbt + +object Message { + def apply[T](s: => T) = new xsbti.F0[T] { def apply() = s } +} diff --git a/bridge/src/sbt-test/source-dependencies/abstract-override/A.scala b/bridge/src/sbt-test/source-dependencies/abstract-override/A.scala new file mode 100644 index 000000000..43b95b9e9 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/abstract-override/A.scala @@ -0,0 +1,3 @@ +trait A { + def x: Int +} diff --git a/bridge/src/sbt-test/source-dependencies/abstract-override/B.scala b/bridge/src/sbt-test/source-dependencies/abstract-override/B.scala new file mode 100644 index 000000000..c7569ba51 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/abstract-override/B.scala @@ -0,0 +1,3 @@ +trait B extends A { + override def x = 2 +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/abstract-override/C.scala b/bridge/src/sbt-test/source-dependencies/abstract-override/C.scala new file mode 100644 index 000000000..24d656d4a --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/abstract-override/C.scala @@ -0,0 +1,3 @@ +trait C extends A { + def x = 5 +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/abstract-override/D.scala b/bridge/src/sbt-test/source-dependencies/abstract-override/D.scala new file mode 100644 index 000000000..1f0d0a274 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/abstract-override/D.scala @@ -0,0 +1 @@ +trait D extends C with B
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/abstract-override/changes/C2.scala b/bridge/src/sbt-test/source-dependencies/abstract-override/changes/C2.scala new file mode 100644 index 000000000..5cb6be980 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/abstract-override/changes/C2.scala @@ -0,0 +1,3 @@ +trait C extends A { + abstract override def x = super.x + 5 +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/abstract-override/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/abstract-override/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/abstract-override/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/abstract-override/test b/bridge/src/sbt-test/source-dependencies/abstract-override/test new file mode 100644 index 000000000..8021d5ce2 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/abstract-override/test @@ -0,0 +1,3 @@ +> compile +$ copy-file changes/C2.scala C.scala +-> compile
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/abstract-type-override/build.sbt b/bridge/src/sbt-test/source-dependencies/abstract-type-override/build.sbt new file mode 100644 index 000000000..92d209377 --- /dev/null +++ b/bridge/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/bridge/src/sbt-test/source-dependencies/abstract-type-override/changes/Bar1.scala b/bridge/src/sbt-test/source-dependencies/abstract-type-override/changes/Bar1.scala new file mode 100644 index 000000000..fb8320f6e --- /dev/null +++ b/bridge/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/bridge/src/sbt-test/source-dependencies/abstract-type-override/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/abstract-type-override/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/abstract-type-override/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/abstract-type-override/src/main/scala/Bar.scala b/bridge/src/sbt-test/source-dependencies/abstract-type-override/src/main/scala/Bar.scala new file mode 100644 index 000000000..93e2de3bc --- /dev/null +++ b/bridge/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/bridge/src/sbt-test/source-dependencies/abstract-type-override/src/main/scala/Foo.scala b/bridge/src/sbt-test/source-dependencies/abstract-type-override/src/main/scala/Foo.scala new file mode 100644 index 000000000..44e7145e1 --- /dev/null +++ b/bridge/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/bridge/src/sbt-test/source-dependencies/abstract-type-override/src/main/scala/Impl.scala b/bridge/src/sbt-test/source-dependencies/abstract-type-override/src/main/scala/Impl.scala new file mode 100644 index 000000000..b691898dd --- /dev/null +++ b/bridge/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/bridge/src/sbt-test/source-dependencies/abstract-type-override/test b/bridge/src/sbt-test/source-dependencies/abstract-type-override/test new file mode 100644 index 000000000..b0bec415e --- /dev/null +++ b/bridge/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 diff --git a/bridge/src/sbt-test/source-dependencies/abstract-type/A.scala b/bridge/src/sbt-test/source-dependencies/abstract-type/A.scala new file mode 100644 index 000000000..08c21e380 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/abstract-type/A.scala @@ -0,0 +1,3 @@ +trait A { + type S[_] +} diff --git a/bridge/src/sbt-test/source-dependencies/abstract-type/B.scala b/bridge/src/sbt-test/source-dependencies/abstract-type/B.scala new file mode 100644 index 000000000..c6fa33d89 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/abstract-type/B.scala @@ -0,0 +1,3 @@ +trait B extends A { + type F = S[Int] +} diff --git a/bridge/src/sbt-test/source-dependencies/abstract-type/changes/A.scala b/bridge/src/sbt-test/source-dependencies/abstract-type/changes/A.scala new file mode 100644 index 000000000..7d5c095b4 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/abstract-type/changes/A.scala @@ -0,0 +1,3 @@ +trait A { + type S +} diff --git a/bridge/src/sbt-test/source-dependencies/abstract-type/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/abstract-type/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/abstract-type/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/abstract-type/test b/bridge/src/sbt-test/source-dependencies/abstract-type/test new file mode 100644 index 000000000..3f5a5c7e3 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/abstract-type/test @@ -0,0 +1,7 @@ +> compile + +# remove type arguments from S +$ copy-file changes/A.scala A.scala + +# Both A.scala and B.scala should be recompiled, producing a compile error +-> compile diff --git a/bridge/src/sbt-test/source-dependencies/added/changes/A1.scala b/bridge/src/sbt-test/source-dependencies/added/changes/A1.scala new file mode 100644 index 000000000..a58c253c0 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/added/changes/A1.scala @@ -0,0 +1,6 @@ +package example + +object A +{ + val x: Int = 3 +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/added/changes/A2.scala b/bridge/src/sbt-test/source-dependencies/added/changes/A2.scala new file mode 100644 index 000000000..48ac8e5b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/added/changes/A2.scala @@ -0,0 +1,6 @@ +package example + +object A +{ + val x: Int = B.y +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/added/changes/A3.scala b/bridge/src/sbt-test/source-dependencies/added/changes/A3.scala new file mode 100644 index 000000000..ec450b67e --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/added/changes/A3.scala @@ -0,0 +1,6 @@ +package example + +object A +{ + val x: String = B.y +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/added/changes/B1.scala b/bridge/src/sbt-test/source-dependencies/added/changes/B1.scala new file mode 100644 index 000000000..9b5cc4ee9 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/added/changes/B1.scala @@ -0,0 +1,6 @@ +package example + +object B +{ + val y: String = "4" +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/added/changes/B2.scala b/bridge/src/sbt-test/source-dependencies/added/changes/B2.scala new file mode 100644 index 000000000..fc8c53c9c --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/added/changes/B2.scala @@ -0,0 +1,6 @@ +package example + +object B +{ + val y: Int = 5 +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/added/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/added/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/added/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/added/test b/bridge/src/sbt-test/source-dependencies/added/test new file mode 100644 index 000000000..a1ab31849 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/added/test @@ -0,0 +1,28 @@ +# This test checks that when a source file included in a partial recompilation adds a dependency on +# a file not included in the partial recompilation, the dependency is properly recorded. + +# B and A are independent, so both should compile successfully +$ copy-file changes/A1.scala src/main/scala/A.scala +$ copy-file changes/B1.scala src/main/scala/B.scala +> compile + + +# A now depends on B and to check that it was recompiled, we mismatch the types, which should fail +$ copy-file changes/A2.scala src/main/scala/A.scala +-> compile + + +# We now correct the type so that it compiles successfully and this should introduce a dependency from A to B +$ copy-file changes/A3.scala src/main/scala/A.scala +> compile + + +# If the dependency from A to B was properly introduced, changing the type of B.y to Int should make +# the following statement in A a compiler error: +# val x: String = B.y +$ copy-file changes/B2.scala src/main/scala/B.scala +-> compile + +# verify this was the correct result by doing a clean+compile +> clean +-> compile diff --git a/bridge/src/sbt-test/source-dependencies/as-seen-from-a/A.scala b/bridge/src/sbt-test/source-dependencies/as-seen-from-a/A.scala new file mode 100644 index 000000000..fe6a784a4 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/as-seen-from-a/A.scala @@ -0,0 +1,6 @@ +abstract class A { + type T + object X { + def foo(x: T): T = x + } +} diff --git a/bridge/src/sbt-test/source-dependencies/as-seen-from-a/B.scala b/bridge/src/sbt-test/source-dependencies/as-seen-from-a/B.scala new file mode 100644 index 000000000..60059966f --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/as-seen-from-a/B.scala @@ -0,0 +1,3 @@ +class B extends A { + type T = Int +} diff --git a/bridge/src/sbt-test/source-dependencies/as-seen-from-a/C.scala b/bridge/src/sbt-test/source-dependencies/as-seen-from-a/C.scala new file mode 100644 index 000000000..3753dbeec --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/as-seen-from-a/C.scala @@ -0,0 +1 @@ +object C extends B diff --git a/bridge/src/sbt-test/source-dependencies/as-seen-from-a/D.scala b/bridge/src/sbt-test/source-dependencies/as-seen-from-a/D.scala new file mode 100644 index 000000000..ace241491 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/as-seen-from-a/D.scala @@ -0,0 +1,3 @@ +object D { + C.X.foo(12) +} diff --git a/bridge/src/sbt-test/source-dependencies/as-seen-from-a/changes/B2.scala b/bridge/src/sbt-test/source-dependencies/as-seen-from-a/changes/B2.scala new file mode 100644 index 000000000..18f3eefdd --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/as-seen-from-a/changes/B2.scala @@ -0,0 +1,3 @@ +class B extends A { + type T = String +} diff --git a/bridge/src/sbt-test/source-dependencies/as-seen-from-a/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/as-seen-from-a/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/as-seen-from-a/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/as-seen-from-a/test b/bridge/src/sbt-test/source-dependencies/as-seen-from-a/test new file mode 100644 index 000000000..176a86399 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/as-seen-from-a/test @@ -0,0 +1,3 @@ +> compile +$ copy-file changes/B2.scala B.scala +-> compile diff --git a/bridge/src/sbt-test/source-dependencies/as-seen-from-b/A.scala b/bridge/src/sbt-test/source-dependencies/as-seen-from-b/A.scala new file mode 100644 index 000000000..f4ae0b78d --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/as-seen-from-b/A.scala @@ -0,0 +1,7 @@ +abstract class A { + type T <: S + type S + object X { + def foo: T = null.asInstanceOf[T] + } +} diff --git a/bridge/src/sbt-test/source-dependencies/as-seen-from-b/B.scala b/bridge/src/sbt-test/source-dependencies/as-seen-from-b/B.scala new file mode 100644 index 000000000..f97007480 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/as-seen-from-b/B.scala @@ -0,0 +1,3 @@ +class B extends A { + type S <: Int +} diff --git a/bridge/src/sbt-test/source-dependencies/as-seen-from-b/C.scala b/bridge/src/sbt-test/source-dependencies/as-seen-from-b/C.scala new file mode 100644 index 000000000..3753dbeec --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/as-seen-from-b/C.scala @@ -0,0 +1 @@ +object C extends B diff --git a/bridge/src/sbt-test/source-dependencies/as-seen-from-b/D.scala b/bridge/src/sbt-test/source-dependencies/as-seen-from-b/D.scala new file mode 100644 index 000000000..ec333ca60 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/as-seen-from-b/D.scala @@ -0,0 +1,3 @@ +object D { + val x: Int = C.X.foo +} diff --git a/bridge/src/sbt-test/source-dependencies/as-seen-from-b/changes/B2.scala b/bridge/src/sbt-test/source-dependencies/as-seen-from-b/changes/B2.scala new file mode 100644 index 000000000..f8fa3ad03 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/as-seen-from-b/changes/B2.scala @@ -0,0 +1,3 @@ +class B extends A { + type S <: String +} diff --git a/bridge/src/sbt-test/source-dependencies/as-seen-from-b/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/as-seen-from-b/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/as-seen-from-b/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/as-seen-from-b/test b/bridge/src/sbt-test/source-dependencies/as-seen-from-b/test new file mode 100644 index 000000000..176a86399 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/as-seen-from-b/test @@ -0,0 +1,3 @@ +> compile +$ copy-file changes/B2.scala B.scala +-> compile diff --git a/bridge/src/sbt-test/source-dependencies/backtick-quoted-names/A.scala b/bridge/src/sbt-test/source-dependencies/backtick-quoted-names/A.scala new file mode 100644 index 000000000..1d3a976a8 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/backtick-quoted-names/A.scala @@ -0,0 +1,3 @@ +object A { + def `=` = 3 +} diff --git a/bridge/src/sbt-test/source-dependencies/backtick-quoted-names/B.scala b/bridge/src/sbt-test/source-dependencies/backtick-quoted-names/B.scala new file mode 100644 index 000000000..03d8769fd --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/backtick-quoted-names/B.scala @@ -0,0 +1,3 @@ +object B extends dotty.runtime.LegacyApp { + println(A.`=`) +} diff --git a/bridge/src/sbt-test/source-dependencies/backtick-quoted-names/build.sbt b/bridge/src/sbt-test/source-dependencies/backtick-quoted-names/build.sbt new file mode 100644 index 000000000..8a38ef414 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/backtick-quoted-names/build.sbt @@ -0,0 +1 @@ +incOptions := incOptions.value.withNameHashing(true) diff --git a/bridge/src/sbt-test/source-dependencies/backtick-quoted-names/changes/A.scala b/bridge/src/sbt-test/source-dependencies/backtick-quoted-names/changes/A.scala new file mode 100644 index 000000000..b473714fa --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/backtick-quoted-names/changes/A.scala @@ -0,0 +1,3 @@ +object A { + def asdf = 3 +} diff --git a/bridge/src/sbt-test/source-dependencies/backtick-quoted-names/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/backtick-quoted-names/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/backtick-quoted-names/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/backtick-quoted-names/test b/bridge/src/sbt-test/source-dependencies/backtick-quoted-names/test new file mode 100644 index 000000000..d4d386615 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/backtick-quoted-names/test @@ -0,0 +1,7 @@ +> compile + +# rename def with symbolic name (`=`) +$ copy-file changes/A.scala A.scala + +# Both A.scala and B.scala should be recompiled, producing a compile error +-> compile diff --git a/bridge/src/sbt-test/source-dependencies/binary/changes/Break.scala b/bridge/src/sbt-test/source-dependencies/binary/changes/Break.scala new file mode 100644 index 000000000..88d8ef9a3 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/binary/changes/Break.scala @@ -0,0 +1 @@ +object Break
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/binary/dep/A.scala b/bridge/src/sbt-test/source-dependencies/binary/dep/A.scala new file mode 100644 index 000000000..91d3855f6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/binary/dep/A.scala @@ -0,0 +1,3 @@ +object A { + val x = 3 +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/binary/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/binary/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/binary/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/binary/project/P.scala b/bridge/src/sbt-test/source-dependencies/binary/project/P.scala new file mode 100644 index 000000000..d5d84e5a4 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/binary/project/P.scala @@ -0,0 +1,10 @@ +import sbt._ +import Keys._ + +object B extends Build +{ + lazy val dep = Project("dep", file("dep")) + lazy val use = Project("use", file("use")) settings( + unmanagedJars in Compile <+= packageBin in (dep, Compile) map Attributed.blank + ) +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/binary/test b/bridge/src/sbt-test/source-dependencies/binary/test new file mode 100644 index 000000000..058c5492c --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/binary/test @@ -0,0 +1,6 @@ +# done this way because last modified times often have ~1s resolution +> use/package +$ sleep 2000 + +$ copy-file changes/Break.scala dep/A.scala +-> use/compile diff --git a/bridge/src/sbt-test/source-dependencies/binary/use/B.scala b/bridge/src/sbt-test/source-dependencies/binary/use/B.scala new file mode 100644 index 000000000..5f371ab41 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/binary/use/B.scala @@ -0,0 +1,3 @@ +object B { + val y = A.x +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/by-name/A.scala b/bridge/src/sbt-test/source-dependencies/by-name/A.scala new file mode 100644 index 000000000..46ec286ff --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/by-name/A.scala @@ -0,0 +1,4 @@ +object A +{ + def x(i: => String) = () +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/by-name/B.scala b/bridge/src/sbt-test/source-dependencies/by-name/B.scala new file mode 100644 index 000000000..a06f3a186 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/by-name/B.scala @@ -0,0 +1,4 @@ +object B +{ + val x = A.x("3") +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/by-name/changes/A.scala b/bridge/src/sbt-test/source-dependencies/by-name/changes/A.scala new file mode 100644 index 000000000..0d12dd477 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/by-name/changes/A.scala @@ -0,0 +1,4 @@ +object A +{ + def x(i: Function0[String]) = () +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/by-name/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/by-name/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/by-name/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/by-name/test b/bridge/src/sbt-test/source-dependencies/by-name/test new file mode 100644 index 000000000..4306d3bcc --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/by-name/test @@ -0,0 +1,7 @@ +> compile + +# change => Int to Function0 +$ copy-file changes/A.scala A.scala + +# Both A.scala and B.scala need to be recompiled because the type has changed +-> compile diff --git a/bridge/src/sbt-test/source-dependencies/canon/Use.scala b/bridge/src/sbt-test/source-dependencies/canon/Use.scala new file mode 100644 index 000000000..fe9e21714 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/canon/Use.scala @@ -0,0 +1,3 @@ +object Use { + val x = A.x +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/canon/actual/A.java b/bridge/src/sbt-test/source-dependencies/canon/actual/A.java new file mode 100644 index 000000000..693c5b932 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/canon/actual/A.java @@ -0,0 +1,4 @@ +// this is the source for the compiled class in a.jar +public class A { + public static final int x = 3; +} diff --git a/bridge/src/sbt-test/source-dependencies/canon/actual/a.jar b/bridge/src/sbt-test/source-dependencies/canon/actual/a.jar Binary files differnew file mode 100644 index 000000000..5c63ca5e9 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/canon/actual/a.jar diff --git a/bridge/src/sbt-test/source-dependencies/canon/build.sbt b/bridge/src/sbt-test/source-dependencies/canon/build.sbt new file mode 100644 index 000000000..d23dff705 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/canon/build.sbt @@ -0,0 +1,10 @@ +import complete.DefaultParsers._ + +val checkIterations = inputKey[Unit]("Verifies the accumlated number of iterations of incremental compilation.") + +checkIterations := { + val expected: Int = (Space ~> NatBasic).parsed + val actual: Int = (compile in Compile).value.compilations.allCompilations.size + assert(expected == actual, s"Expected $expected compilations, got $actual") +} + diff --git a/bridge/src/sbt-test/source-dependencies/canon/lib/a.jar b/bridge/src/sbt-test/source-dependencies/canon/lib/a.jar new file mode 120000 index 000000000..9fa4156a8 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/canon/lib/a.jar @@ -0,0 +1 @@ +../actual/a.jar
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/canon/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/canon/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/canon/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/canon/test b/bridge/src/sbt-test/source-dependencies/canon/test new file mode 100644 index 000000000..13caf4871 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/canon/test @@ -0,0 +1,10 @@ +# Tests that classpath entries that are different than their canonical representation are +# handled properly. In particular, a symlink from lib/a.jar to lib/../actual/a.jar.0 is +# available on the classpath and read by scalac. scalac 2.10.x does not interpret .jar.0 +# as a jar, so if sbt passes the canonical path, it will not be read. +# This also verifies that compilation does not get repeatedly triggered by a mismatch in +# paths. + +> compile +> compile +> checkIterations 1
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/compactify/build.sbt b/bridge/src/sbt-test/source-dependencies/compactify/build.sbt new file mode 100644 index 000000000..f44ca0862 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/compactify/build.sbt @@ -0,0 +1,9 @@ +TaskKey[Unit]("output-empty") <<= classDirectory in Configurations.Compile map { outputDirectory => + def classes = (outputDirectory ** "*.class").get + if(!classes.isEmpty) sys.error("Classes existed:\n\t" + classes.mkString("\n\t")) else () +} + +// apparently Travis CI stopped allowing long file names +// it fails with the default setting of 255 characters so +// we have to set lower limit ourselves +scalacOptions ++= Seq("-Xmax-classfile-name", "240") diff --git a/bridge/src/sbt-test/source-dependencies/compactify/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/compactify/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/compactify/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/compactify/src/main/scala/For.scala b/bridge/src/sbt-test/source-dependencies/compactify/src/main/scala/For.scala new file mode 100644 index 000000000..5d1b8c4db --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/compactify/src/main/scala/For.scala @@ -0,0 +1,44 @@ +package somereallylongpackagenamethatwilltestsbtsanalyzer_somereallylongpackagenamethatwilltestsbtsanalyzer.somereallylongpackagenamethatwilltestsbtsanalyzer + +object T +{ + val y = List(3) + for(a <- y; + b <- y; + c <- y; + d <- y; + e <- y; + f <- y; + g <- y; + h <- y; + i <- y; + j <- y; + k <- y; + l <- y; + m <- y; + n <- y; + o <- y; + p <- y; + q <- y; + r <- y; + s <- y; + t <- y; + u <- y; + v <- y; + w <- y; + x <- y; + yx <- y; + z <- y; + aa <- y; + bb <- y; + cc <- y; + dd <- y; + ee <- y; + ff <- y; + gg <- y; + hh<- y; + ii <- y; + jj <- y; + kk <- y + ) yield a + b + c + d + e +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/compactify/src/main/scala/Nested.scala b/bridge/src/sbt-test/source-dependencies/compactify/src/main/scala/Nested.scala new file mode 100644 index 000000000..798868d72 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/compactify/src/main/scala/Nested.scala @@ -0,0 +1,41 @@ +package test + +object TopLevelModule1 +{ + object InnerModule1 + { + object InnerModule2 + { + trait Z { def q = 3 } + def x = 3 + } + } + class InnerClass1 + { + class InnerClass2 + { + val z = new TopLevelModule1.InnerClass2 + } + object InnerModule3 + { + val y = new TopLevel1 with InnerModule1.InnerModule2.Z { val x = 4 } + } + } + class InnerClass2 +} +class TopLevel1 +{ + object Inner1_1 +} +object TopLevel1 +{ + class Inner1_2 + object Inner1_2 +} + +object TopLevel2 +class TopLevel2 + +object TopLevel3 + +class TopLevel4
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/compactify/test b/bridge/src/sbt-test/source-dependencies/compactify/test new file mode 100644 index 000000000..e2abf578b --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/compactify/test @@ -0,0 +1,8 @@ +# Marked pending due to https://github.com/sbt/sbt/issues/1553 + +> output-empty +> compile +-> output-empty +$ delete src/main/scala/For.scala src/main/scala/Nested.scala +> compile +> output-empty
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/constants/changes/A1.scala b/bridge/src/sbt-test/source-dependencies/constants/changes/A1.scala new file mode 100644 index 000000000..f67b6f474 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/constants/changes/A1.scala @@ -0,0 +1 @@ +object A { final val x = 1 } diff --git a/bridge/src/sbt-test/source-dependencies/constants/changes/A2.scala b/bridge/src/sbt-test/source-dependencies/constants/changes/A2.scala new file mode 100644 index 000000000..4f9396f13 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/constants/changes/A2.scala @@ -0,0 +1 @@ +object A { final val x = 2 } diff --git a/bridge/src/sbt-test/source-dependencies/constants/changes/B.scala b/bridge/src/sbt-test/source-dependencies/constants/changes/B.scala new file mode 100644 index 000000000..058527993 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/constants/changes/B.scala @@ -0,0 +1,4 @@ +object B +{ + def main(args: Array[String]) = assert(args(0).toInt == A.x ) +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/constants/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/constants/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/constants/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/constants/test b/bridge/src/sbt-test/source-dependencies/constants/test new file mode 100644 index 000000000..7a5ae5879 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/constants/test @@ -0,0 +1,12 @@ +# Marked as pending, see https://github.com/sbt/sbt/issues/1543 +# Tests if source dependencies are tracked properly +# for compile-time constants (like final vals in top-level objects) +# see https://issues.scala-lang.org/browse/SI-7173 for details +# why compile-time constants can be tricky to track due to early inlining + +$ copy-file changes/B.scala B.scala + +$ copy-file changes/A1.scala A.scala +> run 1 +$ copy-file changes/A2.scala A.scala +> run 2 diff --git a/bridge/src/sbt-test/source-dependencies/default-params/A.scala b/bridge/src/sbt-test/source-dependencies/default-params/A.scala new file mode 100644 index 000000000..50baa662f --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/default-params/A.scala @@ -0,0 +1,5 @@ +object A +{ + def x(f: String, g: Int): Int = g + def x(f: Int, g: Int = 3): Int = g +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/default-params/B.scala b/bridge/src/sbt-test/source-dependencies/default-params/B.scala new file mode 100644 index 000000000..59a7159f9 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/default-params/B.scala @@ -0,0 +1,4 @@ +object B +{ + val y = A.x(5) +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/default-params/changes/A.scala b/bridge/src/sbt-test/source-dependencies/default-params/changes/A.scala new file mode 100644 index 000000000..b59015306 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/default-params/changes/A.scala @@ -0,0 +1,5 @@ +object A +{ + def x(f: String, g: Int = 3): Int = g + def x(f: Int, g: Int): Int = g +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/default-params/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/default-params/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/default-params/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/default-params/test b/bridge/src/sbt-test/source-dependencies/default-params/test new file mode 100644 index 000000000..1e674f8f6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/default-params/test @@ -0,0 +1,9 @@ +> compile + +# switch which 'x' method has a default for the second parameter in A +# this change is selected because of the encoding of default method names +$ copy-file changes/A.scala A.scala + +# Both A.scala and B.scala need to be recompiled because the parameter needs to be explicitly provided +# and it should be a compile error +-> compile diff --git a/bridge/src/sbt-test/source-dependencies/dup-class/changes/A.scala b/bridge/src/sbt-test/source-dependencies/dup-class/changes/A.scala new file mode 100644 index 000000000..264775513 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/dup-class/changes/A.scala @@ -0,0 +1,3 @@ +package clear + +object A diff --git a/bridge/src/sbt-test/source-dependencies/dup-class/changes/A2.scala b/bridge/src/sbt-test/source-dependencies/dup-class/changes/A2.scala new file mode 100644 index 000000000..264775513 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/dup-class/changes/A2.scala @@ -0,0 +1,3 @@ +package clear + +object A diff --git a/bridge/src/sbt-test/source-dependencies/dup-class/changes/B.scala b/bridge/src/sbt-test/source-dependencies/dup-class/changes/B.scala new file mode 100644 index 000000000..50df7082c --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/dup-class/changes/B.scala @@ -0,0 +1,3 @@ +package clear + +object B diff --git a/bridge/src/sbt-test/source-dependencies/dup-class/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/dup-class/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/dup-class/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/dup-class/test b/bridge/src/sbt-test/source-dependencies/dup-class/test new file mode 100644 index 000000000..531553bb5 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/dup-class/test @@ -0,0 +1,6 @@ +$ copy-file changes/A.scala A.scala +> compile +$ copy-file changes/A2.scala B.scala +-> compile +$ copy-file changes/B.scala B.scala +> compile diff --git a/bridge/src/sbt-test/source-dependencies/empty-a/changes/A.scala b/bridge/src/sbt-test/source-dependencies/empty-a/changes/A.scala new file mode 100644 index 000000000..0c52ad165 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/empty-a/changes/A.scala @@ -0,0 +1,6 @@ +package a + +object A +{ + def x = "A" +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/empty-a/changes/A2.scala b/bridge/src/sbt-test/source-dependencies/empty-a/changes/A2.scala new file mode 100644 index 000000000..2e85f9808 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/empty-a/changes/A2.scala @@ -0,0 +1,6 @@ +/*package a + +object A +{ + def x = "A" +}*/
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/empty-a/changes/B.scala b/bridge/src/sbt-test/source-dependencies/empty-a/changes/B.scala new file mode 100644 index 000000000..7865ddcec --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/empty-a/changes/B.scala @@ -0,0 +1,6 @@ +package a + +class B +{ + def x = A.x +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/empty-a/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/empty-a/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/empty-a/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/empty-a/test b/bridge/src/sbt-test/source-dependencies/empty-a/test new file mode 100644 index 000000000..d0f0b25a8 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/empty-a/test @@ -0,0 +1,19 @@ +$ copy-file changes/A.scala src/main/scala/A.scala +> compile + +$ copy-file changes/A2.scala src/main/scala/A.scala +> compile + +$ copy-file changes/B.scala src/main/scala/B.scala +-> compile + +$ copy-file changes/A.scala src/main/scala/A.scala +> compile + +$ delete src/main/scala/B.scala +$ copy-file changes/A2.scala src/main/scala/A.scala +> compile + +$ copy-file changes/A.scala src/main/scala/A.scala +$ copy-file changes/B.scala src/main/scala/B.scala +> compile
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/empty-package/changes/Define1.scala b/bridge/src/sbt-test/source-dependencies/empty-package/changes/Define1.scala new file mode 100644 index 000000000..9317a8425 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/empty-package/changes/Define1.scala @@ -0,0 +1,3 @@ +package a.pkgName + +object Test diff --git a/bridge/src/sbt-test/source-dependencies/empty-package/changes/Define2.scala b/bridge/src/sbt-test/source-dependencies/empty-package/changes/Define2.scala new file mode 100644 index 000000000..ed2d7ae8a --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/empty-package/changes/Define2.scala @@ -0,0 +1,3 @@ +package pkgName + +object Test diff --git a/bridge/src/sbt-test/source-dependencies/empty-package/changes/Use.scala b/bridge/src/sbt-test/source-dependencies/empty-package/changes/Use.scala new file mode 100644 index 000000000..b4d87c711 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/empty-package/changes/Use.scala @@ -0,0 +1,7 @@ +package a + +import pkgName.Test + +object Use { + val x = Test +} diff --git a/bridge/src/sbt-test/source-dependencies/empty-package/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/empty-package/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/empty-package/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/empty-package/test b/bridge/src/sbt-test/source-dependencies/empty-package/test new file mode 100644 index 000000000..718e7f125 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/empty-package/test @@ -0,0 +1,12 @@ +$ copy-file changes/Define1.scala Define.scala +$ copy-file changes/Use.scala Use.scala +> compile + +$ copy-file changes/Define2.scala Define.scala +> compile + +$ delete Define.scala +-> compile + +$ copy-file changes/Define1.scala Define.scala +> compile
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/erasure/A.scala b/bridge/src/sbt-test/source-dependencies/erasure/A.scala new file mode 100644 index 000000000..63b240ac6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/erasure/A.scala @@ -0,0 +1,3 @@ +object A { + def x: List[Int] = List(3) +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/erasure/B.scala b/bridge/src/sbt-test/source-dependencies/erasure/B.scala new file mode 100644 index 000000000..1c636101f --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/erasure/B.scala @@ -0,0 +1,3 @@ +object B { + val y: List[Int] = A.x +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/erasure/changes/A.scala b/bridge/src/sbt-test/source-dependencies/erasure/changes/A.scala new file mode 100644 index 000000000..c1bceae79 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/erasure/changes/A.scala @@ -0,0 +1,3 @@ +object A { + def x: List[String] = List("3") +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/erasure/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/erasure/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/erasure/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/erasure/test b/bridge/src/sbt-test/source-dependencies/erasure/test new file mode 100644 index 000000000..aaca5a2e3 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/erasure/test @@ -0,0 +1,4 @@ +> compile + +$ copy-file changes/A.scala A.scala +-> compile
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/export-jars/changes/A1.scala b/bridge/src/sbt-test/source-dependencies/export-jars/changes/A1.scala new file mode 100644 index 000000000..210adf865 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/export-jars/changes/A1.scala @@ -0,0 +1 @@ +object A { val x = 1 } diff --git a/bridge/src/sbt-test/source-dependencies/export-jars/changes/A2.scala b/bridge/src/sbt-test/source-dependencies/export-jars/changes/A2.scala new file mode 100644 index 000000000..799400c8c --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/export-jars/changes/A2.scala @@ -0,0 +1 @@ +object A { val x = 2 } diff --git a/bridge/src/sbt-test/source-dependencies/export-jars/changes/A3.scala b/bridge/src/sbt-test/source-dependencies/export-jars/changes/A3.scala new file mode 100644 index 000000000..25fb93965 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/export-jars/changes/A3.scala @@ -0,0 +1 @@ +object A { def x = 3 } diff --git a/bridge/src/sbt-test/source-dependencies/export-jars/changes/B.scala b/bridge/src/sbt-test/source-dependencies/export-jars/changes/B.scala new file mode 100644 index 000000000..058527993 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/export-jars/changes/B.scala @@ -0,0 +1,4 @@ +object B +{ + def main(args: Array[String]) = assert(args(0).toInt == A.x ) +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/export-jars/changes/build2.sbt b/bridge/src/sbt-test/source-dependencies/export-jars/changes/build2.sbt new file mode 100644 index 000000000..0f5735bc8 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/export-jars/changes/build2.sbt @@ -0,0 +1 @@ +exportJars := true
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/export-jars/project/Build.scala b/bridge/src/sbt-test/source-dependencies/export-jars/project/Build.scala new file mode 100644 index 000000000..4a783acbe --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/export-jars/project/Build.scala @@ -0,0 +1,7 @@ +import sbt._ + +object Build extends Build +{ + lazy val root = Project("root", file(".")) dependsOn(a) + lazy val a = Project("a", file("a")) +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/export-jars/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/export-jars/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/export-jars/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/export-jars/test b/bridge/src/sbt-test/source-dependencies/export-jars/test new file mode 100644 index 000000000..e06ce1ee5 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/export-jars/test @@ -0,0 +1,27 @@ +$ copy-file changes/B.scala B.scala + +$ copy-file changes/A1.scala a/A.scala +> run 1 +$ copy-file changes/A2.scala a/A.scala + +# done this way because last modified times often have ~1s resolution +$ sleep 2000 +> run 2 +$ copy-file changes/A3.scala a/A.scala + +$ sleep 2000 +> run 3 + +$ copy-file changes/build2.sbt build.sbt +> reload + +$ copy-file changes/A1.scala a/A.scala +> run 1 +$ copy-file changes/A2.scala a/A.scala + +$ sleep 2000 +> run 2 +$ copy-file changes/A3.scala a/A.scala + +$ sleep 2000 +> run 3 diff --git a/bridge/src/sbt-test/source-dependencies/ext/A.scala b/bridge/src/sbt-test/source-dependencies/ext/A.scala new file mode 100644 index 000000000..ad9931075 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/ext/A.scala @@ -0,0 +1,5 @@ +import sun.net.spi.nameservice.dns.DNSNameService + +object A { + val x = new DNSNameService +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/ext/build.sbt b/bridge/src/sbt-test/source-dependencies/ext/build.sbt new file mode 100644 index 000000000..8aaec76ec --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/ext/build.sbt @@ -0,0 +1,9 @@ +import complete.DefaultParsers._ + +val checkIterations = inputKey[Unit]("Verifies the accumlated number of iterations of incremental compilation.") + +checkIterations := { + val expected: Int = (Space ~> NatBasic).parsed + val actual: Int = (compile in Compile).value.compilations.allCompilations.size + assert(expected == actual, s"Expected $expected compilations, got $actual") +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/ext/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/ext/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/ext/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/ext/test b/bridge/src/sbt-test/source-dependencies/ext/test new file mode 100644 index 000000000..2b01a3de7 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/ext/test @@ -0,0 +1,7 @@ +# initial compilation +> checkIterations 1 + +# no further compilation should be necessary, since nothing changed +# previously, a dependency on a jar in <java.home>lib/ext/ would +# always force recompilation +> checkIterations 1
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/false-error/A.scala b/bridge/src/sbt-test/source-dependencies/false-error/A.scala new file mode 100644 index 000000000..64675b5e3 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/false-error/A.scala @@ -0,0 +1,4 @@ +object A { + val x = 3 + val z: Int = B.y +} diff --git a/bridge/src/sbt-test/source-dependencies/false-error/B.scala b/bridge/src/sbt-test/source-dependencies/false-error/B.scala new file mode 100644 index 000000000..756aeacf6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/false-error/B.scala @@ -0,0 +1,3 @@ +object B { + val y = A.x +} diff --git a/bridge/src/sbt-test/source-dependencies/false-error/changes/A.scala b/bridge/src/sbt-test/source-dependencies/false-error/changes/A.scala new file mode 100644 index 000000000..b2c9dfb26 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/false-error/changes/A.scala @@ -0,0 +1,4 @@ +object A { + val x = "3" + val z: String = B.y +} diff --git a/bridge/src/sbt-test/source-dependencies/false-error/pending b/bridge/src/sbt-test/source-dependencies/false-error/pending new file mode 100644 index 000000000..80c8ec9bf --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/false-error/pending @@ -0,0 +1,5 @@ +> compile + +$ copy-file changes/A.scala A.scala + +> compile diff --git a/bridge/src/sbt-test/source-dependencies/false-error/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/false-error/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/false-error/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/fbounded-existentials/fbounds.scala b/bridge/src/sbt-test/source-dependencies/fbounded-existentials/fbounds.scala new file mode 100644 index 000000000..60fe40879 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/fbounded-existentials/fbounds.scala @@ -0,0 +1,10 @@ +class Dep { + // The API representation for `bla`'s result type contains a cycle + // (an existential's type variable's bound is the existential type itself) + // This results in a stack overflow while showing the API diff. + // Note that the actual result type in the compiler is not cyclic + // (the f-bounded existential for Comparable is truncated) + def bla(c: Boolean) = if (c) new Value else "bla" +} + +class Value extends java.lang.Comparable[Value] { def compareTo(that: Value): Int = 1 }
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/fbounded-existentials/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/fbounded-existentials/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/fbounded-existentials/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/fbounded-existentials/test b/bridge/src/sbt-test/source-dependencies/fbounded-existentials/test new file mode 100644 index 000000000..5df2af1f3 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/fbounded-existentials/test @@ -0,0 +1 @@ +> compile diff --git a/bridge/src/sbt-test/source-dependencies/implicit-params/A.scala b/bridge/src/sbt-test/source-dependencies/implicit-params/A.scala new file mode 100644 index 000000000..598d266d4 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/implicit-params/A.scala @@ -0,0 +1,6 @@ +class A +{ + implicit def e: E = new E + def x(i: Int)(implicit y: E): String = "" +} +class E
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/implicit-params/B.scala b/bridge/src/sbt-test/source-dependencies/implicit-params/B.scala new file mode 100644 index 000000000..3273cdceb --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/implicit-params/B.scala @@ -0,0 +1,4 @@ +object B extends A +{ + val y = x(3) +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/implicit-params/changes/A.scala b/bridge/src/sbt-test/source-dependencies/implicit-params/changes/A.scala new file mode 100644 index 000000000..2de2c62ee --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/implicit-params/changes/A.scala @@ -0,0 +1,6 @@ +class A +{ + implicit def e: E = new E + def x(i: Int)(y: E): String = "" +} +class E
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/implicit-params/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/implicit-params/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/implicit-params/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/implicit-params/test b/bridge/src/sbt-test/source-dependencies/implicit-params/test new file mode 100644 index 000000000..5a2bcc0f4 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/implicit-params/test @@ -0,0 +1,8 @@ +> compile + +# make implicit parameters in A.x be explicit +$ copy-file changes/A.scala A.scala + +# Both A.scala and B.scala need to be recompiled because the parameter section is no longer implicit +# and it should be a compile error +-> compile
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/implicit-search-companion-scope/changes/A1.scala b/bridge/src/sbt-test/source-dependencies/implicit-search-companion-scope/changes/A1.scala new file mode 100644 index 000000000..5a58c097b --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/implicit-search-companion-scope/changes/A1.scala @@ -0,0 +1,2 @@ +trait A +object A diff --git a/bridge/src/sbt-test/source-dependencies/implicit-search-companion-scope/changes/A2.scala b/bridge/src/sbt-test/source-dependencies/implicit-search-companion-scope/changes/A2.scala new file mode 100644 index 000000000..8a0b629bc --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/implicit-search-companion-scope/changes/A2.scala @@ -0,0 +1,4 @@ +trait A +object A { + implicit def m[A]: M[A] = ??? +} diff --git a/bridge/src/sbt-test/source-dependencies/implicit-search-companion-scope/changes/B.scala b/bridge/src/sbt-test/source-dependencies/implicit-search-companion-scope/changes/B.scala new file mode 100644 index 000000000..c49ed55ad --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/implicit-search-companion-scope/changes/B.scala @@ -0,0 +1,2 @@ + +trait B extends A diff --git a/bridge/src/sbt-test/source-dependencies/implicit-search-companion-scope/changes/C.scala b/bridge/src/sbt-test/source-dependencies/implicit-search-companion-scope/changes/C.scala new file mode 100644 index 000000000..7fd803222 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/implicit-search-companion-scope/changes/C.scala @@ -0,0 +1,3 @@ +object Test { + implicitly[M[B]] +} diff --git a/bridge/src/sbt-test/source-dependencies/implicit-search-companion-scope/changes/M.scala b/bridge/src/sbt-test/source-dependencies/implicit-search-companion-scope/changes/M.scala new file mode 100644 index 000000000..9464f4238 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/implicit-search-companion-scope/changes/M.scala @@ -0,0 +1,4 @@ +class M[A](a: A) +object M { + implicit def m[A]: M[A] = ??? +} diff --git a/bridge/src/sbt-test/source-dependencies/implicit-search-companion-scope/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/implicit-search-companion-scope/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/implicit-search-companion-scope/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/implicit-search-companion-scope/test b/bridge/src/sbt-test/source-dependencies/implicit-search-companion-scope/test new file mode 100644 index 000000000..701b2c9a5 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/implicit-search-companion-scope/test @@ -0,0 +1,12 @@ +# Tests if dependencies on implicit scope are tracked properly +$ copy-file changes/A1.scala A.scala +$ copy-file changes/B.scala B.scala +$ copy-file changes/M.scala M.scala +$ copy-file changes/C.scala C.scala +> compile + +$ copy-file changes/A2.scala A.scala +-> compile + +> clean +-> compile diff --git a/bridge/src/sbt-test/source-dependencies/implicit-search/changes/A1.scala b/bridge/src/sbt-test/source-dependencies/implicit-search/changes/A1.scala new file mode 100644 index 000000000..7aa91d096 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/implicit-search/changes/A1.scala @@ -0,0 +1 @@ +object A diff --git a/bridge/src/sbt-test/source-dependencies/implicit-search/changes/A2.scala b/bridge/src/sbt-test/source-dependencies/implicit-search/changes/A2.scala new file mode 100644 index 000000000..45930d594 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/implicit-search/changes/A2.scala @@ -0,0 +1,3 @@ +object A { + val x = 1 +} diff --git a/bridge/src/sbt-test/source-dependencies/implicit-search/changes/B.scala b/bridge/src/sbt-test/source-dependencies/implicit-search/changes/B.scala new file mode 100644 index 000000000..3e5db4c7e --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/implicit-search/changes/B.scala @@ -0,0 +1,4 @@ +object B { + implicit val x: Ordering[Int] = ??? +} + diff --git a/bridge/src/sbt-test/source-dependencies/implicit-search/changes/C.scala b/bridge/src/sbt-test/source-dependencies/implicit-search/changes/C.scala new file mode 100644 index 000000000..bdf19dd1d --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/implicit-search/changes/C.scala @@ -0,0 +1,6 @@ +object C { + import A._, B._ + implicitly[Ordering[Int]] + + def main(args: Array[String]): Unit = () +} diff --git a/bridge/src/sbt-test/source-dependencies/implicit-search/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/implicit-search/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/implicit-search/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/implicit-search/test b/bridge/src/sbt-test/source-dependencies/implicit-search/test new file mode 100644 index 000000000..1b73c1fe6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/implicit-search/test @@ -0,0 +1,9 @@ +$ copy-file changes/A1.scala A.scala +$ copy-file changes/B.scala B.scala +$ copy-file changes/C.scala C.scala +> compile +-> run + +$ copy-file changes/A2.scala A.scala +> compile +-> run diff --git a/bridge/src/sbt-test/source-dependencies/implicit/A.scala b/bridge/src/sbt-test/source-dependencies/implicit/A.scala new file mode 100644 index 000000000..765f66013 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/implicit/A.scala @@ -0,0 +1,4 @@ +class A +{ + implicit def x(i: Int): String = i.toString +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/implicit/B.scala b/bridge/src/sbt-test/source-dependencies/implicit/B.scala new file mode 100644 index 000000000..ec0200dfa --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/implicit/B.scala @@ -0,0 +1,4 @@ +object B extends A +{ + val x: String = 3 +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/implicit/changes/A.scala b/bridge/src/sbt-test/source-dependencies/implicit/changes/A.scala new file mode 100644 index 000000000..24f8e4069 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/implicit/changes/A.scala @@ -0,0 +1,4 @@ +class A +{ + def x(i: Int): String = i.toString +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/implicit/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/implicit/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/implicit/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/implicit/test b/bridge/src/sbt-test/source-dependencies/implicit/test new file mode 100644 index 000000000..73aaab1d9 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/implicit/test @@ -0,0 +1,7 @@ +> compile + +# change A.x to be implicit +$ copy-file changes/A.scala A.scala + +# Both A.scala and B.scala need to be recompiled because a new implicit is available +-> compile
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/import-class/A.scala b/bridge/src/sbt-test/source-dependencies/import-class/A.scala new file mode 100644 index 000000000..a93bbe535 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/import-class/A.scala @@ -0,0 +1,3 @@ +package a + +class A diff --git a/bridge/src/sbt-test/source-dependencies/import-class/B.scala b/bridge/src/sbt-test/source-dependencies/import-class/B.scala new file mode 100644 index 000000000..0489f4a26 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/import-class/B.scala @@ -0,0 +1 @@ +import a.A diff --git a/bridge/src/sbt-test/source-dependencies/import-class/changes/A.scala b/bridge/src/sbt-test/source-dependencies/import-class/changes/A.scala new file mode 100644 index 000000000..2a93cdef5 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/import-class/changes/A.scala @@ -0,0 +1 @@ +package a diff --git a/bridge/src/sbt-test/source-dependencies/import-class/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/import-class/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/import-class/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/import-class/test b/bridge/src/sbt-test/source-dependencies/import-class/test new file mode 100644 index 000000000..7679ba52c --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/import-class/test @@ -0,0 +1,8 @@ +> compile + +# remove class a.A +$ copy-file changes/A.scala A.scala + +# 'import a.A' should now fail in B.scala +# succeeds because scalac doesn't track this dependency +-> compile diff --git a/bridge/src/sbt-test/source-dependencies/import-package/A.scala b/bridge/src/sbt-test/source-dependencies/import-package/A.scala new file mode 100644 index 000000000..1c94ccf3a --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/import-package/A.scala @@ -0,0 +1 @@ +package a.b
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/import-package/B.scala b/bridge/src/sbt-test/source-dependencies/import-package/B.scala new file mode 100644 index 000000000..10ee10d82 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/import-package/B.scala @@ -0,0 +1 @@ +import a.b
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/import-package/changes/A.scala b/bridge/src/sbt-test/source-dependencies/import-package/changes/A.scala new file mode 100644 index 000000000..d63f93ea4 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/import-package/changes/A.scala @@ -0,0 +1 @@ +package a
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/import-package/pending b/bridge/src/sbt-test/source-dependencies/import-package/pending new file mode 100644 index 000000000..5dc9851d5 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/import-package/pending @@ -0,0 +1,8 @@ +> compile + +# shorten the package defined in A from 'a.b' to 'a'. +$ copy-file changes/A.scala A.scala + +# 'import a.b' should now fail in B.scala +# succeeds because scalac doesn't track this dependency +-> compile diff --git a/bridge/src/sbt-test/source-dependencies/import-package/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/import-package/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/import-package/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/inherited-deps-java/A.java b/bridge/src/sbt-test/source-dependencies/inherited-deps-java/A.java new file mode 100644 index 000000000..894125a7e --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/inherited-deps-java/A.java @@ -0,0 +1 @@ +class A implements B.T<Integer>, E {} diff --git a/bridge/src/sbt-test/source-dependencies/inherited-deps-java/B.java b/bridge/src/sbt-test/source-dependencies/inherited-deps-java/B.java new file mode 100644 index 000000000..6b54edc7d --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/inherited-deps-java/B.java @@ -0,0 +1,11 @@ +public class B { + static interface T<X> extends C {} + + // not public, so this shouldn't be tracked as an inherited dependency + private class Q implements E<Integer> {} + + public void x(int i) { + // not public, not an inherited dependency + D j = new D() {}; + } +} diff --git a/bridge/src/sbt-test/source-dependencies/inherited-deps-java/C.java b/bridge/src/sbt-test/source-dependencies/inherited-deps-java/C.java new file mode 100644 index 000000000..6c06f4033 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/inherited-deps-java/C.java @@ -0,0 +1 @@ +interface C extends D {} diff --git a/bridge/src/sbt-test/source-dependencies/inherited-deps-java/D.java b/bridge/src/sbt-test/source-dependencies/inherited-deps-java/D.java new file mode 100644 index 000000000..9455ef5b0 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/inherited-deps-java/D.java @@ -0,0 +1 @@ +interface D extends G.P {} diff --git a/bridge/src/sbt-test/source-dependencies/inherited-deps-java/E.java b/bridge/src/sbt-test/source-dependencies/inherited-deps-java/E.java new file mode 100644 index 000000000..d5e4d6517 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/inherited-deps-java/E.java @@ -0,0 +1 @@ +public interface E<T> {} diff --git a/bridge/src/sbt-test/source-dependencies/inherited-deps-java/F.java b/bridge/src/sbt-test/source-dependencies/inherited-deps-java/F.java new file mode 100644 index 000000000..e205778d5 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/inherited-deps-java/F.java @@ -0,0 +1,3 @@ +public class F { + public C q() { return null; } +} diff --git a/bridge/src/sbt-test/source-dependencies/inherited-deps-java/G.java b/bridge/src/sbt-test/source-dependencies/inherited-deps-java/G.java new file mode 100644 index 000000000..ed3429f8c --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/inherited-deps-java/G.java @@ -0,0 +1,3 @@ +public class G { + static interface P extends J {} +} diff --git a/bridge/src/sbt-test/source-dependencies/inherited-deps-java/J.java b/bridge/src/sbt-test/source-dependencies/inherited-deps-java/J.java new file mode 100644 index 000000000..8aeeb05b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/inherited-deps-java/J.java @@ -0,0 +1 @@ +public interface J {} diff --git a/bridge/src/sbt-test/source-dependencies/inherited-deps-java/build.sbt b/bridge/src/sbt-test/source-dependencies/inherited-deps-java/build.sbt new file mode 100644 index 000000000..c25b54921 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/inherited-deps-java/build.sbt @@ -0,0 +1,30 @@ +// this test is specific to the old incremental compilation algorithm +incOptions := incOptions.value.withNameHashing(false) + +lazy val verifyDeps = taskKey[Unit]("verify inherited dependencies are properly extracted") + +verifyDeps := { + val a = compile.in(Compile).value + same(a.relations.publicInherited.internal.forwardMap, expectedDeps.forwardMap) +} + +lazy val expected = Seq( + "A" -> Seq("C", "D", "E", "G", "J"), + "B" -> Seq("C", "D", "G", "J"), + "C" -> Seq("D", "G", "J"), + "D" -> Seq("G", "J"), + "E" -> Seq(), + "F" -> Seq(), + "G" -> Seq("J"), + "J" -> Seq() +) +lazy val pairs = + expected.map { case (from,tos) => + (toFile(from), tos.map(toFile)) + } +lazy val expectedDeps = (Relation.empty[File,File] /: pairs) { case (r, (x,ys)) => r + (x,ys) } +def toFile(s: String) = file(s + ".java").getAbsoluteFile + +def same[T](x: T, y: T): Unit = { + assert(x == y, s"\nActual: $x, \nExpected: $y") +} diff --git a/bridge/src/sbt-test/source-dependencies/inherited-deps-java/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/inherited-deps-java/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/inherited-deps-java/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/inherited-deps-java/test b/bridge/src/sbt-test/source-dependencies/inherited-deps-java/test new file mode 100644 index 000000000..e5d477601 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/inherited-deps-java/test @@ -0,0 +1 @@ +> verifyDeps diff --git a/bridge/src/sbt-test/source-dependencies/inherited_type_params/A.scala b/bridge/src/sbt-test/source-dependencies/inherited_type_params/A.scala new file mode 100644 index 000000000..9de61dd5f --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/inherited_type_params/A.scala @@ -0,0 +1,7 @@ + +trait Equal[-A] { + def equal(a1: A, a2: A): Boolean +} +object Test { + implicit def TraversableEqual[CC[X] <: collection.TraversableLike[X, CC[X]] with Traversable[X], A: Equal]: Equal[CC[A]] = error("") +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/inherited_type_params/build.sbt b/bridge/src/sbt-test/source-dependencies/inherited_type_params/build.sbt new file mode 100644 index 000000000..a5982f901 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/inherited_type_params/build.sbt @@ -0,0 +1,7 @@ +name := "test" + +TaskKey[Unit]("check-same") <<= compile in Configurations.Compile map { analysis => + analysis.apis.internal foreach { case (_, api) => + assert( xsbt.api.SameAPI(api.api, api.api) ) + } +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/inherited_type_params/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/inherited_type_params/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/inherited_type_params/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/inherited_type_params/test b/bridge/src/sbt-test/source-dependencies/inherited_type_params/test new file mode 100644 index 000000000..8434347c5 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/inherited_type_params/test @@ -0,0 +1 @@ +> check-same
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/intermediate-error/A.scala b/bridge/src/sbt-test/source-dependencies/intermediate-error/A.scala new file mode 100644 index 000000000..392db0805 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/intermediate-error/A.scala @@ -0,0 +1,6 @@ +object A +{ + def x = 3 + //def x: String = 3 + //def x: String = "3" +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/intermediate-error/B.scala b/bridge/src/sbt-test/source-dependencies/intermediate-error/B.scala new file mode 100644 index 000000000..1a1e0c06f --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/intermediate-error/B.scala @@ -0,0 +1,4 @@ +object B +{ + val y: Int = A.x +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/intermediate-error/changes/A2.scala b/bridge/src/sbt-test/source-dependencies/intermediate-error/changes/A2.scala new file mode 100644 index 000000000..ba9953954 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/intermediate-error/changes/A2.scala @@ -0,0 +1,6 @@ +object A +{ + //def x = 3 + def x: String = 3 + //def x: String = "3" +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/intermediate-error/changes/A3.scala b/bridge/src/sbt-test/source-dependencies/intermediate-error/changes/A3.scala new file mode 100644 index 000000000..f020041ea --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/intermediate-error/changes/A3.scala @@ -0,0 +1,6 @@ +object A +{ + //def x = 3 + //def x: String = 3 + def x: String = "3" +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/intermediate-error/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/intermediate-error/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/intermediate-error/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/intermediate-error/test b/bridge/src/sbt-test/source-dependencies/intermediate-error/test new file mode 100644 index 000000000..e3016a9c6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/intermediate-error/test @@ -0,0 +1,7 @@ +> compile + +$ copy-file changes/A2.scala A.scala +-> compile + +$ copy-file changes/A3.scala A.scala +-> compile
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/java-analysis-serialization-error/Outer.java b/bridge/src/sbt-test/source-dependencies/java-analysis-serialization-error/Outer.java new file mode 100644 index 000000000..0cf8276a9 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/java-analysis-serialization-error/Outer.java @@ -0,0 +1 @@ +public class Outer { private class T extends Thread {} }
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/java-analysis-serialization-error/build.sbt b/bridge/src/sbt-test/source-dependencies/java-analysis-serialization-error/build.sbt new file mode 100644 index 000000000..1b1ddefb9 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/java-analysis-serialization-error/build.sbt @@ -0,0 +1 @@ +incOptions := incOptions.value.withNameHashing(true).withApiDebug(true) diff --git a/bridge/src/sbt-test/source-dependencies/java-analysis-serialization-error/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/java-analysis-serialization-error/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/java-analysis-serialization-error/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/java-analysis-serialization-error/test b/bridge/src/sbt-test/source-dependencies/java-analysis-serialization-error/test new file mode 100644 index 000000000..5df2af1f3 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/java-analysis-serialization-error/test @@ -0,0 +1 @@ +> compile diff --git a/bridge/src/sbt-test/source-dependencies/java-basic/changes/A.java b/bridge/src/sbt-test/source-dependencies/java-basic/changes/A.java new file mode 100644 index 000000000..c84f997f4 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/java-basic/changes/A.java @@ -0,0 +1,6 @@ +package a; + +public class A +{ + public static int x() { return 3; } +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/java-basic/changes/A2.java b/bridge/src/sbt-test/source-dependencies/java-basic/changes/A2.java new file mode 100644 index 000000000..36270f805 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/java-basic/changes/A2.java @@ -0,0 +1,6 @@ +package a.b; + +public class A +{ + public static int x() { return 3; } +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/java-basic/changes/B1.java b/bridge/src/sbt-test/source-dependencies/java-basic/changes/B1.java new file mode 100644 index 000000000..ec9a67e1a --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/java-basic/changes/B1.java @@ -0,0 +1,6 @@ +package a.b; + +public class B +{ + public int y() { return 3; } +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/java-basic/changes/B2.java b/bridge/src/sbt-test/source-dependencies/java-basic/changes/B2.java new file mode 100644 index 000000000..551900114 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/java-basic/changes/B2.java @@ -0,0 +1,6 @@ +package a.b; + +public class B +{ + public int y() { return a.A.x(); } +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/java-basic/changes/B3.java b/bridge/src/sbt-test/source-dependencies/java-basic/changes/B3.java new file mode 100644 index 000000000..1ec729b74 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/java-basic/changes/B3.java @@ -0,0 +1,6 @@ +package a.b; + +public class B +{ + public static void main(String[] args) {} +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/java-basic/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/java-basic/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/java-basic/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/java-basic/test b/bridge/src/sbt-test/source-dependencies/java-basic/test new file mode 100644 index 000000000..9dac40735 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/java-basic/test @@ -0,0 +1,45 @@ +# Basic test for Java dependency tracking +> 'eval System.setProperty("xsbt.inc.debug", "true")' + +# A is a basic Java file with no dependencies. Just a basic check for Java compilation +$ copy-file changes/A.java src/main/java/a/A.java +> compile + +# A2 is a basic Java file with no dependencies. This is added to verify +# that classes are properly mapped back to their source. +# (There are two files named A.java now, one in a/ and one in a/b) +$ copy-file changes/A2.java src/main/java/a/b/A.java +> compile + +# This adds B, another basic Java file with no dependencies +$ copy-file changes/B1.java src/main/java/a/b/B.java +> compile + +# Now, modify B so that it depends on a.A +# This ensures that dependencies on a source not included in the compilation +# (a/A.java has not changed) are tracked +$ copy-file changes/B2.java src/main/java/a/b/B.java +> compile + +# Remove a.b.A and there should be no problem compiling, since B should +# have recorded a dependency on a.A and not a.b.A +$ delete src/main/java/a/b/A.java +> compile + +# Remove a.A and B should be recompiled if the dependency on a.A was properly +# recorded. This should be a compile error, since we haven't updated B to not +# depend on A +$ delete src/main/java/a/A.java +-> compile + +# Replace B with a new B that doesn't depend on a.A and so it should compile +# It shouldn't run though, because it doesn't have a main method +$ copy-file changes/B1.java src/main/java/a/b/B.java +> compile +-> run + + +# Replace B with a new B that has a main method and should therefore run +# if the main method was properly detected +$ copy-file changes/B3.java src/main/java/a/b/B.java +> run
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/java-generic-workaround/A.java b/bridge/src/sbt-test/source-dependencies/java-generic-workaround/A.java new file mode 100644 index 000000000..7ac3d1a41 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/java-generic-workaround/A.java @@ -0,0 +1,7 @@ + +public class A<T> { + class B { + class C { + } + } +} diff --git a/bridge/src/sbt-test/source-dependencies/java-generic-workaround/DefaultTreeTableSorter.java b/bridge/src/sbt-test/source-dependencies/java-generic-workaround/DefaultTreeTableSorter.java new file mode 100644 index 000000000..eec11ccea --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/java-generic-workaround/DefaultTreeTableSorter.java @@ -0,0 +1,15 @@ +import javax.swing.DefaultRowSorter; +import javax.swing.tree.TreeModel; +import javax.swing.tree.TreePath; + +public class DefaultTreeTableSorter<T extends TreeModel, C extends TreeColumnModel, I> + implements TreeTableSorter<T,C>, TreeTableSorter.SortCycle { + + public class NodeSorter extends DefaultRowSorter<T,I> implements SortCycle { + + protected TreeTableWrapper getTreeTableModelWrapper() { + return (TreeTableWrapper)getModelWrapper(); + } + protected abstract class TreeTableWrapper extends ModelWrapper<T,I> {} + } +} diff --git a/bridge/src/sbt-test/source-dependencies/java-generic-workaround/TreeColumnModel.java b/bridge/src/sbt-test/source-dependencies/java-generic-workaround/TreeColumnModel.java new file mode 100644 index 000000000..bd66a91b8 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/java-generic-workaround/TreeColumnModel.java @@ -0,0 +1 @@ +public interface TreeColumnModel {} diff --git a/bridge/src/sbt-test/source-dependencies/java-generic-workaround/TreeTableSorter.java b/bridge/src/sbt-test/source-dependencies/java-generic-workaround/TreeTableSorter.java new file mode 100644 index 000000000..08b9f38f5 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/java-generic-workaround/TreeTableSorter.java @@ -0,0 +1,5 @@ +import javax.swing.tree.TreeModel; + +public interface TreeTableSorter<T extends TreeModel, C extends TreeColumnModel> { + public interface SortCycle {} +} diff --git a/bridge/src/sbt-test/source-dependencies/java-generic-workaround/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/java-generic-workaround/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/java-generic-workaround/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/java-generic-workaround/test b/bridge/src/sbt-test/source-dependencies/java-generic-workaround/test new file mode 100644 index 000000000..125967284 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/java-generic-workaround/test @@ -0,0 +1,3 @@ +# generic signatures fails to parse due to http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6476261 +# tests workaround for https://github.com/sbt/sbt/issues/1035 +> compile diff --git a/bridge/src/sbt-test/source-dependencies/java-mixed/JJ.java b/bridge/src/sbt-test/source-dependencies/java-mixed/JJ.java new file mode 100644 index 000000000..18d52ae30 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/java-mixed/JJ.java @@ -0,0 +1,5 @@ +public class JJ { + public static void main(String[] args) { + new S().foo("ahoy"); + } +} diff --git a/bridge/src/sbt-test/source-dependencies/java-mixed/build.sbt b/bridge/src/sbt-test/source-dependencies/java-mixed/build.sbt new file mode 100644 index 000000000..522224a38 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/java-mixed/build.sbt @@ -0,0 +1 @@ +compileOrder := CompileOrder.Mixed
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/java-mixed/changes/S1.scala b/bridge/src/sbt-test/source-dependencies/java-mixed/changes/S1.scala new file mode 100644 index 000000000..486f40262 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/java-mixed/changes/S1.scala @@ -0,0 +1,3 @@ +class S { + def foo(s:String): Unit = println("I am foo") +} diff --git a/bridge/src/sbt-test/source-dependencies/java-mixed/changes/S2.scala b/bridge/src/sbt-test/source-dependencies/java-mixed/changes/S2.scala new file mode 100644 index 000000000..63bc37d77 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/java-mixed/changes/S2.scala @@ -0,0 +1,3 @@ +class S { + def foo2(s:String): Unit = println("I am foo") +} diff --git a/bridge/src/sbt-test/source-dependencies/java-mixed/changes/build.sbt b/bridge/src/sbt-test/source-dependencies/java-mixed/changes/build.sbt new file mode 100644 index 000000000..f4f9b5bf7 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/java-mixed/changes/build.sbt @@ -0,0 +1 @@ +compileOrder := CompileOrder.ScalaThenJava
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/java-mixed/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/java-mixed/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/java-mixed/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/java-mixed/test b/bridge/src/sbt-test/source-dependencies/java-mixed/test new file mode 100644 index 000000000..60402f1e6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/java-mixed/test @@ -0,0 +1,13 @@ +$ copy-file changes/S1.scala S.scala +> compile +$ copy-file changes/S2.scala S.scala +-> compile + +> clean +$ copy-file changes/build.sbt build.sbt +> reload + +$ copy-file changes/S1.scala S.scala +> compile +$ copy-file changes/S2.scala S.scala +-> compile diff --git a/bridge/src/sbt-test/source-dependencies/java-static/changes/J1.java b/bridge/src/sbt-test/source-dependencies/java-static/changes/J1.java new file mode 100644 index 000000000..cf042ce22 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/java-static/changes/J1.java @@ -0,0 +1,4 @@ +public class J +{ + public static final Integer x = 3; +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/java-static/changes/J2.java b/bridge/src/sbt-test/source-dependencies/java-static/changes/J2.java new file mode 100644 index 000000000..8ff2e24c6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/java-static/changes/J2.java @@ -0,0 +1,4 @@ +public class J +{ + public static final String x = "3"; +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/java-static/changes/S.scala b/bridge/src/sbt-test/source-dependencies/java-static/changes/S.scala new file mode 100644 index 000000000..45436972b --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/java-static/changes/S.scala @@ -0,0 +1,4 @@ +object S +{ + val y: Int = J.x +} diff --git a/bridge/src/sbt-test/source-dependencies/java-static/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/java-static/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/java-static/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/java-static/test b/bridge/src/sbt-test/source-dependencies/java-static/test new file mode 100644 index 000000000..42890ca74 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/java-static/test @@ -0,0 +1,24 @@ +# When a Java class is loaded from a class file and not parsed from a source file, scalac reports +# the statics as an object without a file and so the Analyzer must know to look for the +# object's linked class. +# This test verifies this happens. +# The test compiles a Java class with a static field. +# It then adds a Scala object that references the static field. Because the object only depends on a +# static member and because the Java source is not included in the compilation (since it didn't change), +# this triggers the special case above. + +# add and compile the Java source +$ copy-file changes/J1.java src/main/java/J.java +> compile + +# add and compile the Scala source +$ copy-file changes/S.scala src/main/scala/S.scala +> compile + +# change the Java source so that a compile error should occur if S.scala is also recompiled (which will happen if the dependency was properly recorded) +$ copy-file changes/J2.java src/main/java/J.java +-> compile + +# verify it should have failed by doing a full recompilation +> clean +-> compile
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/lazy-val/A.scala b/bridge/src/sbt-test/source-dependencies/lazy-val/A.scala new file mode 100644 index 000000000..fc3870856 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/lazy-val/A.scala @@ -0,0 +1,4 @@ +class A +{ + val x = 3 +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/lazy-val/B.scala b/bridge/src/sbt-test/source-dependencies/lazy-val/B.scala new file mode 100644 index 000000000..3ddfddb61 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/lazy-val/B.scala @@ -0,0 +1,4 @@ +class B extends A +{ + override val x = 3 +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/lazy-val/changes/A.scala b/bridge/src/sbt-test/source-dependencies/lazy-val/changes/A.scala new file mode 100644 index 000000000..805901802 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/lazy-val/changes/A.scala @@ -0,0 +1,4 @@ +class A +{ + lazy val x = 3 +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/lazy-val/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/lazy-val/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/lazy-val/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/lazy-val/test b/bridge/src/sbt-test/source-dependencies/lazy-val/test new file mode 100644 index 000000000..f870aaef3 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/lazy-val/test @@ -0,0 +1,6 @@ +> compile + +# replace val x with lazy val x +$ copy-file changes/A.scala A.scala + +-> compile
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/less-inter-inv-java/A.java b/bridge/src/sbt-test/source-dependencies/less-inter-inv-java/A.java new file mode 100644 index 000000000..2bce1ee78 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/less-inter-inv-java/A.java @@ -0,0 +1,3 @@ +public class A { + public Integer x() { return 3; } +} diff --git a/bridge/src/sbt-test/source-dependencies/less-inter-inv-java/B.java b/bridge/src/sbt-test/source-dependencies/less-inter-inv-java/B.java new file mode 100644 index 000000000..7e9bb5574 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/less-inter-inv-java/B.java @@ -0,0 +1 @@ +public class B extends A {} diff --git a/bridge/src/sbt-test/source-dependencies/less-inter-inv-java/C.java b/bridge/src/sbt-test/source-dependencies/less-inter-inv-java/C.java new file mode 100644 index 000000000..042c2b2a3 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/less-inter-inv-java/C.java @@ -0,0 +1 @@ +public class C extends B {} diff --git a/bridge/src/sbt-test/source-dependencies/less-inter-inv-java/D.java b/bridge/src/sbt-test/source-dependencies/less-inter-inv-java/D.java new file mode 100644 index 000000000..03e6ad740 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/less-inter-inv-java/D.java @@ -0,0 +1,4 @@ +public class D { + public static final C c = new C(); + public static String x() { return c.x().toString(); } +} diff --git a/bridge/src/sbt-test/source-dependencies/less-inter-inv-java/E.java b/bridge/src/sbt-test/source-dependencies/less-inter-inv-java/E.java new file mode 100644 index 000000000..d28336ed5 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/less-inter-inv-java/E.java @@ -0,0 +1,5 @@ +public class E { + public static void main(String[] args) { + assert(D.x() == "3"); + } +} diff --git a/bridge/src/sbt-test/source-dependencies/less-inter-inv-java/build.sbt b/bridge/src/sbt-test/source-dependencies/less-inter-inv-java/build.sbt new file mode 100644 index 000000000..d23dff705 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/less-inter-inv-java/build.sbt @@ -0,0 +1,10 @@ +import complete.DefaultParsers._ + +val checkIterations = inputKey[Unit]("Verifies the accumlated number of iterations of incremental compilation.") + +checkIterations := { + val expected: Int = (Space ~> NatBasic).parsed + val actual: Int = (compile in Compile).value.compilations.allCompilations.size + assert(expected == actual, s"Expected $expected compilations, got $actual") +} + diff --git a/bridge/src/sbt-test/source-dependencies/less-inter-inv-java/changes/A2.java b/bridge/src/sbt-test/source-dependencies/less-inter-inv-java/changes/A2.java new file mode 100644 index 000000000..610c20407 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/less-inter-inv-java/changes/A2.java @@ -0,0 +1,3 @@ +public class A { + public String x() { return "3"; } +} diff --git a/bridge/src/sbt-test/source-dependencies/less-inter-inv-java/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/less-inter-inv-java/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/less-inter-inv-java/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/less-inter-inv-java/test b/bridge/src/sbt-test/source-dependencies/less-inter-inv-java/test new file mode 100644 index 000000000..85a7c97e9 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/less-inter-inv-java/test @@ -0,0 +1,9 @@ +# 1 iteration from initial full compile +> run +$ copy-file changes/A2.java A.java + +# 1 iteration for the initial changes +# 1 iteration to recompile all descendents and direct dependencies +# no further iteration, because APIs of directs don't change +> run +> checkIterations 3 diff --git a/bridge/src/sbt-test/source-dependencies/less-inter-inv/A.scala b/bridge/src/sbt-test/source-dependencies/less-inter-inv/A.scala new file mode 100644 index 000000000..a4f92f4fa --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/less-inter-inv/A.scala @@ -0,0 +1,3 @@ +class A { + def x = 3 +} diff --git a/bridge/src/sbt-test/source-dependencies/less-inter-inv/B.scala b/bridge/src/sbt-test/source-dependencies/less-inter-inv/B.scala new file mode 100644 index 000000000..a18aec3db --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/less-inter-inv/B.scala @@ -0,0 +1 @@ +class B extends A diff --git a/bridge/src/sbt-test/source-dependencies/less-inter-inv/C.scala b/bridge/src/sbt-test/source-dependencies/less-inter-inv/C.scala new file mode 100644 index 000000000..f6f5bb28f --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/less-inter-inv/C.scala @@ -0,0 +1 @@ +class C extends B diff --git a/bridge/src/sbt-test/source-dependencies/less-inter-inv/D.scala b/bridge/src/sbt-test/source-dependencies/less-inter-inv/D.scala new file mode 100644 index 000000000..55959c2a9 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/less-inter-inv/D.scala @@ -0,0 +1,4 @@ +object D { + val c = new C + def x: String = c.x.toString +} diff --git a/bridge/src/sbt-test/source-dependencies/less-inter-inv/E.scala b/bridge/src/sbt-test/source-dependencies/less-inter-inv/E.scala new file mode 100644 index 000000000..23e0805a0 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/less-inter-inv/E.scala @@ -0,0 +1,3 @@ +object E extends dotty.runtime.LegacyApp { + assert(D.x == "3") +} diff --git a/bridge/src/sbt-test/source-dependencies/less-inter-inv/build.sbt b/bridge/src/sbt-test/source-dependencies/less-inter-inv/build.sbt new file mode 100644 index 000000000..d23dff705 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/less-inter-inv/build.sbt @@ -0,0 +1,10 @@ +import complete.DefaultParsers._ + +val checkIterations = inputKey[Unit]("Verifies the accumlated number of iterations of incremental compilation.") + +checkIterations := { + val expected: Int = (Space ~> NatBasic).parsed + val actual: Int = (compile in Compile).value.compilations.allCompilations.size + assert(expected == actual, s"Expected $expected compilations, got $actual") +} + diff --git a/bridge/src/sbt-test/source-dependencies/less-inter-inv/changes/A2.scala b/bridge/src/sbt-test/source-dependencies/less-inter-inv/changes/A2.scala new file mode 100644 index 000000000..acab4a1ae --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/less-inter-inv/changes/A2.scala @@ -0,0 +1,3 @@ +class A { + def x = "3" +} diff --git a/bridge/src/sbt-test/source-dependencies/less-inter-inv/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/less-inter-inv/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/less-inter-inv/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/less-inter-inv/test b/bridge/src/sbt-test/source-dependencies/less-inter-inv/test new file mode 100644 index 000000000..c6df5698e --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/less-inter-inv/test @@ -0,0 +1,9 @@ +# 1 iteration from initial full compile +> run +$ copy-file changes/A2.scala A.scala + +# 1 iteration for the initial changes +# 1 iteration to recompile all descendents and direct dependencies +# no further iteration, because APIs of directs don't change +> run +> checkIterations 3 diff --git a/bridge/src/sbt-test/source-dependencies/linearization/A.scala b/bridge/src/sbt-test/source-dependencies/linearization/A.scala new file mode 100644 index 000000000..69399d3fb --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/linearization/A.scala @@ -0,0 +1,3 @@ +trait A { + def x = 3 +} diff --git a/bridge/src/sbt-test/source-dependencies/linearization/B.scala b/bridge/src/sbt-test/source-dependencies/linearization/B.scala new file mode 100644 index 000000000..608b53052 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/linearization/B.scala @@ -0,0 +1,3 @@ +trait B extends A { + override def x = super.x * 2 +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/linearization/C.scala b/bridge/src/sbt-test/source-dependencies/linearization/C.scala new file mode 100644 index 000000000..3fbd747e0 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/linearization/C.scala @@ -0,0 +1,3 @@ +trait C extends A { + override def x = super.x + 5 +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/linearization/D.scala b/bridge/src/sbt-test/source-dependencies/linearization/D.scala new file mode 100644 index 000000000..7b46ebf97 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/linearization/D.scala @@ -0,0 +1,2 @@ +// define the order +trait D extends C with B
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/linearization/E.scala b/bridge/src/sbt-test/source-dependencies/linearization/E.scala new file mode 100644 index 000000000..f69ea1d51 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/linearization/E.scala @@ -0,0 +1,2 @@ +// put a level in between D and its concrete class +trait E extends D diff --git a/bridge/src/sbt-test/source-dependencies/linearization/F.scala b/bridge/src/sbt-test/source-dependencies/linearization/F.scala new file mode 100644 index 000000000..6dda903f5 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/linearization/F.scala @@ -0,0 +1,3 @@ +object F extends E { + def main(args: Array[String]) = assert(x == args(0).toInt, x) +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/linearization/changes/D.scala b/bridge/src/sbt-test/source-dependencies/linearization/changes/D.scala new file mode 100644 index 000000000..84c173887 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/linearization/changes/D.scala @@ -0,0 +1 @@ +trait D extends B with C diff --git a/bridge/src/sbt-test/source-dependencies/linearization/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/linearization/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/linearization/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/linearization/test b/bridge/src/sbt-test/source-dependencies/linearization/test new file mode 100644 index 000000000..e6078ebfb --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/linearization/test @@ -0,0 +1,13 @@ +> compile + +# the value of F.x should be 16 +> run 16 + +# modify D.scala so that the linearization changes +$ copy-file changes/D.scala D.scala +# F.x becomes 11 +> compile + +# if F is recompiled, the value of x should be 11, otherwise it will still be 16 +# and this will fail +> run 11
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/named/A.scala b/bridge/src/sbt-test/source-dependencies/named/A.scala new file mode 100644 index 000000000..42afb874d --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/named/A.scala @@ -0,0 +1,3 @@ +object A { + def x(zz: Int, yy: Int) = yy - zz +} diff --git a/bridge/src/sbt-test/source-dependencies/named/B.scala b/bridge/src/sbt-test/source-dependencies/named/B.scala new file mode 100644 index 000000000..5699c4db8 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/named/B.scala @@ -0,0 +1,7 @@ +object B { + def main(args: Array[String]): Unit = + { + val result = A.x(zz = 3, yy = 4) + assert(result == args(0).toInt, result) + } +} diff --git a/bridge/src/sbt-test/source-dependencies/named/changes/A.scala b/bridge/src/sbt-test/source-dependencies/named/changes/A.scala new file mode 100644 index 000000000..04b150525 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/named/changes/A.scala @@ -0,0 +1,3 @@ +object A { + def x(yy: Int, zz: Int) = yy - zz +} diff --git a/bridge/src/sbt-test/source-dependencies/named/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/named/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/named/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/named/test b/bridge/src/sbt-test/source-dependencies/named/test new file mode 100644 index 000000000..28f1c58d3 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/named/test @@ -0,0 +1,16 @@ +# named parameters are only in 2.8 +#> ++2.8.0 + +> compile + +# result should be 1 +> run 1 + +# change order of arguments in A.x +$ copy-file changes/A.scala A.scala + +# Recompile +> compile + +# Should still get 1 and not -1 +> run 1 diff --git a/bridge/src/sbt-test/source-dependencies/nested-case-class/changes/A0.scala b/bridge/src/sbt-test/source-dependencies/nested-case-class/changes/A0.scala new file mode 100644 index 000000000..cc6a53b6a --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/nested-case-class/changes/A0.scala @@ -0,0 +1,11 @@ +package example + +class A { + case class B(x: Int) + def c = B +} +object A { + def main(args: Array[String]): Unit = { + (new A).c + } +} diff --git a/bridge/src/sbt-test/source-dependencies/nested-case-class/changes/A1.scala b/bridge/src/sbt-test/source-dependencies/nested-case-class/changes/A1.scala new file mode 100644 index 000000000..e71b1ef17 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/nested-case-class/changes/A1.scala @@ -0,0 +1,13 @@ +package example + +class VC(val self: Int) extends AnyVal + +class A { + case class B(x: VC) + def c = B +} +object A { + def main(args: Array[String]): Unit = { + (new A).c + } +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/nested-case-class/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/nested-case-class/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/nested-case-class/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/nested-case-class/test b/bridge/src/sbt-test/source-dependencies/nested-case-class/test new file mode 100644 index 000000000..28ed70321 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/nested-case-class/test @@ -0,0 +1,6 @@ +$ copy-file changes/A0.scala A.scala +> run + +# The same test case, but involving value classes +$ copy-file changes/A1.scala A.scala +> run diff --git a/bridge/src/sbt-test/source-dependencies/new-cyclic/changes/A2.scala b/bridge/src/sbt-test/source-dependencies/new-cyclic/changes/A2.scala new file mode 100644 index 000000000..c530efeb4 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/new-cyclic/changes/A2.scala @@ -0,0 +1 @@ +trait A { val x = (new B).y } diff --git a/bridge/src/sbt-test/source-dependencies/new-cyclic/pending b/bridge/src/sbt-test/source-dependencies/new-cyclic/pending new file mode 100644 index 000000000..82b078e7d --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/new-cyclic/pending @@ -0,0 +1,4 @@ +> compile + +$ copy-file changes/A2.scala src/main/scala/A.scala +-> compile diff --git a/bridge/src/sbt-test/source-dependencies/new-cyclic/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/new-cyclic/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/new-cyclic/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/new-cyclic/src/main/scala/A.scala b/bridge/src/sbt-test/source-dependencies/new-cyclic/src/main/scala/A.scala new file mode 100644 index 000000000..d6d4ebdd9 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/new-cyclic/src/main/scala/A.scala @@ -0,0 +1 @@ +trait A { val x = "hello" } diff --git a/bridge/src/sbt-test/source-dependencies/new-cyclic/src/main/scala/B.scala b/bridge/src/sbt-test/source-dependencies/new-cyclic/src/main/scala/B.scala new file mode 100644 index 000000000..4fa74512d --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/new-cyclic/src/main/scala/B.scala @@ -0,0 +1 @@ +class B extends A { val y = x } diff --git a/bridge/src/sbt-test/source-dependencies/new-pkg-dep/changes/A1.java b/bridge/src/sbt-test/source-dependencies/new-pkg-dep/changes/A1.java new file mode 100644 index 000000000..b448538ae --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/new-pkg-dep/changes/A1.java @@ -0,0 +1,2 @@ +package a; +public class A { public static final int x = 3; } diff --git a/bridge/src/sbt-test/source-dependencies/new-pkg-dep/changes/B0.scala b/bridge/src/sbt-test/source-dependencies/new-pkg-dep/changes/B0.scala new file mode 100644 index 000000000..ddeafd32d --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/new-pkg-dep/changes/B0.scala @@ -0,0 +1,2 @@ +package b +object B { val x = 3 } diff --git a/bridge/src/sbt-test/source-dependencies/new-pkg-dep/changes/B1.scala b/bridge/src/sbt-test/source-dependencies/new-pkg-dep/changes/B1.scala new file mode 100644 index 000000000..6f0f9f967 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/new-pkg-dep/changes/B1.scala @@ -0,0 +1,2 @@ +package b +object B { val x = a.A.x } diff --git a/bridge/src/sbt-test/source-dependencies/new-pkg-dep/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/new-pkg-dep/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/new-pkg-dep/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/new-pkg-dep/test b/bridge/src/sbt-test/source-dependencies/new-pkg-dep/test new file mode 100644 index 000000000..89251bcec --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/new-pkg-dep/test @@ -0,0 +1,8 @@ +$ copy-file changes/B0.scala B.scala +> compile + +$ copy-file changes/A1.java A.java +> compile + +$ copy-file changes/B1.scala B.scala +> compile diff --git a/bridge/src/sbt-test/source-dependencies/override/A.scala b/bridge/src/sbt-test/source-dependencies/override/A.scala new file mode 100644 index 000000000..43b95b9e9 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/override/A.scala @@ -0,0 +1,3 @@ +trait A { + def x: Int +} diff --git a/bridge/src/sbt-test/source-dependencies/override/B.scala b/bridge/src/sbt-test/source-dependencies/override/B.scala new file mode 100644 index 000000000..c7569ba51 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/override/B.scala @@ -0,0 +1,3 @@ +trait B extends A { + override def x = 2 +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/override/C.scala b/bridge/src/sbt-test/source-dependencies/override/C.scala new file mode 100644 index 000000000..24d656d4a --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/override/C.scala @@ -0,0 +1,3 @@ +trait C extends A { + def x = 5 +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/override/D.scala b/bridge/src/sbt-test/source-dependencies/override/D.scala new file mode 100644 index 000000000..1f0d0a274 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/override/D.scala @@ -0,0 +1 @@ +trait D extends C with B
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/override/changes/B2.scala b/bridge/src/sbt-test/source-dependencies/override/changes/B2.scala new file mode 100644 index 000000000..f314e6a46 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/override/changes/B2.scala @@ -0,0 +1,3 @@ +trait B extends A { + def x = 2 +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/override/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/override/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/override/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/override/test b/bridge/src/sbt-test/source-dependencies/override/test new file mode 100644 index 000000000..43f805d4e --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/override/test @@ -0,0 +1,3 @@ +> compile +$ copy-file changes/B2.scala B.scala +-> compile
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/parent-change/W.scala b/bridge/src/sbt-test/source-dependencies/parent-change/W.scala new file mode 100644 index 000000000..527676b6d --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/parent-change/W.scala @@ -0,0 +1,5 @@ +class W +{ + def x = 3 +} +class V extends W
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/parent-change/Y.scala b/bridge/src/sbt-test/source-dependencies/parent-change/Y.scala new file mode 100644 index 000000000..9379ee7b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/parent-change/Y.scala @@ -0,0 +1,5 @@ +object Y +{ + def main(args: Array[String]) = + println( (new Z).x ) +} diff --git a/bridge/src/sbt-test/source-dependencies/parent-change/Z.scala b/bridge/src/sbt-test/source-dependencies/parent-change/Z.scala new file mode 100644 index 000000000..0f7c79a40 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/parent-change/Z.scala @@ -0,0 +1 @@ +class Z extends V diff --git a/bridge/src/sbt-test/source-dependencies/parent-change/changes/W.scala b/bridge/src/sbt-test/source-dependencies/parent-change/changes/W.scala new file mode 100644 index 000000000..f2e4dc28f --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/parent-change/changes/W.scala @@ -0,0 +1,5 @@ +class W +{ + def x = 3 +} +class V
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/parent-change/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/parent-change/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/parent-change/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/parent-change/test b/bridge/src/sbt-test/source-dependencies/parent-change/test new file mode 100644 index 000000000..9a80ffae6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/parent-change/test @@ -0,0 +1,7 @@ +> compile + +# modify V to no longer extend W +$ copy-file changes/W.scala W.scala + +# Should recompile Y.scala and report an error: "value x is not a member of Z" +-> compile
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/parent-member-change/A.scala b/bridge/src/sbt-test/source-dependencies/parent-member-change/A.scala new file mode 100644 index 000000000..d6f828508 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/parent-member-change/A.scala @@ -0,0 +1,3 @@ +class A { + def x(i: Int) = i+"3" +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/parent-member-change/B.scala b/bridge/src/sbt-test/source-dependencies/parent-member-change/B.scala new file mode 100644 index 000000000..26e47fd25 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/parent-member-change/B.scala @@ -0,0 +1 @@ +class B extends A
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/parent-member-change/C.scala b/bridge/src/sbt-test/source-dependencies/parent-member-change/C.scala new file mode 100644 index 000000000..6985a0d2f --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/parent-member-change/C.scala @@ -0,0 +1,3 @@ +class C extends B { + def x(s: String) = s+"5" +} diff --git a/bridge/src/sbt-test/source-dependencies/parent-member-change/changes/A.scala b/bridge/src/sbt-test/source-dependencies/parent-member-change/changes/A.scala new file mode 100644 index 000000000..949655f41 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/parent-member-change/changes/A.scala @@ -0,0 +1,3 @@ +class A { + def x(i: String) = i+"3" +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/parent-member-change/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/parent-member-change/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/parent-member-change/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/parent-member-change/test b/bridge/src/sbt-test/source-dependencies/parent-member-change/test new file mode 100644 index 000000000..95ba12295 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/parent-member-change/test @@ -0,0 +1,7 @@ +> compile + +# modify A.scala so that the signature of its method changes to be identical to +# that of the method in its descendant in C.scala +$ copy-file changes/A.scala A.scala +# Should recompile C.scala and report this error, failing the compile +-> compile diff --git a/bridge/src/sbt-test/source-dependencies/pkg-self/changes/A1.scala b/bridge/src/sbt-test/source-dependencies/pkg-self/changes/A1.scala new file mode 100644 index 000000000..f804b5b3e --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/pkg-self/changes/A1.scala @@ -0,0 +1,8 @@ +package demo.sub + +class A { + implicit def x(i: Int): C = new C(i) +} +class C(i: Int) { + def y = i + 1 +} diff --git a/bridge/src/sbt-test/source-dependencies/pkg-self/changes/A2.scala b/bridge/src/sbt-test/source-dependencies/pkg-self/changes/A2.scala new file mode 100644 index 000000000..288698e5d --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/pkg-self/changes/A2.scala @@ -0,0 +1,8 @@ +package demo.sub + +class A { + implicit def x(i: Int): C = new C(i) +} +class C(i: Int) { + def y = i + 2 +} diff --git a/bridge/src/sbt-test/source-dependencies/pkg-self/changes/B.scala b/bridge/src/sbt-test/source-dependencies/pkg-self/changes/B.scala new file mode 100644 index 000000000..54ffd4574 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/pkg-self/changes/B.scala @@ -0,0 +1,5 @@ +package demo + +object B { + 3.y +} diff --git a/bridge/src/sbt-test/source-dependencies/pkg-self/changes/package.scala b/bridge/src/sbt-test/source-dependencies/pkg-self/changes/package.scala new file mode 100644 index 000000000..3c01ff4e4 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/pkg-self/changes/package.scala @@ -0,0 +1,3 @@ +package object demo extends sub.A { + val y = 9 +} diff --git a/bridge/src/sbt-test/source-dependencies/pkg-self/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/pkg-self/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/pkg-self/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/pkg-self/test b/bridge/src/sbt-test/source-dependencies/pkg-self/test new file mode 100644 index 000000000..595138bba --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/pkg-self/test @@ -0,0 +1,14 @@ +# Here we have a package object (demo) that extends a class in a subpackage (demo.sub.A) +# demo.sub.A provides an implicit used by demo.B +$ copy-file changes/package.scala src/main/scala/demo/package.scala +$ copy-file changes/A1.scala src/main/scala/demo/sub/A.scala +$ copy-file changes/B.scala src/main/scala/demo/B.scala +> compile + +# When recompiling A, we delete the class files for A +# When the demo package object is loaded, scalac complains it can't +# find the class files for A. Presumably this occurs because +# package object loading occurs early and doesn't see the new A +# from source. +$ copy-file changes/A2.scala src/main/scala/demo/sub/A.scala +> compile diff --git a/bridge/src/sbt-test/source-dependencies/qualified-access/A.scala b/bridge/src/sbt-test/source-dependencies/qualified-access/A.scala new file mode 100644 index 000000000..b1ff88af7 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/qualified-access/A.scala @@ -0,0 +1,10 @@ +package a +{ + package b + { + object A + { + private[a] def x = 3 + } + } +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/qualified-access/B.scala b/bridge/src/sbt-test/source-dependencies/qualified-access/B.scala new file mode 100644 index 000000000..d709285f5 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/qualified-access/B.scala @@ -0,0 +1,6 @@ +package a + +object B +{ + val y = b.A.x +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/qualified-access/changes/A.scala b/bridge/src/sbt-test/source-dependencies/qualified-access/changes/A.scala new file mode 100644 index 000000000..ef50d0ef9 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/qualified-access/changes/A.scala @@ -0,0 +1,6 @@ +package a.b + +object A +{ + private[b] def x = 3 +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/qualified-access/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/qualified-access/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/qualified-access/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/qualified-access/test b/bridge/src/sbt-test/source-dependencies/qualified-access/test new file mode 100644 index 000000000..2cc575f6b --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/qualified-access/test @@ -0,0 +1,7 @@ +> compile + +# change access of A.x +$ copy-file changes/A.scala A.scala + +# Should force recompilation of B.scala because access changed and B's access is now invalid. +-> compile
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/relative-source-error/changes/absolute.sbt b/bridge/src/sbt-test/source-dependencies/relative-source-error/changes/absolute.sbt new file mode 100644 index 000000000..a5f2d007a --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/relative-source-error/changes/absolute.sbt @@ -0,0 +1 @@ +scalaSource in Compile := baseDirectory.value / "src"
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/relative-source-error/changes/relative.sbt b/bridge/src/sbt-test/source-dependencies/relative-source-error/changes/relative.sbt new file mode 100644 index 000000000..8e898fe02 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/relative-source-error/changes/relative.sbt @@ -0,0 +1 @@ +scalaSource in Compile := file("src")
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/relative-source-error/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/relative-source-error/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/relative-source-error/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/relative-source-error/src/A.scala b/bridge/src/sbt-test/source-dependencies/relative-source-error/src/A.scala new file mode 100644 index 000000000..528ffce71 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/relative-source-error/src/A.scala @@ -0,0 +1 @@ +object A
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/relative-source-error/test b/bridge/src/sbt-test/source-dependencies/relative-source-error/test new file mode 100644 index 000000000..fb8e9dce8 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/relative-source-error/test @@ -0,0 +1,7 @@ +$ copy-file changes/relative.sbt build.sbt +> reload +-> compile + +$ copy-file changes/absolute.sbt build.sbt +> reload +> compile diff --git a/bridge/src/sbt-test/source-dependencies/remove-test-a/changes/1.scala b/bridge/src/sbt-test/source-dependencies/remove-test-a/changes/1.scala new file mode 100644 index 000000000..1444a85e8 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/remove-test-a/changes/1.scala @@ -0,0 +1,6 @@ +package test + +object TestScriptTest +{ + val x: Int = "" +} diff --git a/bridge/src/sbt-test/source-dependencies/remove-test-a/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/remove-test-a/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/remove-test-a/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/remove-test-a/test b/bridge/src/sbt-test/source-dependencies/remove-test-a/test new file mode 100644 index 000000000..ea5cc469c --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/remove-test-a/test @@ -0,0 +1,7 @@ +> compile + +$ copy-file changes/1.scala src/main/scala/1.scala +-> compile + +$ delete src/main/scala/1.scala +> compile
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/remove-test-b/changes/A2.scala b/bridge/src/sbt-test/source-dependencies/remove-test-b/changes/A2.scala new file mode 100644 index 000000000..b971413bf --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/remove-test-b/changes/A2.scala @@ -0,0 +1,6 @@ +package test + +object A +{ + def test = B.length +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/remove-test-b/changes/B3.scala b/bridge/src/sbt-test/source-dependencies/remove-test-b/changes/B3.scala new file mode 100644 index 000000000..c5a1267df --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/remove-test-b/changes/B3.scala @@ -0,0 +1,6 @@ +package test + +object B +{ + def length: Int = 5 +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/remove-test-b/changes/B4.scala b/bridge/src/sbt-test/source-dependencies/remove-test-b/changes/B4.scala new file mode 100644 index 000000000..86a6cb4b9 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/remove-test-b/changes/B4.scala @@ -0,0 +1,5 @@ +package test + +object B +{ +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/remove-test-b/changes/B5.scala b/bridge/src/sbt-test/source-dependencies/remove-test-b/changes/B5.scala new file mode 100644 index 000000000..8829a8f73 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/remove-test-b/changes/B5.scala @@ -0,0 +1,5 @@ +/*package test + +object B +{ +}*/
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/remove-test-b/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/remove-test-b/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/remove-test-b/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/remove-test-b/src/main/scala/A.scala b/bridge/src/sbt-test/source-dependencies/remove-test-b/src/main/scala/A.scala new file mode 100644 index 000000000..af481a935 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/remove-test-b/src/main/scala/A.scala @@ -0,0 +1,5 @@ +package test + +object A +{ +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/remove-test-b/src/main/scala/B.scala b/bridge/src/sbt-test/source-dependencies/remove-test-b/src/main/scala/B.scala new file mode 100644 index 000000000..86a6cb4b9 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/remove-test-b/src/main/scala/B.scala @@ -0,0 +1,5 @@ +package test + +object B +{ +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/remove-test-b/test b/bridge/src/sbt-test/source-dependencies/remove-test-b/test new file mode 100644 index 000000000..79a6db6c8 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/remove-test-b/test @@ -0,0 +1,25 @@ +> compile + +$ copy-file changes/A2.scala src/main/scala/A.scala +-> compile + +$ copy-file changes/B3.scala src/main/scala/B.scala +> compile + +$ delete src/main/scala/B.scala +-> compile + +$ copy-file changes/B3.scala src/main/scala/B.scala +> compile + +$ copy-file changes/B4.scala src/main/scala/B.scala +-> compile + +$ copy-file changes/B3.scala src/main/scala/B.scala +> compile + +$ copy-file changes/B5.scala src/main/scala/B.scala +-> compile + +$ copy-file changes/B3.scala src/main/scala/B.scala +> compile
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/repeated-parameters/A.scala b/bridge/src/sbt-test/source-dependencies/repeated-parameters/A.scala new file mode 100644 index 000000000..df798a859 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/repeated-parameters/A.scala @@ -0,0 +1,4 @@ +object A +{ + def x(i: String*) = () +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/repeated-parameters/B.scala b/bridge/src/sbt-test/source-dependencies/repeated-parameters/B.scala new file mode 100644 index 000000000..a06f3a186 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/repeated-parameters/B.scala @@ -0,0 +1,4 @@ +object B +{ + val x = A.x("3") +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/repeated-parameters/changes/A.scala b/bridge/src/sbt-test/source-dependencies/repeated-parameters/changes/A.scala new file mode 100644 index 000000000..6de960644 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/repeated-parameters/changes/A.scala @@ -0,0 +1,4 @@ +object A +{ + def x(i: Seq[String]) = () +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/repeated-parameters/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/repeated-parameters/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/repeated-parameters/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/repeated-parameters/test b/bridge/src/sbt-test/source-dependencies/repeated-parameters/test new file mode 100644 index 000000000..4964ab5a8 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/repeated-parameters/test @@ -0,0 +1,7 @@ +> compile + +# change repeated parameters to Seq +$ copy-file changes/A.scala A.scala + +# B.scala needs recompiling because the type has changed +-> compile
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/replace-test-a/changes/first.scala b/bridge/src/sbt-test/source-dependencies/replace-test-a/changes/first.scala new file mode 100644 index 000000000..9e12604c2 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/replace-test-a/changes/first.scala @@ -0,0 +1,4 @@ +object First +{ + def main(args: Array[String]): Unit = () +} diff --git a/bridge/src/sbt-test/source-dependencies/replace-test-a/changes/second.scala b/bridge/src/sbt-test/source-dependencies/replace-test-a/changes/second.scala new file mode 100644 index 000000000..45ce49a65 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/replace-test-a/changes/second.scala @@ -0,0 +1,4 @@ +object Second +{ + def main(args: Array[String]): Unit = () +} diff --git a/bridge/src/sbt-test/source-dependencies/replace-test-a/project/Build.scala b/bridge/src/sbt-test/source-dependencies/replace-test-a/project/Build.scala new file mode 100644 index 000000000..9c2678540 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/replace-test-a/project/Build.scala @@ -0,0 +1,19 @@ +import sbt._ +import Keys._ +import java.net.URLClassLoader + +object B extends Build +{ + lazy val root = Project("root", file(".")) settings( ss : _*) + + def ss = Seq( + TaskKey[Unit]("check-first") <<= checkTask("First"), + TaskKey[Unit]("check-second") <<= checkTask("Second") + ) + private def checkTask(className: String) = + fullClasspath in Configurations.Runtime map { runClasspath => + val cp = runClasspath.map(_.data.toURI.toURL).toArray + Class.forName(className, false, new URLClassLoader(cp)) + () + } +} diff --git a/bridge/src/sbt-test/source-dependencies/replace-test-a/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/replace-test-a/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/replace-test-a/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/replace-test-a/test b/bridge/src/sbt-test/source-dependencies/replace-test-a/test new file mode 100644 index 000000000..4b4ad3a2b --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/replace-test-a/test @@ -0,0 +1,9 @@ +$ copy-file changes/first.scala src/main/scala/A.scala +> compile +> check-first +-> check-second + +$ copy-file changes/second.scala src/main/scala/A.scala +> compile +-> check-first +> check-second
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/resident-java/build.sbt b/bridge/src/sbt-test/source-dependencies/resident-java/build.sbt new file mode 100644 index 000000000..619622832 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/resident-java/build.sbt @@ -0,0 +1 @@ +compileOrder := CompileOrder.JavaThenScala diff --git a/bridge/src/sbt-test/source-dependencies/resident-java/changes/A1.java b/bridge/src/sbt-test/source-dependencies/resident-java/changes/A1.java new file mode 100644 index 000000000..bdf223afb --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/resident-java/changes/A1.java @@ -0,0 +1,5 @@ +package example; + +public class A { + public final int x = 3; +} diff --git a/bridge/src/sbt-test/source-dependencies/resident-java/changes/A2.java b/bridge/src/sbt-test/source-dependencies/resident-java/changes/A2.java new file mode 100644 index 000000000..3b67c58d2 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/resident-java/changes/A2.java @@ -0,0 +1,5 @@ +package example; + +public class A { + public final String x = "a"; +} diff --git a/bridge/src/sbt-test/source-dependencies/resident-java/changes/B0.scala b/bridge/src/sbt-test/source-dependencies/resident-java/changes/B0.scala new file mode 100644 index 000000000..251ef7397 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/resident-java/changes/B0.scala @@ -0,0 +1 @@ +object B diff --git a/bridge/src/sbt-test/source-dependencies/resident-java/changes/B1.scala b/bridge/src/sbt-test/source-dependencies/resident-java/changes/B1.scala new file mode 100644 index 000000000..9d9a60c87 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/resident-java/changes/B1.scala @@ -0,0 +1,3 @@ +object B { + val x: Int = (new example.A).x +} diff --git a/bridge/src/sbt-test/source-dependencies/resident-java/changes/B2.scala b/bridge/src/sbt-test/source-dependencies/resident-java/changes/B2.scala new file mode 100644 index 000000000..ec5fd2cf3 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/resident-java/changes/B2.scala @@ -0,0 +1,3 @@ +object B { + val x: String = (new example.A).x +} diff --git a/bridge/src/sbt-test/source-dependencies/resident-java/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/resident-java/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/resident-java/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/resident-java/test b/bridge/src/sbt-test/source-dependencies/resident-java/test new file mode 100644 index 000000000..6987c7df0 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/resident-java/test @@ -0,0 +1,10 @@ +$ copy-file changes/B0.scala B.scala +> compile + +$ copy-file changes/A1.java src/main/java/example/A.java +$ copy-file changes/B1.scala B.scala +> compile + +$ copy-file changes/A2.java src/main/java/example/A.java +$ copy-file changes/B2.scala B.scala +> compile diff --git a/bridge/src/sbt-test/source-dependencies/resident-package-object/changes/A.scala b/bridge/src/sbt-test/source-dependencies/resident-package-object/changes/A.scala new file mode 100644 index 000000000..da058d2d9 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/resident-package-object/changes/A.scala @@ -0,0 +1,5 @@ +package example + +object A { + val x: Int = green +} diff --git a/bridge/src/sbt-test/source-dependencies/resident-package-object/changes/package.scala b/bridge/src/sbt-test/source-dependencies/resident-package-object/changes/package.scala new file mode 100644 index 000000000..9fd811040 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/resident-package-object/changes/package.scala @@ -0,0 +1,3 @@ +package object example { + val green = 3 +} diff --git a/bridge/src/sbt-test/source-dependencies/resident-package-object/changes/package2.scala b/bridge/src/sbt-test/source-dependencies/resident-package-object/changes/package2.scala new file mode 100644 index 000000000..22c1afd15 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/resident-package-object/changes/package2.scala @@ -0,0 +1,3 @@ +package object example { + val green = "asdf" +} diff --git a/bridge/src/sbt-test/source-dependencies/resident-package-object/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/resident-package-object/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/resident-package-object/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/resident-package-object/test b/bridge/src/sbt-test/source-dependencies/resident-package-object/test new file mode 100644 index 000000000..e83d2578d --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/resident-package-object/test @@ -0,0 +1,11 @@ +$ copy-file changes/package.scala src/main/scala/example/package.scala +> compile + +$ copy-file changes/A.scala src/main/scala/example/A.scala +> compile + +$ copy-file changes/package2.scala src/main/scala/example/package.scala +-> compile + +$ copy-file changes/package.scala src/main/scala/example/package.scala +> compile diff --git a/bridge/src/sbt-test/source-dependencies/restore-classes/build.sbt b/bridge/src/sbt-test/source-dependencies/restore-classes/build.sbt new file mode 100644 index 000000000..2231204ea --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/restore-classes/build.sbt @@ -0,0 +1,12 @@ +import complete.DefaultParsers._ + +crossTarget in Compile := target.value + +val checkIterations = inputKey[Unit]("Verifies the accumlated number of iterations of incremental compilation.") + +checkIterations := { + val expected: Int = (Space ~> NatBasic).parsed + val actual: Int = (compile in Compile).value.compilations.allCompilations.size + assert(expected == actual, s"Expected $expected compilations, got $actual") +} + diff --git a/bridge/src/sbt-test/source-dependencies/restore-classes/changes/A1.scala b/bridge/src/sbt-test/source-dependencies/restore-classes/changes/A1.scala new file mode 100644 index 000000000..2a499fa7b --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/restore-classes/changes/A1.scala @@ -0,0 +1,3 @@ +object A { + val x = 3 +} diff --git a/bridge/src/sbt-test/source-dependencies/restore-classes/changes/A2.scala b/bridge/src/sbt-test/source-dependencies/restore-classes/changes/A2.scala new file mode 100644 index 000000000..10d738255 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/restore-classes/changes/A2.scala @@ -0,0 +1,5 @@ +object A { + val x = "a" +} + +class C diff --git a/bridge/src/sbt-test/source-dependencies/restore-classes/changes/B.scala b/bridge/src/sbt-test/source-dependencies/restore-classes/changes/B.scala new file mode 100644 index 000000000..945e97bb3 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/restore-classes/changes/B.scala @@ -0,0 +1,4 @@ +object B { + val y: Int = A.x +} + diff --git a/bridge/src/sbt-test/source-dependencies/restore-classes/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/restore-classes/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/restore-classes/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/restore-classes/test b/bridge/src/sbt-test/source-dependencies/restore-classes/test new file mode 100644 index 000000000..028d6226c --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/restore-classes/test @@ -0,0 +1,23 @@ +$ copy-file changes/A1.scala A.scala +$ copy-file changes/B.scala B.scala +# B depends on A +# 1 iteration +> compile + +$ copy-file changes/A2.scala A.scala + +# will successfully compile A.scala in the first step but fail to compile B.scala in the second +# because type of A.x changed. The original classes should be restored after this failure. +# 2 iterations, but none are recorded in the Analysis +-> compile + +# the class file for C should be deleted: +# it was only added by A2, but compilation hasn't succeeded yet +$ absent target/classes/C.class + + +$ copy-file changes/A1.scala A.scala +# if the classes were correctly restored, another compilation shouldn't be necessary +> compile +# so, there should only be the original 1 iteration recorded in the Analysis +> checkIterations 1 diff --git a/bridge/src/sbt-test/source-dependencies/same-file-used-names/A.scala b/bridge/src/sbt-test/source-dependencies/same-file-used-names/A.scala new file mode 100644 index 000000000..d91afb5ca --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/same-file-used-names/A.scala @@ -0,0 +1,8 @@ +object A { + def x = 3 + + def y = { + import B._ + x + } +} diff --git a/bridge/src/sbt-test/source-dependencies/same-file-used-names/B.scala b/bridge/src/sbt-test/source-dependencies/same-file-used-names/B.scala new file mode 100644 index 000000000..5e34efa4d --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/same-file-used-names/B.scala @@ -0,0 +1,3 @@ +object B { +// def x = 3 +} diff --git a/bridge/src/sbt-test/source-dependencies/same-file-used-names/build.sbt b/bridge/src/sbt-test/source-dependencies/same-file-used-names/build.sbt new file mode 100644 index 000000000..8a38ef414 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/same-file-used-names/build.sbt @@ -0,0 +1 @@ +incOptions := incOptions.value.withNameHashing(true) diff --git a/bridge/src/sbt-test/source-dependencies/same-file-used-names/changes/B.scala b/bridge/src/sbt-test/source-dependencies/same-file-used-names/changes/B.scala new file mode 100644 index 000000000..4bf188fb2 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/same-file-used-names/changes/B.scala @@ -0,0 +1,3 @@ +object B { + def x = 3 +} diff --git a/bridge/src/sbt-test/source-dependencies/same-file-used-names/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/same-file-used-names/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/same-file-used-names/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/same-file-used-names/test b/bridge/src/sbt-test/source-dependencies/same-file-used-names/test new file mode 100644 index 000000000..781b4aafb --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/same-file-used-names/test @@ -0,0 +1,7 @@ +> compile + +# uncomment definition of `x` that leads to ambiguity error in A +$ copy-file changes/B.scala B.scala + +# Both A.scala and B.scala should be recompiled, producing a compile error +-> compile diff --git a/bridge/src/sbt-test/source-dependencies/sealed/A.scala b/bridge/src/sbt-test/source-dependencies/sealed/A.scala new file mode 100644 index 000000000..d185a50a9 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/sealed/A.scala @@ -0,0 +1,3 @@ +sealed trait A +class B extends A +class C extends A
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/sealed/D.scala b/bridge/src/sbt-test/source-dependencies/sealed/D.scala new file mode 100644 index 000000000..1f49e9d61 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/sealed/D.scala @@ -0,0 +1,8 @@ + +object D { +def x(a: A) = + a match { + case _: B => () + case _: C => () + } +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/sealed/changes/A.scala b/bridge/src/sbt-test/source-dependencies/sealed/changes/A.scala new file mode 100644 index 000000000..f00e9c127 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/sealed/changes/A.scala @@ -0,0 +1,4 @@ +sealed trait A +class B extends A +class C extends A +class E extends A
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/sealed/pending b/bridge/src/sbt-test/source-dependencies/sealed/pending new file mode 100644 index 000000000..69c8ebe98 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/sealed/pending @@ -0,0 +1,11 @@ +> 'set scalacOptions += "-Xfatal-warnings"' + +> compile + +# have new class E extend A +$ copy-file changes/A.scala A.scala + +# D.scala needs recompiling because the pattern match in D +# is no longer exhaustive, which should be a warning +# there is no way to make warnings errors, so this has to be manually checked +-> compile
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/sealed/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/sealed/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/sealed/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/specialized/A.scala b/bridge/src/sbt-test/source-dependencies/specialized/A.scala new file mode 100644 index 000000000..a9b5e6818 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/specialized/A.scala @@ -0,0 +1,4 @@ +class A +{ + def x[T](t: T) = t +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/specialized/B.scala b/bridge/src/sbt-test/source-dependencies/specialized/B.scala new file mode 100644 index 000000000..387a85019 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/specialized/B.scala @@ -0,0 +1,7 @@ +object B +{ + def main(args: Array[String]): Unit = { + val a = new A + a.x(3) + } +} diff --git a/bridge/src/sbt-test/source-dependencies/specialized/changes/A.scala b/bridge/src/sbt-test/source-dependencies/specialized/changes/A.scala new file mode 100644 index 000000000..76ac39400 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/specialized/changes/A.scala @@ -0,0 +1,4 @@ +class A +{ + def x[@specialized T](t: T) = t +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/specialized/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/specialized/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/specialized/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/specialized/test b/bridge/src/sbt-test/source-dependencies/specialized/test new file mode 100644 index 000000000..b9e1ad09c --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/specialized/test @@ -0,0 +1,15 @@ +# -Yspecialize is 2.8 only +> compile + +# verify that erased A.x can be called normally and reflectively +> run false + +# make A.x specialized +$ copy-file changes/A.scala A.scala + +# B.scala needs recompiling so that B.y calls the specialized version of A.x +> compile + +# verify that specialized A.x can be called normally and reflectively +# NOTE: this test doesn't actually work correctly: have to check the output to see that B.scala was recompiled +> run true
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/stability-change/A.scala b/bridge/src/sbt-test/source-dependencies/stability-change/A.scala new file mode 100644 index 000000000..e9b4d7aa6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/stability-change/A.scala @@ -0,0 +1,4 @@ +object A +{ + val x = new C +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/stability-change/B.scala b/bridge/src/sbt-test/source-dependencies/stability-change/B.scala new file mode 100644 index 000000000..fce3e99cf --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/stability-change/B.scala @@ -0,0 +1,5 @@ +object B +{ + import A.x.y + val z = y +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/stability-change/C.scala b/bridge/src/sbt-test/source-dependencies/stability-change/C.scala new file mode 100644 index 000000000..9b2e3741a --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/stability-change/C.scala @@ -0,0 +1,4 @@ +class C +{ + val y = 4 +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/stability-change/changes/A.scala b/bridge/src/sbt-test/source-dependencies/stability-change/changes/A.scala new file mode 100644 index 000000000..1b6e8d65a --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/stability-change/changes/A.scala @@ -0,0 +1,4 @@ +object A +{ + def x = new C +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/stability-change/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/stability-change/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/stability-change/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/stability-change/test b/bridge/src/sbt-test/source-dependencies/stability-change/test new file mode 100644 index 000000000..887778d24 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/stability-change/test @@ -0,0 +1,6 @@ +> compile + +# replace val x with var x, invalidating the import in B +$ copy-file changes/A.scala A.scala + +-> compile
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/synthetic-companion/A.scala b/bridge/src/sbt-test/source-dependencies/synthetic-companion/A.scala new file mode 100644 index 000000000..9917b2d98 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/synthetic-companion/A.scala @@ -0,0 +1 @@ +case class A(x: Int) diff --git a/bridge/src/sbt-test/source-dependencies/synthetic-companion/B.scala b/bridge/src/sbt-test/source-dependencies/synthetic-companion/B.scala new file mode 100644 index 000000000..be302fe40 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/synthetic-companion/B.scala @@ -0,0 +1,3 @@ +object B { + A(0) +} diff --git a/bridge/src/sbt-test/source-dependencies/synthetic-companion/changes/A2.scala b/bridge/src/sbt-test/source-dependencies/synthetic-companion/changes/A2.scala new file mode 100644 index 000000000..3d35a445f --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/synthetic-companion/changes/A2.scala @@ -0,0 +1,2 @@ +case class A(x: Int) +private object A diff --git a/bridge/src/sbt-test/source-dependencies/synthetic-companion/dbg.sbt b/bridge/src/sbt-test/source-dependencies/synthetic-companion/dbg.sbt new file mode 100644 index 000000000..1ac0e14e9 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/synthetic-companion/dbg.sbt @@ -0,0 +1,2 @@ +logLevel := Level.Debug +incOptions ~= { _.copy(apiDebug = true, relationsDebug = true) } diff --git a/bridge/src/sbt-test/source-dependencies/synthetic-companion/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/synthetic-companion/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/synthetic-companion/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/synthetic-companion/test b/bridge/src/sbt-test/source-dependencies/synthetic-companion/test new file mode 100644 index 000000000..f3a023810 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/synthetic-companion/test @@ -0,0 +1,4 @@ +> compile +$ copy-file changes/A2.scala A.scala +# Compilation of B.scala should fail because object A does not extend `Int => A` anymore +-> compile diff --git a/bridge/src/sbt-test/source-dependencies/trait-member-modified/build.sbt b/bridge/src/sbt-test/source-dependencies/trait-member-modified/build.sbt new file mode 100644 index 000000000..949d78231 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/trait-member-modified/build.sbt @@ -0,0 +1,27 @@ +/* Performs checks related to compilations: + * a) checks in which compilation given set of files was recompiled + * b) checks overall number of compilations performed + */ +TaskKey[Unit]("check-compilations") := { + val analysis = (compile in Compile).value + val srcDir = (scalaSource in Compile).value + def relative(f: java.io.File): java.io.File = f.relativeTo(srcDir) getOrElse f + val allCompilations = analysis.compilations.allCompilations + val recompiledFiles: Seq[Set[java.io.File]] = allCompilations map { c => + val recompiledFiles = analysis.apis.internal.collect { + case (file, api) if api.compilation.startTime == c.startTime => relative(file) + } + recompiledFiles.toSet + } + def recompiledFilesInIteration(iteration: Int, fileNames: Set[String]) = { + val files = fileNames.map(new java.io.File(_)) + assert(recompiledFiles(iteration) == files, "%s != %s".format(recompiledFiles(iteration), files)) + } + assert(allCompilations.size == 2) + // B.scala is just compiled at the beginning + recompiledFilesInIteration(0, Set("B.scala")) + // A.scala is changed and recompiled + recompiledFilesInIteration(1, Set("A.scala")) +} + +logLevel := Level.Debug diff --git a/bridge/src/sbt-test/source-dependencies/trait-member-modified/changes/A1.scala b/bridge/src/sbt-test/source-dependencies/trait-member-modified/changes/A1.scala new file mode 100644 index 000000000..57a1f34c6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/trait-member-modified/changes/A1.scala @@ -0,0 +1,3 @@ +trait A { + def foo: Int = 12 +} diff --git a/bridge/src/sbt-test/source-dependencies/trait-member-modified/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/trait-member-modified/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/trait-member-modified/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/trait-member-modified/src/main/scala/A.scala b/bridge/src/sbt-test/source-dependencies/trait-member-modified/src/main/scala/A.scala new file mode 100644 index 000000000..0eab80adc --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/trait-member-modified/src/main/scala/A.scala @@ -0,0 +1 @@ +trait A diff --git a/bridge/src/sbt-test/source-dependencies/trait-member-modified/src/main/scala/B.scala b/bridge/src/sbt-test/source-dependencies/trait-member-modified/src/main/scala/B.scala new file mode 100644 index 000000000..c4d3f7e97 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/trait-member-modified/src/main/scala/B.scala @@ -0,0 +1 @@ +class B(a: A) diff --git a/bridge/src/sbt-test/source-dependencies/trait-member-modified/test b/bridge/src/sbt-test/source-dependencies/trait-member-modified/test new file mode 100644 index 000000000..f8f7cb076 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/trait-member-modified/test @@ -0,0 +1,9 @@ +# Test if adding a member to a trait affects classes that refer to that trait +# by a member reference +> compile +# add `foo` method to `A` +$ copy-file changes/A1.scala src/main/scala/A.scala +# only A.scala should be recompiled +> compile +# check if there are only two compile iterations performed +> check-compilations diff --git a/bridge/src/sbt-test/source-dependencies/trait-private-object/A.scala b/bridge/src/sbt-test/source-dependencies/trait-private-object/A.scala new file mode 100644 index 000000000..cbcda3176 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/trait-private-object/A.scala @@ -0,0 +1,3 @@ +trait A { + val foo = 0 +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/trait-private-object/B.scala b/bridge/src/sbt-test/source-dependencies/trait-private-object/B.scala new file mode 100644 index 000000000..5da0f8a71 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/trait-private-object/B.scala @@ -0,0 +1,5 @@ +object B extends A { + def main(args: Array[String]): Unit = { + println(foo) + } +} diff --git a/bridge/src/sbt-test/source-dependencies/trait-private-object/changes/A.scala b/bridge/src/sbt-test/source-dependencies/trait-private-object/changes/A.scala new file mode 100644 index 000000000..63ca671b7 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/trait-private-object/changes/A.scala @@ -0,0 +1,4 @@ +trait A { + val foo = 0 + X.a + private object X { val a = 1 } +} diff --git a/bridge/src/sbt-test/source-dependencies/trait-private-object/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/trait-private-object/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/trait-private-object/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/trait-private-object/test b/bridge/src/sbt-test/source-dependencies/trait-private-object/test new file mode 100644 index 000000000..5aab7a143 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/trait-private-object/test @@ -0,0 +1,5 @@ +> run + +$ copy-file changes/A.scala A.scala + +> run
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/trait-private-var/B.scala b/bridge/src/sbt-test/source-dependencies/trait-private-var/B.scala new file mode 100644 index 000000000..a0bb35627 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/trait-private-var/B.scala @@ -0,0 +1,3 @@ +object B extends A { + def main(args: Array[String]): Unit = println(bar) +} diff --git a/bridge/src/sbt-test/source-dependencies/trait-private-var/changes/A0.scala b/bridge/src/sbt-test/source-dependencies/trait-private-var/changes/A0.scala new file mode 100644 index 000000000..cf57bdb33 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/trait-private-var/changes/A0.scala @@ -0,0 +1,3 @@ +trait A { + def bar: Int = 0 +} diff --git a/bridge/src/sbt-test/source-dependencies/trait-private-var/changes/A1.scala b/bridge/src/sbt-test/source-dependencies/trait-private-var/changes/A1.scala new file mode 100644 index 000000000..3eb53d77c --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/trait-private-var/changes/A1.scala @@ -0,0 +1,5 @@ +trait A { + private var foo = 12 + // we need to access foo to trigger AbstractMethodError + def bar: Int = foo +} diff --git a/bridge/src/sbt-test/source-dependencies/trait-private-var/changes/A2.scala b/bridge/src/sbt-test/source-dependencies/trait-private-var/changes/A2.scala new file mode 100644 index 000000000..60641457d --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/trait-private-var/changes/A2.scala @@ -0,0 +1,5 @@ +trait A { + private val foo = 12 + // we need to access foo to trigger AbstractMethodError + def bar: Int = foo +} diff --git a/bridge/src/sbt-test/source-dependencies/trait-private-var/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/trait-private-var/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/trait-private-var/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/trait-private-var/test b/bridge/src/sbt-test/source-dependencies/trait-private-var/test new file mode 100644 index 000000000..c120697d8 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/trait-private-var/test @@ -0,0 +1,28 @@ +$ copy-file changes/A0.scala A.scala + +# compile and run for the first time to verify that everything works +> run + +# introduce private var and refer to it in a trait that we inherit from +# there'll be pair of getters and setters generated for private var that +# has to be implemented by a class (where you can declare corresponding field) +$ copy-file changes/A1.scala A.scala + +# If the introduction of a private var did not trigger the recompilation of B, +# then this will fail with AbstractMethodError because the getters and setters +# for the private var have not been generated. +> run + +# Try again with a private val +> clean + +$ copy-file changes/A0.scala A.scala + +# compile and run a clean project to verify that everything works +> run + +# introduce a private val in the trait +$ copy-file changes/A2.scala A.scala + +# Verify that B has been recompiled and that everything runs fine. +> run diff --git a/bridge/src/sbt-test/source-dependencies/trait-super/A.scala b/bridge/src/sbt-test/source-dependencies/trait-super/A.scala new file mode 100644 index 000000000..52ad7e6a0 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/trait-super/A.scala @@ -0,0 +1,6 @@ +trait A { + def x: Int +} +class E extends A { + def x = 19 +} diff --git a/bridge/src/sbt-test/source-dependencies/trait-super/B.scala b/bridge/src/sbt-test/source-dependencies/trait-super/B.scala new file mode 100644 index 000000000..cba4cc427 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/trait-super/B.scala @@ -0,0 +1,6 @@ +trait B extends A { + abstract override def x = 1 +} +trait C extends A { + abstract override def x = 3 +} diff --git a/bridge/src/sbt-test/source-dependencies/trait-super/Main.scala b/bridge/src/sbt-test/source-dependencies/trait-super/Main.scala new file mode 100644 index 000000000..37d821d9d --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/trait-super/Main.scala @@ -0,0 +1,10 @@ +class X extends E with C with B + +object Main { + + def main(args: Array[String]): Unit = { + val x = new X + val expected = args(0).toInt + assert(x.x == expected, "Expected " + expected + ", got " + x.x) + } +} diff --git a/bridge/src/sbt-test/source-dependencies/trait-super/changes/B2.scala b/bridge/src/sbt-test/source-dependencies/trait-super/changes/B2.scala new file mode 100644 index 000000000..c89acd3ae --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/trait-super/changes/B2.scala @@ -0,0 +1,6 @@ +trait B extends A { + abstract override def x = super.x + 2 +} +trait C extends A { + abstract override def x = 3 +} diff --git a/bridge/src/sbt-test/source-dependencies/trait-super/changes/B3.scala b/bridge/src/sbt-test/source-dependencies/trait-super/changes/B3.scala new file mode 100644 index 000000000..2a7ba55ec --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/trait-super/changes/B3.scala @@ -0,0 +1,6 @@ +trait B extends A { + abstract override def x = super.x + 2 +} +trait C extends A { + abstract override def x = super.x +} diff --git a/bridge/src/sbt-test/source-dependencies/trait-super/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/trait-super/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/trait-super/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/trait-super/test b/bridge/src/sbt-test/source-dependencies/trait-super/test new file mode 100644 index 000000000..b14d5dc76 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/trait-super/test @@ -0,0 +1,16 @@ +# Dotty: This test has been disabled because super accessors are introduced +# in PostTyper but the sbt phase is run before PostTyper so that tests like +# "constants" succeed. + +# This test verifies that adding/removing calls to super in traits properly +# recompiles subclasses. super calls introduce accessors that are not in +# the public API, so this is not picked up by the usual API change detection. + +> run 1 + +$ copy-file changes/B2.scala B.scala +> run 5 + +$ copy-file changes/B3.scala B.scala +> run 21 + diff --git a/bridge/src/sbt-test/source-dependencies/transitive-a/changes/A2.scala b/bridge/src/sbt-test/source-dependencies/transitive-a/changes/A2.scala new file mode 100644 index 000000000..8811bc83d --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/transitive-a/changes/A2.scala @@ -0,0 +1,4 @@ +object A +{ + val x = 5 +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/transitive-a/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/transitive-a/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/transitive-a/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/transitive-a/src/main/scala/A.scala b/bridge/src/sbt-test/source-dependencies/transitive-a/src/main/scala/A.scala new file mode 100644 index 000000000..a0121ded0 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/transitive-a/src/main/scala/A.scala @@ -0,0 +1,4 @@ +object A +{ + val x = "a" +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/transitive-a/src/main/scala/B.scala b/bridge/src/sbt-test/source-dependencies/transitive-a/src/main/scala/B.scala new file mode 100644 index 000000000..da3e21492 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/transitive-a/src/main/scala/B.scala @@ -0,0 +1,4 @@ +object B +{ + val y = A.x +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/transitive-a/src/main/scala/C.scala b/bridge/src/sbt-test/source-dependencies/transitive-a/src/main/scala/C.scala new file mode 100644 index 000000000..0c2345e0f --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/transitive-a/src/main/scala/C.scala @@ -0,0 +1,4 @@ +object C +{ + val z = B.y.length +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/transitive-a/test b/bridge/src/sbt-test/source-dependencies/transitive-a/test new file mode 100644 index 000000000..774b014aa --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/transitive-a/test @@ -0,0 +1,4 @@ +> compile + +$ copy-file changes/A2.scala src/main/scala/A.scala +-> compile
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/transitive-b/changes/A2.scala b/bridge/src/sbt-test/source-dependencies/transitive-b/changes/A2.scala new file mode 100644 index 000000000..3a0001416 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/transitive-b/changes/A2.scala @@ -0,0 +1,4 @@ +trait A +{ + val x = 5 +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/transitive-b/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/transitive-b/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/transitive-b/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/transitive-b/src/main/scala/A.scala b/bridge/src/sbt-test/source-dependencies/transitive-b/src/main/scala/A.scala new file mode 100644 index 000000000..d49070e79 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/transitive-b/src/main/scala/A.scala @@ -0,0 +1,4 @@ +trait A +{ + val x = "a" +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/transitive-b/src/main/scala/B.scala b/bridge/src/sbt-test/source-dependencies/transitive-b/src/main/scala/B.scala new file mode 100644 index 000000000..310eb5b60 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/transitive-b/src/main/scala/B.scala @@ -0,0 +1 @@ +trait B extends A
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/transitive-b/src/main/scala/C.scala b/bridge/src/sbt-test/source-dependencies/transitive-b/src/main/scala/C.scala new file mode 100644 index 000000000..da117fc3f --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/transitive-b/src/main/scala/C.scala @@ -0,0 +1,4 @@ +trait C extends B +{ + val z = x.length +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/transitive-b/test b/bridge/src/sbt-test/source-dependencies/transitive-b/test new file mode 100644 index 000000000..774b014aa --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/transitive-b/test @@ -0,0 +1,4 @@ +> compile + +$ copy-file changes/A2.scala src/main/scala/A.scala +-> compile
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/transitive-inherit-java/A.java b/bridge/src/sbt-test/source-dependencies/transitive-inherit-java/A.java new file mode 100644 index 000000000..96b1a01a7 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/transitive-inherit-java/A.java @@ -0,0 +1,3 @@ +public class A { + public int x() { return 5; } +} diff --git a/bridge/src/sbt-test/source-dependencies/transitive-inherit-java/B.java b/bridge/src/sbt-test/source-dependencies/transitive-inherit-java/B.java new file mode 100644 index 000000000..7e9bb5574 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/transitive-inherit-java/B.java @@ -0,0 +1 @@ +public class B extends A {} diff --git a/bridge/src/sbt-test/source-dependencies/transitive-inherit-java/C.java b/bridge/src/sbt-test/source-dependencies/transitive-inherit-java/C.java new file mode 100644 index 000000000..a5a7716ea --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/transitive-inherit-java/C.java @@ -0,0 +1,4 @@ +public class C extends B +{ + public int x() { return super.x() + 3; } +} diff --git a/bridge/src/sbt-test/source-dependencies/transitive-inherit-java/changes/A2.java b/bridge/src/sbt-test/source-dependencies/transitive-inherit-java/changes/A2.java new file mode 100644 index 000000000..9f4b93d84 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/transitive-inherit-java/changes/A2.java @@ -0,0 +1 @@ +public class A {} diff --git a/bridge/src/sbt-test/source-dependencies/transitive-inherit-java/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/transitive-inherit-java/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/transitive-inherit-java/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/transitive-inherit-java/test b/bridge/src/sbt-test/source-dependencies/transitive-inherit-java/test new file mode 100644 index 000000000..387cbae45 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/transitive-inherit-java/test @@ -0,0 +1,4 @@ +> compile + +$ copy-file changes/A2.java A.java +-> compile diff --git a/bridge/src/sbt-test/source-dependencies/transitive-inherit/A.scala b/bridge/src/sbt-test/source-dependencies/transitive-inherit/A.scala new file mode 100644 index 000000000..0eab80adc --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/transitive-inherit/A.scala @@ -0,0 +1 @@ +trait A diff --git a/bridge/src/sbt-test/source-dependencies/transitive-inherit/B.scala b/bridge/src/sbt-test/source-dependencies/transitive-inherit/B.scala new file mode 100644 index 000000000..310eb5b60 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/transitive-inherit/B.scala @@ -0,0 +1 @@ +trait B extends A
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/transitive-inherit/C.scala b/bridge/src/sbt-test/source-dependencies/transitive-inherit/C.scala new file mode 100644 index 000000000..9e7708627 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/transitive-inherit/C.scala @@ -0,0 +1,4 @@ +trait C extends B +{ + def x = 3 +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/transitive-inherit/changes/A2.scala b/bridge/src/sbt-test/source-dependencies/transitive-inherit/changes/A2.scala new file mode 100644 index 000000000..609031a44 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/transitive-inherit/changes/A2.scala @@ -0,0 +1,4 @@ +trait A +{ + def x = 5 +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/transitive-inherit/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/transitive-inherit/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/transitive-inherit/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/transitive-inherit/test b/bridge/src/sbt-test/source-dependencies/transitive-inherit/test new file mode 100644 index 000000000..74fa79ef9 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/transitive-inherit/test @@ -0,0 +1,4 @@ +> compile + +$ copy-file changes/A2.scala A.scala +-> compile
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/transitive-memberRef/build.sbt b/bridge/src/sbt-test/source-dependencies/transitive-memberRef/build.sbt new file mode 100644 index 000000000..d24e304b1 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/transitive-memberRef/build.sbt @@ -0,0 +1,40 @@ +logLevel := Level.Debug + +incOptions := incOptions.value.withNameHashing(true) + +// disable sbt's heauristic which recompiles everything in case +// some fraction (e.g. 50%) of files is scheduled to be recompiled +// in this test we want precise information about recompiled files +// which that heuristic would distort +incOptions := incOptions.value.copy(recompileAllFraction = 1.0) + +/* Performs checks related to compilations: + * a) checks in which compilation given set of files was recompiled + * b) checks overall number of compilations performed + */ +TaskKey[Unit]("check-compilations") := { + val analysis = (compile in Compile).value + val srcDir = (scalaSource in Compile).value + def relative(f: java.io.File): java.io.File = f.relativeTo(srcDir) getOrElse f + val allCompilations = analysis.compilations.allCompilations + val recompiledFiles: Seq[Set[java.io.File]] = allCompilations map { c => + val recompiledFiles = analysis.apis.internal.collect { + case (file, api) if api.compilation.startTime == c.startTime => relative(file) + } + recompiledFiles.toSet + } + def recompiledFilesInIteration(iteration: Int, fileNames: Set[String]) = { + val files = fileNames.map(new java.io.File(_)) + assert(recompiledFiles(iteration) == files, "%s != %s".format(recompiledFiles(iteration), files)) + } + // Y.scala is compiled only at the beginning as changes to A.scala do not affect it + recompiledFilesInIteration(0, Set("X.scala", "Y.scala")) + // A.scala is changed and recompiled + recompiledFilesInIteration(1, Set("A.scala")) + // change in A.scala causes recompilation of B.scala, C.scala, D.scala which depend on transtiviely + // and by inheritance on A.scala + // X.scala is also recompiled because it depends by member reference on B.scala + // Note that Y.scala is not recompiled because it depends just on X through member reference dependency + recompiledFilesInIteration(2, Set("B.scala", "C.scala", "D.scala")) + assert(allCompilations.size == 3) +} diff --git a/bridge/src/sbt-test/source-dependencies/transitive-memberRef/changes/A1.scala b/bridge/src/sbt-test/source-dependencies/transitive-memberRef/changes/A1.scala new file mode 100644 index 000000000..63a2739e1 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/transitive-memberRef/changes/A1.scala @@ -0,0 +1,5 @@ +package test + +class A { + def foo: Int = 23 +} diff --git a/bridge/src/sbt-test/source-dependencies/transitive-memberRef/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/transitive-memberRef/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/transitive-memberRef/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/transitive-memberRef/src/main/scala/A.scala b/bridge/src/sbt-test/source-dependencies/transitive-memberRef/src/main/scala/A.scala new file mode 100644 index 000000000..1b0178fd9 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/transitive-memberRef/src/main/scala/A.scala @@ -0,0 +1,3 @@ +package test + +class A diff --git a/bridge/src/sbt-test/source-dependencies/transitive-memberRef/src/main/scala/B.scala b/bridge/src/sbt-test/source-dependencies/transitive-memberRef/src/main/scala/B.scala new file mode 100644 index 000000000..b9913245b --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/transitive-memberRef/src/main/scala/B.scala @@ -0,0 +1,3 @@ +package test + +class B extends A diff --git a/bridge/src/sbt-test/source-dependencies/transitive-memberRef/src/main/scala/C.scala b/bridge/src/sbt-test/source-dependencies/transitive-memberRef/src/main/scala/C.scala new file mode 100644 index 000000000..4ce04f8bf --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/transitive-memberRef/src/main/scala/C.scala @@ -0,0 +1,3 @@ +package test + +class C extends B diff --git a/bridge/src/sbt-test/source-dependencies/transitive-memberRef/src/main/scala/D.scala b/bridge/src/sbt-test/source-dependencies/transitive-memberRef/src/main/scala/D.scala new file mode 100644 index 000000000..eff328ce5 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/transitive-memberRef/src/main/scala/D.scala @@ -0,0 +1,3 @@ +package test + +class D extends C diff --git a/bridge/src/sbt-test/source-dependencies/transitive-memberRef/src/main/scala/X.scala b/bridge/src/sbt-test/source-dependencies/transitive-memberRef/src/main/scala/X.scala new file mode 100644 index 000000000..8c0d9edf8 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/transitive-memberRef/src/main/scala/X.scala @@ -0,0 +1,5 @@ +package test + +class X { + def bar(b: B) = b +} diff --git a/bridge/src/sbt-test/source-dependencies/transitive-memberRef/src/main/scala/Y.scala b/bridge/src/sbt-test/source-dependencies/transitive-memberRef/src/main/scala/Y.scala new file mode 100644 index 000000000..df53c3c5c --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/transitive-memberRef/src/main/scala/Y.scala @@ -0,0 +1,5 @@ +package test + +class Y { + def baz(x: X) = x +} diff --git a/bridge/src/sbt-test/source-dependencies/transitive-memberRef/test b/bridge/src/sbt-test/source-dependencies/transitive-memberRef/test new file mode 100644 index 000000000..395f90229 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/transitive-memberRef/test @@ -0,0 +1,11 @@ +# introduces first compile iteration +> compile +# adds a new method to A which will cause transitive invalidation +# of all source files that inherit from it +# also, all direct dependencies of files that inherit from A will +# be invalidated (in our case that's X.scala) +$ copy-file changes/A1.scala src/main/scala/A.scala +# second iteration +> compile +# check in which compile iteration given source file got recompiled +> check-compilations diff --git a/bridge/src/sbt-test/source-dependencies/type-alias/A.scala b/bridge/src/sbt-test/source-dependencies/type-alias/A.scala new file mode 100644 index 000000000..c0c8794a7 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/type-alias/A.scala @@ -0,0 +1,4 @@ +object A { + type X = Option[Int] +} + diff --git a/bridge/src/sbt-test/source-dependencies/type-alias/B.scala b/bridge/src/sbt-test/source-dependencies/type-alias/B.scala new file mode 100644 index 000000000..81640ed8d --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/type-alias/B.scala @@ -0,0 +1,3 @@ +object B { + def y: A.X = Option(3) +} diff --git a/bridge/src/sbt-test/source-dependencies/type-alias/build.sbt b/bridge/src/sbt-test/source-dependencies/type-alias/build.sbt new file mode 100644 index 000000000..c5a1099aa --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/type-alias/build.sbt @@ -0,0 +1,3 @@ +logLevel in compile := Level.Debug + +incOptions := incOptions.value.withNameHashing(true) diff --git a/bridge/src/sbt-test/source-dependencies/type-alias/changes/A.scala b/bridge/src/sbt-test/source-dependencies/type-alias/changes/A.scala new file mode 100644 index 000000000..53aee1626 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/type-alias/changes/A.scala @@ -0,0 +1,3 @@ +object A { + type X = Int +} diff --git a/bridge/src/sbt-test/source-dependencies/type-alias/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/type-alias/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/type-alias/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/type-alias/test b/bridge/src/sbt-test/source-dependencies/type-alias/test new file mode 100644 index 000000000..f0a7fe8a1 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/type-alias/test @@ -0,0 +1,7 @@ +> compile + +# change type alias +$ copy-file changes/A.scala A.scala + +# Both A.scala and B.scala should be recompiled, producing a compile error +-> compile diff --git a/bridge/src/sbt-test/source-dependencies/type-parameter/A.scala b/bridge/src/sbt-test/source-dependencies/type-parameter/A.scala new file mode 100644 index 000000000..d712f6feb --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/type-parameter/A.scala @@ -0,0 +1 @@ +trait A[T] diff --git a/bridge/src/sbt-test/source-dependencies/type-parameter/B.scala b/bridge/src/sbt-test/source-dependencies/type-parameter/B.scala new file mode 100644 index 000000000..0f996cdc3 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/type-parameter/B.scala @@ -0,0 +1 @@ +trait B[T] extends A[T] diff --git a/bridge/src/sbt-test/source-dependencies/type-parameter/C.scala b/bridge/src/sbt-test/source-dependencies/type-parameter/C.scala new file mode 100644 index 000000000..505a83aa6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/type-parameter/C.scala @@ -0,0 +1,3 @@ +object C { + new A[Int] {} +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/type-parameter/D.scala b/bridge/src/sbt-test/source-dependencies/type-parameter/D.scala new file mode 100644 index 000000000..51273ad98 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/type-parameter/D.scala @@ -0,0 +1,3 @@ +object D { + def x[T](a: A[T]) = a +} diff --git a/bridge/src/sbt-test/source-dependencies/type-parameter/changes/A.scala b/bridge/src/sbt-test/source-dependencies/type-parameter/changes/A.scala new file mode 100644 index 000000000..0eab80adc --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/type-parameter/changes/A.scala @@ -0,0 +1 @@ +trait A diff --git a/bridge/src/sbt-test/source-dependencies/type-parameter/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/type-parameter/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/type-parameter/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/type-parameter/test b/bridge/src/sbt-test/source-dependencies/type-parameter/test new file mode 100644 index 000000000..2063e9e1b --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/type-parameter/test @@ -0,0 +1,7 @@ +> compile + +# remove type parameter from A +$ copy-file changes/A.scala A.scala + +# should get compile error because B, C, D reference A without a type parameter +-> compile
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/typeref-only/A.scala b/bridge/src/sbt-test/source-dependencies/typeref-only/A.scala new file mode 100644 index 000000000..3b274e4a8 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/typeref-only/A.scala @@ -0,0 +1,5 @@ +class A[T] + +abstract class C { + def foo: A[B] +} diff --git a/bridge/src/sbt-test/source-dependencies/typeref-only/B.scala b/bridge/src/sbt-test/source-dependencies/typeref-only/B.scala new file mode 100644 index 000000000..179f0d275 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/typeref-only/B.scala @@ -0,0 +1 @@ +class B diff --git a/bridge/src/sbt-test/source-dependencies/typeref-only/build.sbt b/bridge/src/sbt-test/source-dependencies/typeref-only/build.sbt new file mode 100644 index 000000000..02813797f --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/typeref-only/build.sbt @@ -0,0 +1,5 @@ +logLevel := Level.Debug + +// disable recompile all which causes full recompile which +// makes it more difficult to test dependency tracking +incOptions ~= { _.copy(recompileAllFraction = 1.0) } diff --git a/bridge/src/sbt-test/source-dependencies/typeref-only/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/typeref-only/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/typeref-only/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/typeref-only/test b/bridge/src/sbt-test/source-dependencies/typeref-only/test new file mode 100644 index 000000000..fb314fd7b --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/typeref-only/test @@ -0,0 +1,7 @@ +# test case for dependency tracking in case given type (`B` in our case) +# mentioned only in type ref (as a type argument) +> compile + +$ delete B.scala + +-> compile diff --git a/bridge/src/sbt-test/source-dependencies/typeref-return/A.scala b/bridge/src/sbt-test/source-dependencies/typeref-return/A.scala new file mode 100644 index 000000000..0407cb687 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/typeref-return/A.scala @@ -0,0 +1,4 @@ +object A { + type I = Int + def x: I = sys.error("not important") +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/typeref-return/B.scala b/bridge/src/sbt-test/source-dependencies/typeref-return/B.scala new file mode 100644 index 000000000..afb1169fc --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/typeref-return/B.scala @@ -0,0 +1,3 @@ +object B { + val y: Int = A.x +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/typeref-return/changes/A.scala b/bridge/src/sbt-test/source-dependencies/typeref-return/changes/A.scala new file mode 100644 index 000000000..dfac84abb --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/typeref-return/changes/A.scala @@ -0,0 +1,4 @@ +object A { + type I = String + def x: I = sys.error("Not important") +} diff --git a/bridge/src/sbt-test/source-dependencies/typeref-return/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/typeref-return/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/typeref-return/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/typeref-return/test b/bridge/src/sbt-test/source-dependencies/typeref-return/test new file mode 100644 index 000000000..751cde01b --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/typeref-return/test @@ -0,0 +1,5 @@ +> compile + +$ copy-file changes/A.scala A.scala + +-> compile
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/types-in-used-names-a/A.scala b/bridge/src/sbt-test/source-dependencies/types-in-used-names-a/A.scala new file mode 100644 index 000000000..83d15dc73 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/types-in-used-names-a/A.scala @@ -0,0 +1 @@ +class A diff --git a/bridge/src/sbt-test/source-dependencies/types-in-used-names-a/B.scala b/bridge/src/sbt-test/source-dependencies/types-in-used-names-a/B.scala new file mode 100644 index 000000000..a18aec3db --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/types-in-used-names-a/B.scala @@ -0,0 +1 @@ +class B extends A diff --git a/bridge/src/sbt-test/source-dependencies/types-in-used-names-a/C.scala b/bridge/src/sbt-test/source-dependencies/types-in-used-names-a/C.scala new file mode 100644 index 000000000..d8c306253 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/types-in-used-names-a/C.scala @@ -0,0 +1,3 @@ +object C { + val listb: List[B] = List(new B) +} diff --git a/bridge/src/sbt-test/source-dependencies/types-in-used-names-a/D.scala b/bridge/src/sbt-test/source-dependencies/types-in-used-names-a/D.scala new file mode 100644 index 000000000..fa8f13a1b --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/types-in-used-names-a/D.scala @@ -0,0 +1,3 @@ +object D { + val lista: List[A] = C.listb +} diff --git a/bridge/src/sbt-test/source-dependencies/types-in-used-names-a/changes/B2.scala b/bridge/src/sbt-test/source-dependencies/types-in-used-names-a/changes/B2.scala new file mode 100644 index 000000000..179f0d275 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/types-in-used-names-a/changes/B2.scala @@ -0,0 +1 @@ +class B diff --git a/bridge/src/sbt-test/source-dependencies/types-in-used-names-a/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/types-in-used-names-a/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/types-in-used-names-a/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/types-in-used-names-a/test b/bridge/src/sbt-test/source-dependencies/types-in-used-names-a/test new file mode 100644 index 000000000..134321021 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/types-in-used-names-a/test @@ -0,0 +1,4 @@ +> compile +$ copy-file changes/B2.scala B.scala +# Compilation of D.scala should fail because B is no longer a subtype of A +-> compile diff --git a/bridge/src/sbt-test/source-dependencies/types-in-used-names-b/A.scala b/bridge/src/sbt-test/source-dependencies/types-in-used-names-b/A.scala new file mode 100644 index 000000000..301b546cb --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/types-in-used-names-b/A.scala @@ -0,0 +1,5 @@ +class A { + type T <: S + type S <: Int + def foo: T = null.asInstanceOf[T] +} diff --git a/bridge/src/sbt-test/source-dependencies/types-in-used-names-b/B.scala b/bridge/src/sbt-test/source-dependencies/types-in-used-names-b/B.scala new file mode 100644 index 000000000..edfe2e6a8 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/types-in-used-names-b/B.scala @@ -0,0 +1,3 @@ +object B { + val x: Int = (new A).foo +} diff --git a/bridge/src/sbt-test/source-dependencies/types-in-used-names-b/changes/A2.scala b/bridge/src/sbt-test/source-dependencies/types-in-used-names-b/changes/A2.scala new file mode 100644 index 000000000..bbe60f206 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/types-in-used-names-b/changes/A2.scala @@ -0,0 +1,5 @@ +class A { + type T <: S + type S <: String + def foo: T = null.asInstanceOf[T] +} diff --git a/bridge/src/sbt-test/source-dependencies/types-in-used-names-b/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/types-in-used-names-b/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/types-in-used-names-b/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/types-in-used-names-b/test b/bridge/src/sbt-test/source-dependencies/types-in-used-names-b/test new file mode 100644 index 000000000..97902bd42 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/types-in-used-names-b/test @@ -0,0 +1,4 @@ +> compile +$ copy-file changes/A2.scala A.scala +# Compilation of B.scala should fail because A#S is no longer a subtype of Int +-> compile diff --git a/bridge/src/sbt-test/source-dependencies/value-class-underlying/A.scala b/bridge/src/sbt-test/source-dependencies/value-class-underlying/A.scala new file mode 100644 index 000000000..dbaa1c3f0 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/value-class-underlying/A.scala @@ -0,0 +1 @@ +class A(val x: Int) extends AnyVal diff --git a/bridge/src/sbt-test/source-dependencies/value-class-underlying/B.scala b/bridge/src/sbt-test/source-dependencies/value-class-underlying/B.scala new file mode 100644 index 000000000..7d5a86a95 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/value-class-underlying/B.scala @@ -0,0 +1,3 @@ +object B { + def foo: A = new A(0) +} diff --git a/bridge/src/sbt-test/source-dependencies/value-class-underlying/C.scala b/bridge/src/sbt-test/source-dependencies/value-class-underlying/C.scala new file mode 100644 index 000000000..1a9a42bde --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/value-class-underlying/C.scala @@ -0,0 +1,5 @@ +object C { + def main(args: Array[String]): Unit = { + val x = B.foo + } +} diff --git a/bridge/src/sbt-test/source-dependencies/value-class-underlying/build.sbt b/bridge/src/sbt-test/source-dependencies/value-class-underlying/build.sbt new file mode 100644 index 000000000..6448c246c --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/value-class-underlying/build.sbt @@ -0,0 +1 @@ +logLevel := Level.Debug diff --git a/bridge/src/sbt-test/source-dependencies/value-class-underlying/changes/A2.scala b/bridge/src/sbt-test/source-dependencies/value-class-underlying/changes/A2.scala new file mode 100644 index 000000000..94d868a92 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/value-class-underlying/changes/A2.scala @@ -0,0 +1 @@ +class A(val x: Double) extends AnyVal diff --git a/bridge/src/sbt-test/source-dependencies/value-class-underlying/test b/bridge/src/sbt-test/source-dependencies/value-class-underlying/test new file mode 100644 index 000000000..a42fd2d71 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/value-class-underlying/test @@ -0,0 +1,3 @@ +> run +$ copy-file changes/A2.scala A.scala +> run diff --git a/bridge/src/sbt-test/source-dependencies/value-class/build.sbt b/bridge/src/sbt-test/source-dependencies/value-class/build.sbt new file mode 100644 index 000000000..77cf9f18c --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/value-class/build.sbt @@ -0,0 +1 @@ +incOptions := incOptions.value.withRecompileAllFraction(1.0) diff --git a/bridge/src/sbt-test/source-dependencies/value-class/changes/A0.scala b/bridge/src/sbt-test/source-dependencies/value-class/changes/A0.scala new file mode 100644 index 000000000..ad5bf4c56 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/value-class/changes/A0.scala @@ -0,0 +1 @@ +class A(val x: Int) diff --git a/bridge/src/sbt-test/source-dependencies/value-class/changes/A1.scala b/bridge/src/sbt-test/source-dependencies/value-class/changes/A1.scala new file mode 100644 index 000000000..dbaa1c3f0 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/value-class/changes/A1.scala @@ -0,0 +1 @@ +class A(val x: Int) extends AnyVal diff --git a/bridge/src/sbt-test/source-dependencies/value-class/changes/B0.scala b/bridge/src/sbt-test/source-dependencies/value-class/changes/B0.scala new file mode 100644 index 000000000..0dba978c3 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/value-class/changes/B0.scala @@ -0,0 +1,3 @@ +class B { + def foo(a: A): Int = 1 +} diff --git a/bridge/src/sbt-test/source-dependencies/value-class/changes/B1.scala b/bridge/src/sbt-test/source-dependencies/value-class/changes/B1.scala new file mode 100644 index 000000000..c7b689c5e --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/value-class/changes/B1.scala @@ -0,0 +1,3 @@ +class B { + def bar: A = new A(0) +} diff --git a/bridge/src/sbt-test/source-dependencies/value-class/changes/B2.scala b/bridge/src/sbt-test/source-dependencies/value-class/changes/B2.scala new file mode 100644 index 000000000..fe1136389 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/value-class/changes/B2.scala @@ -0,0 +1,3 @@ +class B { + def bar(dummy: String)(dummy2: String): A = new A(0) +} diff --git a/bridge/src/sbt-test/source-dependencies/value-class/changes/C0.scala b/bridge/src/sbt-test/source-dependencies/value-class/changes/C0.scala new file mode 100644 index 000000000..1fed7a120 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/value-class/changes/C0.scala @@ -0,0 +1,3 @@ +object C extends dotty.runtime.LegacyApp { + println(new B().foo(null)) +} diff --git a/bridge/src/sbt-test/source-dependencies/value-class/changes/C1.scala b/bridge/src/sbt-test/source-dependencies/value-class/changes/C1.scala new file mode 100644 index 000000000..f10fe2d16 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/value-class/changes/C1.scala @@ -0,0 +1,3 @@ +object C extends dotty.runtime.LegacyApp { + println(new B().bar.x) +} diff --git a/bridge/src/sbt-test/source-dependencies/value-class/changes/C2.scala b/bridge/src/sbt-test/source-dependencies/value-class/changes/C2.scala new file mode 100644 index 000000000..a0c5c6972 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/value-class/changes/C2.scala @@ -0,0 +1,3 @@ +object C extends dotty.runtime.LegacyApp { + println(new B().bar("")("").x) +} diff --git a/bridge/src/sbt-test/source-dependencies/value-class/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/value-class/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/value-class/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/value-class/test b/bridge/src/sbt-test/source-dependencies/value-class/test new file mode 100644 index 000000000..268274bf6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/value-class/test @@ -0,0 +1,50 @@ +## Case 1: value class as parameter of method +$ copy-file changes/A0.scala src/main/scala/A.scala +$ copy-file changes/B0.scala src/main/scala/B.scala +$ copy-file changes/C0.scala src/main/scala/C.scala + +# A is a normal class. B.foo accepts a parameter of type A. C calls B.foo, giving it `null`. +> compile +> run + +# Make A a value class. +$ copy-file changes/A1.scala src/main/scala/A.scala + +# The code no longer compiles because B.foo no longer accepts `null` as an argument. +# This means that we have invalidated C.scala, as expected! +-> compile + + +## Case 2: value class as return type of method with no parameter lists +$ copy-file changes/A0.scala src/main/scala/A.scala +$ copy-file changes/B1.scala src/main/scala/B.scala +$ copy-file changes/C1.scala src/main/scala/C.scala + +# A is a normal class. B.bar takes no arguments and returns an instance of A. C calls B.bar. +> compile +> run + +# Make A a value class. +$ copy-file changes/A1.scala src/main/scala/A.scala + +# The code compiles. It will run iff C is recompiled because the signature of B.bar has changed, +# because A is now a value class. +> run + + +## Case 3: value class as return type of method with multiple parameter lists +$ copy-file changes/A0.scala src/main/scala/A.scala +$ copy-file changes/B2.scala src/main/scala/B.scala +$ copy-file changes/C2.scala src/main/scala/C.scala + +# A is a normal class. B.bar takes two dummy arguments and returns an instance of A. C calls B.bar("")(""). +> compile +> run + +# Make A a value class. +$ copy-file changes/A1.scala src/main/scala/A.scala + +# The code compiles. It will run iff C is recompiled because the signature of B.bar has changed, +# because A is now a value class. +> run + diff --git a/bridge/src/sbt-test/source-dependencies/var/A.scala b/bridge/src/sbt-test/source-dependencies/var/A.scala new file mode 100644 index 000000000..1c5d96e09 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/var/A.scala @@ -0,0 +1,5 @@ +class A +{ + def x = 3 + def x_=(x$1: Int) = () +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/var/B.scala b/bridge/src/sbt-test/source-dependencies/var/B.scala new file mode 100644 index 000000000..3ee290f84 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/var/B.scala @@ -0,0 +1,4 @@ +class B extends A +{ + override var x = 3 +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/var/changes/A.scala b/bridge/src/sbt-test/source-dependencies/var/changes/A.scala new file mode 100644 index 000000000..d1c251596 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/var/changes/A.scala @@ -0,0 +1,4 @@ +class A +{ + var x = 3 +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/var/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/var/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/var/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/var/test b/bridge/src/sbt-test/source-dependencies/var/test new file mode 100644 index 000000000..1da88684d --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/var/test @@ -0,0 +1,6 @@ +> compile + +# replace var x with def x, def x_= +$ copy-file changes/A.scala A.scala + +-> compile
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/variance/A.scala b/bridge/src/sbt-test/source-dependencies/variance/A.scala new file mode 100644 index 000000000..4581bfec8 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/variance/A.scala @@ -0,0 +1,2 @@ +class A[+T] +
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/variance/C.scala b/bridge/src/sbt-test/source-dependencies/variance/C.scala new file mode 100644 index 000000000..8b526d9af --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/variance/C.scala @@ -0,0 +1,3 @@ +object C { + val a: A[Any] = new A[Int] +} diff --git a/bridge/src/sbt-test/source-dependencies/variance/changes/A.scala b/bridge/src/sbt-test/source-dependencies/variance/changes/A.scala new file mode 100644 index 000000000..e9c64dff6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/variance/changes/A.scala @@ -0,0 +1,2 @@ +class A[T] +
\ No newline at end of file diff --git a/bridge/src/sbt-test/source-dependencies/variance/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/source-dependencies/variance/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/variance/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/source-dependencies/variance/test b/bridge/src/sbt-test/source-dependencies/variance/test new file mode 100644 index 000000000..d74e441e7 --- /dev/null +++ b/bridge/src/sbt-test/source-dependencies/variance/test @@ -0,0 +1,6 @@ +> compile + +# make T invariant +$ copy-file changes/A.scala A.scala + +-> compile
\ No newline at end of file diff --git a/bridge/src/test/scala/xsbt/DependencySpecification.scala b/bridge/src/test/scala/xsbt/DependencySpecification.scala new file mode 100644 index 000000000..60545091b --- /dev/null +++ b/bridge/src/test/scala/xsbt/DependencySpecification.scala @@ -0,0 +1,151 @@ +/** Adapted from https://github.com/sbt/sbt/blob/0.13/compile/interface/src/test/scala/xsbt/DependencySpecification.scala */ +package xsbt + +import org.junit.runner.RunWith +import xsbti.api.ClassLike +import xsbti.api.Def +import xsbt.api.SameAPI +import org.specs2.mutable.Specification +import org.specs2.runner.JUnitRunner + +import ScalaCompilerForUnitTesting.ExtractedSourceDependencies + +@RunWith(classOf[JUnitRunner]) +class DependencySpecification extends Specification { + + "Extracted source dependencies from public members" in { + val sourceDependencies = extractSourceDependenciesPublic + val memberRef = sourceDependencies.memberRef + val inheritance = sourceDependencies.inheritance + memberRef('A) === Set.empty + inheritance('A) === Set.empty + memberRef('B) === Set('A, 'D) + inheritance('B) === Set('D) + memberRef('C) === Set('A) + inheritance('C) === Set.empty + memberRef('D) === Set.empty + inheritance('D) === Set.empty + memberRef('E) === Set.empty + inheritance('E) === Set.empty + memberRef('F) === Set('A, 'B, 'C, 'D, 'E, 'G) + inheritance('F) === Set('A, 'E) + memberRef('H) === Set('B, 'E, 'G) + // aliases and applied type constructors are expanded so we have inheritance dependency on B + inheritance('H) === Set('B, 'E) + } + + "Extracted source dependencies from private members" in { + val sourceDependencies = extractSourceDependenciesPrivate + val memberRef = sourceDependencies.memberRef + val inheritance = sourceDependencies.inheritance + memberRef('A) === Set.empty + inheritance('A) === Set.empty + memberRef('B) === Set.empty + inheritance('B) === Set.empty + memberRef('C) === Set('A) + inheritance('C) === Set('A) + memberRef('D) === Set('B) + inheritance('D) === Set('B) + } + + "Extracted source dependencies with trait as first parent" in { + val sourceDependencies = extractSourceDependenciesTraitAsFirstPatent + val memberRef = sourceDependencies.memberRef + val inheritance = sourceDependencies.inheritance + memberRef('A) === Set.empty + inheritance('A) === Set.empty + memberRef('B) === Set('A) + inheritance('B) === Set('A) + // verify that memberRef captures the oddity described in documentation of `Relations.inheritance` + // we are mainly interested whether dependency on A is captured in `memberRef` relation so + // the invariant that says that memberRef is superset of inheritance relation is preserved + memberRef('C) === Set('A, 'B) + inheritance('C) === Set('A, 'B) + // same as above but indirect (C -> B -> A), note that only A is visible here + memberRef('D) === Set('A, 'C) + inheritance('D) === Set('A, 'C) + } + + /* + "Extracted source dependencies from macro arguments" in { + val sourceDependencies = extractSourceDependenciesFromMacroArgument + val memberRef = sourceDependencies.memberRef + val inheritance = sourceDependencies.inheritance + + memberRef('A) === Set('B, 'C) + inheritance('A) === Set.empty + memberRef('B) === Set.empty + inheritance('B) === Set.empty + memberRef('C) === Set.empty + inheritance('C) === Set.empty + } + */ + + private def extractSourceDependenciesPublic: ExtractedSourceDependencies = { + val srcA = "class A" + val srcB = "class B extends D[A]" + val srcC = """|class C { + | def a: A = null + |}""".stripMargin + val srcD = "class D[T]" + val srcE = "trait E[T]" + val srcF = "trait F extends A with E[D[B]] { self: G.MyC => }" + val srcG = "object G { type T[x] = B ; type MyC = C }" + // T is a type constructor [x]B + // B extends D + // E verifies the core type gets pulled out + val srcH = "trait H extends G.T[Int] with (E[Int] @unchecked)" + + val compilerForTesting = new ScalaCompilerForUnitTesting(nameHashing = true) + val sourceDependencies = compilerForTesting.extractDependenciesFromSrcs('A -> srcA, 'B -> srcB, 'C -> srcC, + 'D -> srcD, 'E -> srcE, 'F -> srcF, 'G -> srcG, 'H -> srcH) + sourceDependencies + } + + private def extractSourceDependenciesPrivate: ExtractedSourceDependencies = { + val srcA = "class A" + val srcB = "class B" + val srcC = "class C { private class Inner1 extends A }" + val srcD = "class D { def foo: Unit = { class Inner2 extends B } }" + + val compilerForTesting = new ScalaCompilerForUnitTesting(nameHashing = true) + val sourceDependencies = + compilerForTesting.extractDependenciesFromSrcs('A -> srcA, 'B -> srcB, 'C -> srcC, 'D -> srcD) + sourceDependencies + } + + private def extractSourceDependenciesTraitAsFirstPatent: ExtractedSourceDependencies = { + val srcA = "class A" + val srcB = "trait B extends A" + val srcC = "trait C extends B" + val srcD = "class D extends C" + + val compilerForTesting = new ScalaCompilerForUnitTesting(nameHashing = true) + val sourceDependencies = + compilerForTesting.extractDependenciesFromSrcs('A -> srcA, 'B -> srcB, 'C -> srcC, 'D -> srcD) + sourceDependencies + } + + /* + private def extractSourceDependenciesFromMacroArgument: ExtractedSourceDependencies = { + val srcA = "class A { println(B.printTree(C.foo)) }" + val srcB = """ + |import scala.language.experimental.macros + |import scala.reflect.macros._ + |object B { + | def printTree(arg: Any) = macro printTreeImpl + | def printTreeImpl(c: Context)(arg: c.Expr[Any]): c.Expr[String] = { + | val argStr = arg.tree.toString + | val literalStr = c.universe.Literal(c.universe.Constant(argStr)) + | c.Expr[String](literalStr) + | } + |}""".stripMargin + val srcC = "object C { val foo = 1 }" + + val compilerForTesting = new ScalaCompilerForUnitTesting(nameHashing = true) + val sourceDependencies = + compilerForTesting.extractDependenciesFromSrcs(List(Map('B -> srcB, 'C -> srcC), Map('A -> srcA))) + sourceDependencies + } + */ +} diff --git a/bridge/src/test/scala/xsbt/ExtractAPISpecification.scala b/bridge/src/test/scala/xsbt/ExtractAPISpecification.scala new file mode 100644 index 000000000..f5af67e45 --- /dev/null +++ b/bridge/src/test/scala/xsbt/ExtractAPISpecification.scala @@ -0,0 +1,45 @@ +/** Adapted from https://github.com/sbt/sbt/blob/0.13/compile/interface/src/test/scala/xsbt/ExtractAPISpecification.scala */ +package xsbt + +import org.junit.runner.RunWith +import xsbti.api.ClassLike +import xsbti.api.Def +import xsbt.api.ShowAPI +import org.specs2.mutable.Specification +import org.specs2.runner.JUnitRunner + +@RunWith(classOf[JUnitRunner]) +class ExtractAPISpecification extends Specification { + + "Existential types in method signatures" should { + "have stable names" in { stableExistentialNames } + } + + def stableExistentialNames: Boolean = { + def compileAndGetFooMethodApi(src: String): Def = { + val compilerForTesting = new ScalaCompilerForUnitTesting + val sourceApi = compilerForTesting.extractApiFromSrc(src) + val FooApi = sourceApi.definitions().find(_.name() == "Foo").get.asInstanceOf[ClassLike] + val fooMethodApi = FooApi.structure().declared().find(_.name == "foo").get + fooMethodApi.asInstanceOf[Def] + } + val src1 = """ + |class Box[T] + |class Foo { + | def foo: Box[_] = null + | + }""".stripMargin + val fooMethodApi1 = compileAndGetFooMethodApi(src1) + val src2 = """ + |class Box[T] + |class Foo { + | def bar: Box[_] = null + | def foo: Box[_] = null + | + }""".stripMargin + val fooMethodApi2 = compileAndGetFooMethodApi(src2) + fooMethodApi1 == fooMethodApi2 + // Fails because xsbt.api is compiled with Scala 2.10 + // SameAPI.apply(fooMethodApi1, fooMethodApi2) + } +} diff --git a/bridge/src/test/scala/xsbt/ExtractUsedNamesSpecification.scala b/bridge/src/test/scala/xsbt/ExtractUsedNamesSpecification.scala new file mode 100644 index 000000000..ed463a3e6 --- /dev/null +++ b/bridge/src/test/scala/xsbt/ExtractUsedNamesSpecification.scala @@ -0,0 +1,119 @@ +/** Adapted from https://github.com/sbt/sbt/blob/0.13/compile/interface/src/test/scala/xsbt/ExtractUsedNamesSpecification.scala */ +package xsbt + +import org.junit.runner.RunWith +import xsbti.api.ClassLike +import xsbti.api.Def +import xsbti.api.Package +import xsbt.api.SameAPI +import org.junit.runners.JUnit4 + +import org.specs2.mutable.Specification + +@RunWith(classOf[JUnit4]) +class ExtractUsedNamesSpecification extends Specification { + + /** + * Standard names that appear in every compilation unit that has any class + * definition. + */ + private val standardNames = Set( + // All class extend Object + "Object", + // All class have a default constructor called <init> + "<init>", + // the return type of the default constructor is Unit + "Unit" + ) + + "imported name" in { + val src = """ + |package a { class A } + |package b { + | import a.{A => A2} + |}""".stripMargin + val compilerForTesting = new ScalaCompilerForUnitTesting(nameHashing = true) + val usedNames = compilerForTesting.extractUsedNamesFromSrc(src) + val expectedNames = standardNames ++ Set("a", "A", "A2", "b") + usedNames === expectedNames + } + + // test covers https://github.com/gkossakowski/sbt/issues/6 + "names in type tree" in { + val srcA = """| + |package a { + | class A { + | class C { class D } + | } + | class B[T] + | class BB + |}""".stripMargin + val srcB = """| + |package b { + | abstract class X { + | def foo: a.A#C#D + | def bar: a.B[a.BB] + | } + |}""".stripMargin + val compilerForTesting = new ScalaCompilerForUnitTesting(nameHashing = true) + val usedNames = compilerForTesting.extractUsedNamesFromSrc(srcA, srcB) + // DOTTY: unlike the scalac sbt phase, this does not contain "X", I believe this is safe + // TODO: report issue against sbt suggesting that they do the same + val expectedNames = standardNames ++ Set("a", "A", "B", "C", "D", "b", "BB") + usedNames === expectedNames + } + + // test for https://github.com/gkossakowski/sbt/issues/5 + "symbolic names" in { + val srcA = """| + |class A { + | def `=`: Int = 3 + |}""".stripMargin + val srcB = """| + |class B { + | def foo(a: A) = a.`=` + |}""".stripMargin + val compilerForTesting = new ScalaCompilerForUnitTesting(nameHashing = true) + val usedNames = compilerForTesting.extractUsedNamesFromSrc(srcA, srcB) + // DOTTY TODO: "Int" is not actually used, but we collect it because + // it's the inferred return type so it appears in a TypeTree + // We could avoid this by checking if the untyped tree has a return type + // but is it worth it? Revisit this after https://github.com/sbt/sbt/issues/1104 + // has landed. + val expectedNames = standardNames ++ Set("A", "a", "$eq", "Int") + usedNames === expectedNames + } + + // test for https://github.com/gkossakowski/sbt/issues/3 + "used names from the same compilation unit" in { + val src = "class A { def foo: Int = 0; def bar: Int = foo }" + val compilerForTesting = new ScalaCompilerForUnitTesting(nameHashing = true) + val usedNames = compilerForTesting.extractUsedNamesFromSrc(src) + val expectedNames = standardNames ++ Set("A", "foo", "Int") + usedNames === expectedNames + } + + // pending test for https://issues.scala-lang.org/browse/SI-7173 + "names of constants" in { + val src = "class A { final val foo = 12; def bar: Int = foo }" + val compilerForTesting = new ScalaCompilerForUnitTesting(nameHashing = true) + val usedNames = compilerForTesting.extractUsedNamesFromSrc(src) + val expectedNames = standardNames ++ Set("A", "foo", "Int") + usedNames === expectedNames + } + + // pending test for https://github.com/gkossakowski/sbt/issues/4 + // TODO: we should fix it by having special treatment of `selectDynamic` and `applyDynamic` calls + "names from method calls on Dynamic" in { + val srcA = """|import scala.language.dynamics + |class A extends Dynamic { + | def selectDynamic(name: String): Int = name.length + |}""".stripMargin + val srcB = "class B { def foo(a: A): Int = a.bla }" + val compilerForTesting = new ScalaCompilerForUnitTesting(nameHashing = true) + val usedNames = compilerForTesting.extractUsedNamesFromSrc(srcA, srcB) + val expectedNames = standardNames ++ Set("B", "A", "a", "Int", "selectDynamic", "bla") + usedNames === expectedNames + }.pendingUntilFixed("Call to Dynamic is desugared in type checker so Select nodes is turned into string literal.") + +} diff --git a/bridge/src/test/scala/xsbt/ScalaCompilerForUnitTesting.scala b/bridge/src/test/scala/xsbt/ScalaCompilerForUnitTesting.scala new file mode 100644 index 000000000..db037effe --- /dev/null +++ b/bridge/src/test/scala/xsbt/ScalaCompilerForUnitTesting.scala @@ -0,0 +1,191 @@ +/** Adapted from https://github.com/sbt/sbt/blob/0.13/compile/interface/src/test/scala/xsbt/ScalaCompilerForUnitTesting.scala */ +package xsbt + +import xsbti.compile.SingleOutput +import java.io.File +import _root_.scala.tools.nsc.reporters.ConsoleReporter +import _root_.scala.tools.nsc.Settings +import xsbti._ +import xsbti.api.SourceAPI +import sbt.IO.withTemporaryDirectory +import xsbti.api.ClassLike +import xsbti.api.Definition +import xsbti.api.Def +import xsbt.api.SameAPI +import sbt.ConsoleLogger +import xsbti.DependencyContext._ + +import ScalaCompilerForUnitTesting.ExtractedSourceDependencies + +/** + * Provides common functionality needed for unit tests that require compiling + * source code using Scala compiler. + */ +class ScalaCompilerForUnitTesting(nameHashing: Boolean = false) { + + /** + * Compiles given source code using Scala compiler and returns API representation + * extracted by ExtractAPI class. + */ + def extractApiFromSrc(src: String): SourceAPI = { + val (Seq(tempSrcFile), analysisCallback) = compileSrcs(src) + analysisCallback.apis(tempSrcFile) + } + + def extractUsedNamesFromSrc(src: String): Set[String] = { + val (Seq(tempSrcFile), analysisCallback) = compileSrcs(src) + analysisCallback.usedNames(tempSrcFile) + } + + /** + * Extract used names from src provided as the second argument. + * + * The purpose of the first argument is to define names that the second + * source is going to refer to. Both files are compiled in the same compiler + * Run but only names used in the second src file are returned. + */ + def extractUsedNamesFromSrc(definitionSrc: String, actualSrc: String): Set[String] = { + // we drop temp src file corresponding to the definition src file + val (Seq(_, tempSrcFile), analysisCallback) = compileSrcs(definitionSrc, actualSrc) + analysisCallback.usedNames(tempSrcFile) + } + + /** + * Compiles given source code snippets (passed as Strings) using Scala compiler and returns extracted + * dependencies between snippets. Source code snippets are identified by symbols. Each symbol should + * be associated with one snippet only. + * + * Snippets can be grouped to be compiled together in the same compiler run. This is + * useful to compile macros, which cannot be used in the same compilation run that + * defines them. + * + * Symbols are used to express extracted dependencies between source code snippets. This way we have + * file system-independent way of testing dependencies between source code "files". + */ + def extractDependenciesFromSrcs(srcs: List[Map[Symbol, String]]): ExtractedSourceDependencies = { + val rawGroupedSrcs = srcs.map(_.values.toList) + val symbols = srcs.flatMap(_.keys) + val (tempSrcFiles, testCallback) = compileSrcs(rawGroupedSrcs) + val fileToSymbol = (tempSrcFiles zip symbols).toMap + + val memberRefFileDeps = testCallback.sourceDependencies collect { + // false indicates that those dependencies are not introduced by inheritance + case (target, src, DependencyByMemberRef) => (src, target) + } + val inheritanceFileDeps = testCallback.sourceDependencies collect { + // true indicates that those dependencies are introduced by inheritance + case (target, src, DependencyByInheritance) => (src, target) + } + def toSymbols(src: File, target: File): (Symbol, Symbol) = (fileToSymbol(src), fileToSymbol(target)) + val memberRefDeps = memberRefFileDeps map { case (src, target) => toSymbols(src, target) } + val inheritanceDeps = inheritanceFileDeps map { case (src, target) => toSymbols(src, target) } + def pairsToMultiMap[A, B](pairs: Seq[(A, B)]): Map[A, Set[B]] = { + import scala.collection.mutable.{ HashMap, MultiMap } + val emptyMultiMap = new HashMap[A, scala.collection.mutable.Set[B]] with MultiMap[A, B] + val multiMap = pairs.foldLeft(emptyMultiMap) { + case (acc, (key, value)) => + acc.addBinding(key, value) + } + // convert all collections to immutable variants + multiMap.toMap.mapValues(_.toSet).withDefaultValue(Set.empty) + } + + ExtractedSourceDependencies(pairsToMultiMap(memberRefDeps), pairsToMultiMap(inheritanceDeps)) + } + + def extractDependenciesFromSrcs(srcs: (Symbol, String)*): ExtractedSourceDependencies = { + val symbols = srcs.map(_._1) + assert(symbols.distinct.size == symbols.size, + s"Duplicate symbols for srcs detected: $symbols") + extractDependenciesFromSrcs(List(srcs.toMap)) + } + + /** + * Compiles given source code snippets written to temporary files. Each snippet is + * written to a separate temporary file. + * + * Snippets can be grouped to be compiled together in the same compiler run. This is + * useful to compile macros, which cannot be used in the same compilation run that + * defines them. + * + * The sequence of temporary files corresponding to passed snippets and analysis + * callback is returned as a result. + */ + private def compileSrcs(groupedSrcs: List[List[String]]): (Seq[File], TestCallback) = { + withTemporaryDirectory { temp => + val analysisCallback = new TestCallback(nameHashing) + val classesDir = new File(temp, "classes") + classesDir.mkdir() + + // val (compiler, ctx) = prepareCompiler(classesDir, analysisCallback, classesDir.toString) + + val files = for ((compilationUnit, unitId) <- groupedSrcs.zipWithIndex) yield { + val (compiler, ctx) = prepareCompiler(classesDir, analysisCallback, classesDir.toString) + val run = compiler.newRun(ctx) + val srcFiles = compilationUnit.toSeq.zipWithIndex map { + case (src, i) => + val fileName = s"Test-$unitId-$i.scala" + prepareSrcFile(temp, fileName, src) + } + val srcFilePaths = srcFiles.map(srcFile => srcFile.getAbsolutePath).toList + + run.compile(srcFilePaths) + + srcFilePaths.foreach(f => new File(f).delete) + srcFiles + } + (files.flatten.toSeq, analysisCallback) + } + } + + private def compileSrcs(srcs: String*): (Seq[File], TestCallback) = { + compileSrcs(List(srcs.toList)) + } + + private def prepareSrcFile(baseDir: File, fileName: String, src: String): File = { + val srcFile = new File(baseDir, fileName) + sbt.IO.write(srcFile, src) + srcFile + } + + private def prepareCompiler(outputDir: File, analysisCallback: AnalysisCallback, classpath: String = ".") = { + val args = Array.empty[String] + object output extends SingleOutput { + def outputDirectory: File = outputDir + override def toString = s"SingleOutput($outputDirectory)" + } + + import dotty.tools.dotc._ + import dotty.tools.dotc.core.Contexts._ + + val driver = new Driver { + + protected def newCompiler(implicit ctx: Context): Compiler = new Compiler + + override protected def sourcesRequired = false + + def getCompiler(args: Array[String], rootCtx: Context) = { + val (fileNames, ctx) = setup(args, rootCtx) + (newCompiler(ctx), ctx) + } + } + val ctx = (new ContextBase).initialCtx.fresh.setSbtCallback(analysisCallback) + driver.getCompiler(Array("-classpath", classpath, "-usejavacp"), ctx) + } + + private object ConsoleReporter extends Reporter { + def reset(): Unit = () + def hasErrors: Boolean = false + def hasWarnings: Boolean = false + def printWarnings(): Unit = () + def problems: Array[Problem] = Array.empty + def log(pos: Position, msg: String, sev: Severity): Unit = println(msg) + def comment(pos: Position, msg: String): Unit = () + def printSummary(): Unit = () + } + +} + +object ScalaCompilerForUnitTesting { + case class ExtractedSourceDependencies(memberRef: Map[Symbol, Set[Symbol]], inheritance: Map[Symbol, Set[Symbol]]) +} diff --git a/bridge/src/test/scala/xsbti/TestCallback.scala b/bridge/src/test/scala/xsbti/TestCallback.scala new file mode 100644 index 000000000..b849e1a80 --- /dev/null +++ b/bridge/src/test/scala/xsbti/TestCallback.scala @@ -0,0 +1,35 @@ +/** Copied from https://github.com/sbt/sbt/blob/0.13/interface/src/test/scala/xsbti/TestCallback.scala */ +package xsbti + +import java.io.File +import scala.collection.mutable.ArrayBuffer +import xsbti.api.SourceAPI +import xsbti.DependencyContext._ + +class TestCallback(override val nameHashing: Boolean = false) extends AnalysisCallback +{ + val sourceDependencies = new ArrayBuffer[(File, File, DependencyContext)] + val binaryDependencies = new ArrayBuffer[(File, String, File, DependencyContext)] + val products = new ArrayBuffer[(File, File, String)] + val usedNames = scala.collection.mutable.Map.empty[File, Set[String]].withDefaultValue(Set.empty) + val apis: scala.collection.mutable.Map[File, SourceAPI] = scala.collection.mutable.Map.empty + + def sourceDependency(dependsOn: File, source: File, inherited: Boolean): Unit = { + val context = if(inherited) DependencyByInheritance else DependencyByMemberRef + sourceDependency(dependsOn, source, context) + } + def sourceDependency(dependsOn: File, source: File, context: DependencyContext): Unit = { sourceDependencies += ((dependsOn, source, context)) } + def binaryDependency(binary: File, name: String, source: File, inherited: Boolean): Unit = { + val context = if(inherited) DependencyByInheritance else DependencyByMemberRef + binaryDependency(binary, name, source, context) + } + def binaryDependency(binary: File, name: String, source: File, context: DependencyContext): Unit = { binaryDependencies += ((binary, name, source, context)) } + def generatedClass(source: File, module: File, name: String): Unit = { products += ((source, module, name)) } + + def usedName(source: File, name: String): Unit = { usedNames(source) += name } + def api(source: File, sourceAPI: SourceAPI): Unit = { + assert(!apis.contains(source), s"The `api` method should be called once per source file: $source") + apis(source) = sourceAPI + } + def problem(category: String, pos: xsbti.Position, message: String, severity: xsbti.Severity, reported: Boolean): Unit = () +} |