diff --git a/.drone.yml b/.drone.yml index 07ee3a45f974..abb588fdce65 100644 --- a/.drone.yml +++ b/.drone.yml @@ -23,7 +23,7 @@ pipeline: # We run tests in parallel. Tests run in a copy of the working directory to avoid conflict test: group: test - image: lampepfl/dotty:2018-04-10 + image: lampepfl/dotty:2018-05-23 commands: - cp -R . /tmp/1/ && cd /tmp/1/ - ./project/scripts/sbt ";compile ;test" @@ -31,21 +31,21 @@ pipeline: test_bootstrapped: group: test - image: lampepfl/dotty:2018-04-10 + image: lampepfl/dotty:2018-05-23 commands: - cp -R . /tmp/2/ && cd /tmp/2/ - ./project/scripts/sbt ";dotty-bootstrapped/compile ;dotty-bootstrapped/test" test_optimised: group: test - image: lampepfl/dotty:2018-04-10 + image: lampepfl/dotty:2018-05-23 commands: - cp -R . /tmp/3/ && cd /tmp/3/ - ./project/scripts/sbt dotty-optimised/test test_sbt: group: test - image: lampepfl/dotty:2018-04-10 + image: lampepfl/dotty:2018-05-23 commands: - cp -R . /tmp/4/ && cd /tmp/4/ - ./project/scripts/sbt sbt-dotty/scripted @@ -55,7 +55,7 @@ pipeline: # DOCUMENTATION: documentation: - image: lampepfl/dotty:2018-04-10 + image: lampepfl/dotty:2018-05-23 commands: - ./project/scripts/genDocs secrets: [ bot_pass ] @@ -67,7 +67,7 @@ pipeline: # PUBLISHING: # Publishing expect NIGHTLYBUILD or RELEASEBUILD to be set. See dottyVersion in Build.scala publish_nightly: - image: lampepfl/dotty:2018-04-10 + image: lampepfl/dotty:2018-05-23 environment: - NIGHTLYBUILD=yes commands: @@ -78,7 +78,7 @@ pipeline: environment: nightly publish_release: - image: lampepfl/dotty:2018-04-10 + image: lampepfl/dotty:2018-05-23 environment: - RELEASEBUILD=yes commands: @@ -102,7 +102,7 @@ pipeline: event: tag publish_sbt_release: - image: lampepfl/dotty:2018-04-10 + image: lampepfl/dotty:2018-05-23 environment: - RELEASEBUILD=yes commands: diff --git a/project/Build.scala b/project/Build.scala index bb502d545ff7..0580317e4d5c 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -33,7 +33,7 @@ object ExposedValues extends AutoPlugin { object Build { val baseVersion = "0.9.0" - val scalacVersion = "2.12.4" + val scalacVersion = "2.12.6" val dottyOrganization = "ch.epfl.lamp" val dottyGithubUrl = "https://github.com/lampepfl/dotty" @@ -866,7 +866,7 @@ object Build { settings(commonSettings). settings( version := { - val base = "0.2.2" + val base = "0.2.3" if (isRelease) base else base + "-SNAPSHOT" }, diff --git a/project/build.properties b/project/build.properties index 64cf32f7f961..7c817378178a 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.1.4 +sbt.version=1.1.5 diff --git a/sbt-dotty/sbt-test/sbt-dotty/compiler-plugin/src/main/scala/hello/Hello.scala b/sbt-dotty/sbt-test/sbt-dotty/compiler-plugin/app/src/main/scala/hello/Hello.scala similarity index 99% rename from sbt-dotty/sbt-test/sbt-dotty/compiler-plugin/src/main/scala/hello/Hello.scala rename to sbt-dotty/sbt-test/sbt-dotty/compiler-plugin/app/src/main/scala/hello/Hello.scala index 99ae2d0d76a5..d92d9bb84f4d 100644 --- a/sbt-dotty/sbt-test/sbt-dotty/compiler-plugin/src/main/scala/hello/Hello.scala +++ b/sbt-dotty/sbt-test/sbt-dotty/compiler-plugin/app/src/main/scala/hello/Hello.scala @@ -1,4 +1,5 @@ package hello + object Hello { def main(args: Array[String]): Unit = { val dotty: Int | String = "dotty" diff --git a/sbt-dotty/sbt-test/sbt-dotty/compiler-plugin/build.sbt b/sbt-dotty/sbt-test/sbt-dotty/compiler-plugin/build.sbt index 2d1fb1464776..507bd86a4fda 100644 --- a/sbt-dotty/sbt-test/sbt-dotty/compiler-plugin/build.sbt +++ b/sbt-dotty/sbt-test/sbt-dotty/compiler-plugin/build.sbt @@ -1,19 +1,24 @@ lazy val dottyVersion = sys.props("plugin.scalaVersion") -lazy val pluginSetting = Seq( - name := "dividezero", - version := "0.0.1", - organization := "ch.epfl.lamp", - scalaVersion := dottyVersion, +lazy val plugin = project + .in(file("plugin")) + .settings( + name := "dividezero", + version := "0.0.1", + organization := "ch.epfl.lamp", + scalaVersion := dottyVersion, - libraryDependencies ++= Seq( - "ch.epfl.lamp" %% "dotty" % scalaVersion.value % "provided" - ) -) + scalacOptions ++= Seq( + "-language:implicitConversions" + ), -lazy val plugin = (project in file("plugin")).settings(pluginSetting: _*) + libraryDependencies ++= Seq( + "ch.epfl.lamp" %% "dotty-compiler" % scalaVersion.value % "provided" + ) + ) -lazy val app = (project in file(".")).settings( - scalaVersion := dottyVersion, - libraryDependencies += compilerPlugin("ch.epfl.lamp" %% "dividezero" % "0.0.1") -) +lazy val app = project + .in(file("app")) + .settings( + scalaVersion := dottyVersion + ) diff --git a/sbt-dotty/sbt-test/sbt-dotty/compiler-plugin/changes/build.sbt b/sbt-dotty/sbt-test/sbt-dotty/compiler-plugin/changes/build.sbt new file mode 100644 index 000000000000..7b0ee8ccf6f8 --- /dev/null +++ b/sbt-dotty/sbt-test/sbt-dotty/compiler-plugin/changes/build.sbt @@ -0,0 +1,21 @@ +lazy val dottyVersion = sys.props("plugin.scalaVersion") + +lazy val plugin = project + .in(file("plugin")) + .settings( + name := "dividezero", + version := "0.0.1", + organization := "ch.epfl.lamp", + scalaVersion := dottyVersion, + + libraryDependencies ++= Seq( + "ch.epfl.lamp" %% "dotty" % scalaVersion.value % "provided" + ) + ) + +lazy val app = project + .in(file("app")) + .settings( + scalaVersion := dottyVersion, + addCompilerPlugin("ch.epfl.lamp" %% "dividezero" % "0.0.1") + ) diff --git a/sbt-dotty/sbt-test/sbt-dotty/compiler-plugin/pending b/sbt-dotty/sbt-test/sbt-dotty/compiler-plugin/pending deleted file mode 100644 index 6d7fb06f66f3..000000000000 --- a/sbt-dotty/sbt-test/sbt-dotty/compiler-plugin/pending +++ /dev/null @@ -1,5 +0,0 @@ -> plugin/publishLocal -> run -> 'set initialCommands := "1 + 1" ' -# FIXME: does not work on the CI -#> console diff --git a/sbt-dotty/sbt-test/sbt-dotty/compiler-plugin/plugin/DivideZero.scala b/sbt-dotty/sbt-test/sbt-dotty/compiler-plugin/plugin/DivideZero.scala index 1dfe23cf5152..5942d236a079 100644 --- a/sbt-dotty/sbt-test/sbt-dotty/compiler-plugin/plugin/DivideZero.scala +++ b/sbt-dotty/sbt-test/sbt-dotty/compiler-plugin/plugin/DivideZero.scala @@ -12,14 +12,15 @@ import Symbols.Symbol import Constants.Constant import transform.{LinkAll, Pickler} +/** Compiler plugin that emits an error when compiling a division by zero */ class DivideZero extends PluginPhase with StandardPlugin { val name: String = "divideZero" override val description: String = "divide zero check" val phaseName = name - override val runsAfter = Set(Pickler.phaseName) - override val runsBefore = Set(LinkAll.phaseName) + override val runsAfter = Set(Pickler.name) + override val runsBefore = Set(LinkAll.name) override def init(options: List[String]): List[PluginPhase] = this :: Nil @@ -32,9 +33,9 @@ class DivideZero extends PluginPhase with StandardPlugin { override def transformApply(tree: tpd.Apply)(implicit ctx: Context): tpd.Tree = tree match { case tpd.Apply(fun, tpd.Literal(Constants.Constant(v)) :: Nil) if isNumericDivide(fun.symbol) && v == 0 => - ctx.warning("divide by zero", tree.pos) + ctx.error("divide by zero", tree.pos) tpd.Literal(Constant(0)) case _ => tree } -} +} \ No newline at end of file diff --git a/sbt-dotty/sbt-test/sbt-dotty/compiler-plugin/plugin/src/main/resources/plugin.properties b/sbt-dotty/sbt-test/sbt-dotty/compiler-plugin/plugin/src/main/resources/plugin.properties index db215842cecc..f903a0f32451 100644 --- a/sbt-dotty/sbt-test/sbt-dotty/compiler-plugin/plugin/src/main/resources/plugin.properties +++ b/sbt-dotty/sbt-test/sbt-dotty/compiler-plugin/plugin/src/main/resources/plugin.properties @@ -1 +1 @@ -pluginClass=dividezero.DivideZero \ No newline at end of file +pluginClass=dividezero.DivideZero diff --git a/sbt-dotty/sbt-test/sbt-dotty/compiler-plugin/project/build.properties b/sbt-dotty/sbt-test/sbt-dotty/compiler-plugin/project/build.properties deleted file mode 100644 index 133a8f197e36..000000000000 --- a/sbt-dotty/sbt-test/sbt-dotty/compiler-plugin/project/build.properties +++ /dev/null @@ -1 +0,0 @@ -sbt.version=0.13.17 diff --git a/sbt-dotty/sbt-test/sbt-dotty/compiler-plugin/test b/sbt-dotty/sbt-test/sbt-dotty/compiler-plugin/test new file mode 100644 index 000000000000..fa26524a6f68 --- /dev/null +++ b/sbt-dotty/sbt-test/sbt-dotty/compiler-plugin/test @@ -0,0 +1,13 @@ +# Should compile OK without the plugin +> app/compile + +# Publish plugin locally +> plugin/publishLocal + +# Enable plugin +$ copy-file changes/build.sbt build.sbt +> reload + +# Should NOT compile with the plugin +> clean +-> app/compile diff --git a/sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala b/sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala index c971e9020582..efd342e656ad 100644 --- a/sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala +++ b/sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala @@ -145,9 +145,9 @@ object DottyPlugin extends AutoPlugin { onLoad in Global := onLoad.in(Global).value.andThen { state => val sbtV = sbtVersion.value sbtFullVersion(sbtV) match { - case Some((1, sbtMinor, sbtPatch)) if sbtMinor > 1 || (sbtMinor == 1 && sbtPatch >= 4) => + case Some((1, sbtMinor, sbtPatch)) if sbtMinor > 1 || (sbtMinor == 1 && sbtPatch >= 5) => case _ => - sys.error(s"The sbt-dotty plugin cannot work with this version of sbt ($sbtV), sbt >= 1.1.4 is required.") + sys.error(s"The sbt-dotty plugin cannot work with this version of sbt ($sbtV), sbt >= 1.1.5 is required.") } state } diff --git a/tests/run/t5880.scala b/tests/run/t5880.scala deleted file mode 100644 index 5608f4fed937..000000000000 --- a/tests/run/t5880.scala +++ /dev/null @@ -1,41 +0,0 @@ - - -import scala.collection.JavaConversions._ - - - -object Test { - - def main(args:Array[String]) = { - val tests = 5000 - val jm: java.util.Map[Int, Int] = scala.collection.mutable.Map((0 until tests) zip (0 until tests).reverse: _*) - val es = jm.entrySet() - val it = es.iterator - - // chi square test - val groups = 10 - val hits = new Array[Int](groups) - def hit(hc: Int): Unit = { - val bucket = math.abs(hc) / (Int.MaxValue / groups) - hits(bucket) += 1 - } - def expected = tests / groups - def Dstat = { - val diffs = for (i <- 0 until groups) yield math.abs(hits(i) - expected) - diffs.sum.toDouble / expected - } - def ChiSquare = { - val diffs = for (i <- 0 until groups) yield (hits(i) - expected) * (hits(i) - expected) - diffs.sum.toDouble / expected - } - - while (it.hasNext) { - val x = it.next() - hit(x.##) - } - // println(hits.toBuffer) - // println(ChiSquare) - assert(ChiSquare < 4.0, ChiSquare + " -> " + hits.mkString(", ")) - } - -} diff --git a/tests/run/view-headoption.check b/tests/run/view-headoption.check index 5c98b54b46cb..10e02753507f 100644 --- a/tests/run/view-headoption.check +++ b/tests/run/view-headoption.check @@ -17,8 +17,6 @@ f3: Some(5) fail success fail -success -fail fail success fail