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 {
3333object 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
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 11package hello
2+
23object Hello {
34 def main (args : Array [String ]): Unit = {
45 val dotty : Int | String = " dotty"
Original file line number Diff line number Diff line change 11lazy 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+ )
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
1212import Constants .Constant
1313import transform .{LinkAll , Pickler }
1414
15+ /** Compiler plugin that emits an error when compiling a division by zero */
1516class 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+ }
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
You can’t perform that action at this time.
0 commit comments