Hi,
I was porting sbt-assembly to sbt 0.13 tonight, and came across something weird.
Not sure if it's my bug, sbt 0.13's bug, or Scala 2.10's bug.
First, the plugin provides a sequence extractor called PathList that splits up file path by the system's
separator:
object PathList {
private val sysFileSep = System.getProperty("file.separator")
def unapplySeq(path: String): Option[Seq[String]] = {
val split = path.split(if (sysFileSep.equals( """\""")) """\\""" else sysFileSep)
if (split.size == 0) None
else Some(split.toList)
}
}
Next, it defines a "merge strategy" based on the path[1]:
mergeStrategy in assembly := {
case "reference.conf" =>
MergeStrategy.concat
case PathList(ps @ _*) if isReadme(ps.last) || isLicenseFile(ps.last) =>
MergeStrategy.rename
case ....
}
The above code compiles fine for sbt 0.12, but on sbt 0.13.0-M1, it errors with the following message:
[error] /work/sbt-assembly/src/main/scala/sbtassembly/Plugin.scala:313: star patterns must correspond with varargs parameters
[error] case PathList(ps @ _*) if isReadme(ps.last) || isLicenseFile(ps.last) =>
[error] ^
[error] one error found
I tried different things, and finally what fixed was moving the entire partial function out of Seq(...)
as a stand-alone function value: [2]
val defaultMergeStrategy: String => MergeStrategy = {
case "reference.conf" =>
MergeStrategy.concat
case PathList(ps @ _*) if isReadme(ps.last) || isLicenseFile(ps.last) =>
MergeStrategy.rename
case ....
}
The code does the same thing. One is named function value, the other is an anonymous case function.
You, me, patmat, macros?
-eugene