File tree Expand file tree Collapse file tree 11 files changed +65
-30
lines changed
sbt-test/sbt-dotty/compiler-plugin
src/dotty/tools/sbtplugin Expand file tree Collapse file tree 11 files changed +65
-30
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ object ExposedValues extends AutoPlugin {
33
33
object Build {
34
34
35
35
val baseVersion = " 0.9.0"
36
- val scalacVersion = " 2.12.4 "
36
+ val scalacVersion = " 2.12.6 "
37
37
38
38
val dottyOrganization = " ch.epfl.lamp"
39
39
val dottyGithubUrl = " https://github.com/lampepfl/dotty"
@@ -866,7 +866,7 @@ object Build {
866
866
settings(commonSettings).
867
867
settings(
868
868
version := {
869
- val base = " 0.2.2 "
869
+ val base = " 0.2.3 "
870
870
if (isRelease) base else base + " -SNAPSHOT"
871
871
},
872
872
Original file line number Diff line number Diff line change 1
- sbt.version =1.1.4
1
+ sbt.version =1.1.5
Original file line number Diff line number Diff line change 1
1
package hello
2
+
2
3
object Hello {
3
4
def main (args : Array [String ]): Unit = {
4
5
val dotty : Int | String = " dotty"
Original file line number Diff line number Diff line change 1
1
lazy val dottyVersion = sys.props(" plugin.scalaVersion" )
2
2
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,
8
10
9
- libraryDependencies ++= Seq (
10
- " ch.epfl.lamp" %% " dotty" % scalaVersion.value % " provided"
11
- )
12
- )
11
+ scalacOptions ++= Seq (
12
+ " -language:implicitConversions"
13
+ ),
13
14
14
- lazy val plugin = (project in file(" plugin" )).settings(pluginSetting : _* )
15
+ libraryDependencies ++= Seq (
16
+ " ch.epfl.lamp" %% " dotty-compiler" % scalaVersion.value % " provided"
17
+ )
18
+ )
15
19
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
+ )
Original file line number Diff line number Diff line change
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
+ )
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -12,14 +12,15 @@ import Symbols.Symbol
12
12
import Constants .Constant
13
13
import transform .{LinkAll , Pickler }
14
14
15
+ /** Compiler plugin that emits an error when compiling a division by zero */
15
16
class DivideZero extends PluginPhase with StandardPlugin {
16
17
val name : String = " divideZero"
17
18
override val description : String = " divide zero check"
18
19
19
20
val phaseName = name
20
21
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 )
23
24
24
25
override def init (options : List [String ]): List [PluginPhase ] = this :: Nil
25
26
@@ -32,9 +33,9 @@ class DivideZero extends PluginPhase with StandardPlugin {
32
33
33
34
override def transformApply (tree : tpd.Apply )(implicit ctx : Context ): tpd.Tree = tree match {
34
35
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)
36
37
tpd.Literal (Constant (0 ))
37
38
case _ =>
38
39
tree
39
40
}
40
- }
41
+ }
Original file line number Diff line number Diff line change 1
- pluginClass =dividezero.DivideZero
1
+ pluginClass =dividezero.DivideZero
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change @@ -145,9 +145,9 @@ object DottyPlugin extends AutoPlugin {
145
145
onLoad in Global := onLoad.in(Global ).value.andThen { state =>
146
146
val sbtV = sbtVersion.value
147
147
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 ) =>
149
149
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. " )
151
151
}
152
152
state
153
153
}
You can’t perform that action at this time.
0 commit comments