Skip to content

Commit 825c149

Browse files
committed
Upgrade to sbt 1.1.5 and scala 2.12.6
We can now enable the compiler plugin test
1 parent 91de029 commit 825c149

File tree

11 files changed

+65
-30
lines changed

11 files changed

+65
-30
lines changed

project/Build.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ object ExposedValues extends AutoPlugin {
3333
object Build {
3434

3535
val baseVersion = "0.9.0"
36-
val scalacVersion = "2.12.4"
36+
val scalacVersion = "2.12.6"
3737

3838
val dottyOrganization = "ch.epfl.lamp"
3939
val dottyGithubUrl = "https://github.com/lampepfl/dotty"
@@ -866,7 +866,7 @@ object Build {
866866
settings(commonSettings).
867867
settings(
868868
version := {
869-
val base = "0.2.2"
869+
val base = "0.2.3"
870870
if (isRelease) base else base + "-SNAPSHOT"
871871
},
872872

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.1.4
1+
sbt.version=1.1.5

sbt-dotty/sbt-test/sbt-dotty/compiler-plugin/src/main/scala/hello/Hello.scala renamed to sbt-dotty/sbt-test/sbt-dotty/compiler-plugin/app/src/main/scala/hello/Hello.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
package hello
2+
23
object Hello {
34
def main(args: Array[String]): Unit = {
45
val dotty: Int | String = "dotty"
Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
lazy val dottyVersion = sys.props("plugin.scalaVersion")
22

3-
lazy val pluginSetting = Seq(
4-
name := "dividezero",
5-
version := "0.0.1",
6-
organization := "ch.epfl.lamp",
7-
scalaVersion := dottyVersion,
3+
lazy val plugin = project
4+
.in(file("plugin"))
5+
.settings(
6+
name := "dividezero",
7+
version := "0.0.1",
8+
organization := "ch.epfl.lamp",
9+
scalaVersion := dottyVersion,
810

9-
libraryDependencies ++= Seq(
10-
"ch.epfl.lamp" %% "dotty" % scalaVersion.value % "provided"
11-
)
12-
)
11+
scalacOptions ++= Seq(
12+
"-language:implicitConversions"
13+
),
1314

14-
lazy val plugin = (project in file("plugin")).settings(pluginSetting: _*)
15+
libraryDependencies ++= Seq(
16+
"ch.epfl.lamp" %% "dotty-compiler" % scalaVersion.value % "provided"
17+
)
18+
)
1519

16-
lazy val app = (project in file(".")).settings(
17-
scalaVersion := dottyVersion,
18-
libraryDependencies += compilerPlugin("ch.epfl.lamp" %% "dividezero" % "0.0.1")
19-
)
20+
lazy val app = project
21+
.in(file("app"))
22+
.settings(
23+
scalaVersion := dottyVersion
24+
)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
lazy val dottyVersion = sys.props("plugin.scalaVersion")
2+
3+
lazy val plugin = project
4+
.in(file("plugin"))
5+
.settings(
6+
name := "dividezero",
7+
version := "0.0.1",
8+
organization := "ch.epfl.lamp",
9+
scalaVersion := dottyVersion,
10+
11+
libraryDependencies ++= Seq(
12+
"ch.epfl.lamp" %% "dotty" % scalaVersion.value % "provided"
13+
)
14+
)
15+
16+
lazy val app = project
17+
.in(file("app"))
18+
.settings(
19+
scalaVersion := dottyVersion,
20+
addCompilerPlugin("ch.epfl.lamp" %% "dividezero" % "0.0.1")
21+
)

sbt-dotty/sbt-test/sbt-dotty/compiler-plugin/pending

Lines changed: 0 additions & 5 deletions
This file was deleted.

sbt-dotty/sbt-test/sbt-dotty/compiler-plugin/plugin/DivideZero.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ import Symbols.Symbol
1212
import Constants.Constant
1313
import transform.{LinkAll, Pickler}
1414

15+
/** Compiler plugin that emits an error when compiling a division by zero */
1516
class DivideZero extends PluginPhase with StandardPlugin {
1617
val name: String = "divideZero"
1718
override val description: String = "divide zero check"
1819

1920
val phaseName = name
2021

21-
override val runsAfter = Set(Pickler.phaseName)
22-
override val runsBefore = Set(LinkAll.phaseName)
22+
override val runsAfter = Set(Pickler.name)
23+
override val runsBefore = Set(LinkAll.name)
2324

2425
override def init(options: List[String]): List[PluginPhase] = this :: Nil
2526

@@ -32,9 +33,9 @@ class DivideZero extends PluginPhase with StandardPlugin {
3233

3334
override def transformApply(tree: tpd.Apply)(implicit ctx: Context): tpd.Tree = tree match {
3435
case tpd.Apply(fun, tpd.Literal(Constants.Constant(v)) :: Nil) if isNumericDivide(fun.symbol) && v == 0 =>
35-
ctx.warning("divide by zero", tree.pos)
36+
ctx.error("divide by zero", tree.pos)
3637
tpd.Literal(Constant(0))
3738
case _ =>
3839
tree
3940
}
40-
}
41+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pluginClass=dividezero.DivideZero
1+
pluginClass=dividezero.DivideZero

sbt-dotty/sbt-test/sbt-dotty/compiler-plugin/project/build.properties

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Should compile OK without the plugin
2+
> app/compile
3+
4+
# Publish plugin locally
5+
> plugin/publishLocal
6+
7+
# Enable plugin
8+
$ copy-file changes/build.sbt build.sbt
9+
> reload
10+
11+
# Should NOT compile with the plugin
12+
> clean
13+
-> app/compile

sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,9 @@ object DottyPlugin extends AutoPlugin {
145145
onLoad in Global := onLoad.in(Global).value.andThen { state =>
146146
val sbtV = sbtVersion.value
147147
sbtFullVersion(sbtV) match {
148-
case Some((1, sbtMinor, sbtPatch)) if sbtMinor > 1 || (sbtMinor == 1 && sbtPatch >= 4) =>
148+
case Some((1, sbtMinor, sbtPatch)) if sbtMinor > 1 || (sbtMinor == 1 && sbtPatch >= 5) =>
149149
case _ =>
150-
sys.error(s"The sbt-dotty plugin cannot work with this version of sbt ($sbtV), sbt >= 1.1.4 is required.")
150+
sys.error(s"The sbt-dotty plugin cannot work with this version of sbt ($sbtV), sbt >= 1.1.5 is required.")
151151
}
152152
state
153153
}

0 commit comments

Comments
 (0)