aboutsummaryrefslogtreecommitdiff
path: root/bridge/src/sbt-test/source-dependencies/java-static
diff options
context:
space:
mode:
authorGuillaume Martres <smarter@ubuntu.com>2016-05-31 15:23:04 +0200
committerFelix Mulder <felix.mulder@gmail.com>2016-06-07 17:10:36 +0200
commit09b2f39731386cd5b3688d5c3badf75d956d4f6d (patch)
treed122fc0e96d6c1cd22d7e0d0b5ee523563d534e7 /bridge/src/sbt-test/source-dependencies/java-static
parent030ff82070197f0c126f5c0287e076b0f6b6dd8d (diff)
downloaddotty-09b2f39731386cd5b3688d5c3badf75d956d4f6d.tar.gz
dotty-09b2f39731386cd5b3688d5c3badf75d956d4f6d.tar.bz2
dotty-09b2f39731386cd5b3688d5c3badf75d956d4f6d.zip
Make the dotty-bridge sbt project a subproject of dotty
Note that the dotty-bridge tests will not be run automatically by `test` which is short for `dotty/test`, to run the dotty-bridge tests, do in sbt: > dotty-bridge/test > dotty-bridge/scripted Original history: https://github.com/smarter/dotty-bridge/commits/master
Diffstat (limited to 'bridge/src/sbt-test/source-dependencies/java-static')
-rw-r--r--bridge/src/sbt-test/source-dependencies/java-static/changes/J1.java4
-rw-r--r--bridge/src/sbt-test/source-dependencies/java-static/changes/J2.java4
-rw-r--r--bridge/src/sbt-test/source-dependencies/java-static/changes/S.scala4
-rw-r--r--bridge/src/sbt-test/source-dependencies/java-static/project/DottyInjectedPlugin.scala17
-rw-r--r--bridge/src/sbt-test/source-dependencies/java-static/test24
5 files changed, 53 insertions, 0 deletions
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