@@ -8,40 +8,52 @@ object PartialUnification extends AutoPlugin {
8
8
override def trigger = allRequirements
9
9
10
10
object autoImport {
11
- val partialUnificationModule = settingKey[ModuleID ](" Module to add partial unification to scala 2.10/2.11" )
11
+ val partialUnificationModule = settingKey[ModuleID ](
12
+ " Module to add partial unification to scala 2.10/2.11" )
12
13
}
13
14
14
15
import autoImport ._
15
16
17
+ def reportError (scalaVersion : String ) = {
18
+ sys.error(s " scala version $scalaVersion is not supported by this plugin. " )
19
+ }
20
+
16
21
def pluginOrFlag (scalaVersion : String , pluginModule : ModuleID ): Resolution = {
17
- val pluginDependency = Resolution .Plugin (compilerPlugin(pluginModule cross CrossVersion .full))
22
+ val pluginDependency =
23
+ Resolution .Plugin (compilerPlugin(pluginModule cross CrossVersion .full))
18
24
val flag = Resolution .Flag (" -Ypartial-unification" )
19
25
val VersionNumber ((major +: minor +: patch +: _), tags, _) = scalaVersion
20
26
21
27
(major, minor, patch, tags) match {
22
28
case (2 , 10 , p, _) if p >= 6 => pluginDependency
23
- case (2 , 11 , 8 , _) => pluginDependency
29
+ case (2 , 10 , _, _) => reportError(scalaVersion)
30
+
31
+ case (2 , 11 , 8 , _) => pluginDependency
24
32
case (2 , 11 , p, _) if p >= 9 => flag
33
+ case (2 , 11 , _, _) => reportError(scalaVersion)
34
+
25
35
case (2 , 12 , _, _) => flag
26
- case (2 , 13 , _, milestone +: _) if milestone == " M1" || milestone == " M2" || milestone == " M3" => flag // ignoring the M4 snapshot
36
+
37
+ case (2 , 13 , 0 , milestone +: _)
38
+ if milestone == " M1" || milestone == " M2" || milestone == " M3" =>
39
+ flag // ignoring the M4 snapshot
40
+
27
41
case _ => Resolution .NothingHappens
28
42
}
29
43
}
30
44
31
45
override val projectSettings = Seq (
32
46
partialUnificationModule := " com.milessabin" % " si2712fix-plugin" % " 1.2.0" ,
33
-
34
47
libraryDependencies ++= {
35
48
pluginOrFlag(scalaVersion.value, partialUnificationModule.value) match {
36
49
case Resolution .Plugin (id) => Seq (id)
37
- case _ => Seq .empty
50
+ case _ => Seq .empty
38
51
}
39
52
},
40
-
41
53
scalacOptions ++= {
42
54
pluginOrFlag(scalaVersion.value, partialUnificationModule.value) match {
43
55
case Resolution .Flag (flag) => Seq (flag)
44
- case _ => Seq .empty
56
+ case _ => Seq .empty
45
57
}
46
58
}
47
59
)
0 commit comments