Skip to content

Commit df1dfe5

Browse files
authored
Merge pull request #141 from lrytz/newCollections
Compile with 2.13.0-M4
2 parents 51b93a3 + 4bfdfde commit df1dfe5

File tree

8 files changed

+49
-26
lines changed

8 files changed

+49
-26
lines changed

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ env:
3131
- SCALA_VERSION=2.12.4
3232
- SCALA_VERSION=2.12.5
3333
- SCALA_VERSION=2.12.6
34-
- SCALA_VERSION=2.13.0-M3
34+
- SCALA_VERSION=2.13.0-M4
3535

3636
# there's no better way it seems.. https://github.com/travis-ci/travis-ci/issues/1519
3737
matrix:
@@ -52,7 +52,7 @@ matrix:
5252
- jdk: openjdk6
5353
env: SCALA_VERSION=2.12.6
5454
- jdk: openjdk6
55-
env: SCALA_VERSION=2.13.0-M3
55+
env: SCALA_VERSION=2.13.0-M4
5656

5757
# Increasing ReservedCodeCacheSize minimizes scala compiler-interface compile times
5858
script:

build.sbt

+14-8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
val scalaMajorVersion = SettingKey[Int]("scalaMajorVersion")
2+
13
// so we can set this from automated builds and also depending on Scala version
24
lazy val scalaTestVersion = settingKey[String]("The version of ScalaTest to use.")
35

@@ -26,7 +28,7 @@ lazy val `genjavadoc-plugin` = (project in file("plugin"))
2628
IO.write(result, (fullClasspath in Test).value.map(_.data.getAbsolutePath).mkString("\n"))
2729
result
2830
},
29-
(test in Test) := {
31+
test in Test := {
3032
// since we are building for different Scala patch versions, a clean
3133
// is required to avoid conflicts in class files
3234
clean.value
@@ -38,12 +40,15 @@ lazy val `genjavadoc-plugin` = (project in file("plugin"))
3840
val default = (unmanagedSourceDirectories in Compile).value
3941
def r(from: String, to: String) = default.map(f => new java.io.File(f.getPath.replaceAll(from, to)))
4042
if (scalaVersion.value == "2.12.0") r("""/scala-2\.12$""", "/scala-2.11")
41-
else if (scalaVersion.value.startsWith("2.13.")) r("""/scala-2\.13[^/]*$""", "/scala-2.12")
43+
else if (scalaMajorVersion.value == 13) r("""/scala-2\.13[^/]*$""", "/scala-2.12")
4244
else default
4345
},
4446
crossVersion := CrossVersion.full,
4547
exportJars := true,
46-
scalacOptions ++= Seq("-deprecation", "-feature", "-unchecked", "-Xlint", "-Xfatal-warnings")
48+
scalacOptions ++=
49+
Seq("-deprecation", "-feature", "-unchecked", "-Xlint") ++ (
50+
if (scalaMajorVersion.value == 13) Seq() // deprecation warnings due to SortedSet.from/to
51+
else Seq("-Xfatal-warnings"))
4752
)
4853

4954
lazy val defaults = Seq(
@@ -53,7 +58,7 @@ lazy val defaults = Seq(
5358
val earliest211 = 6
5459
val latest211 = 12
5560
val latest212 = 6
56-
val pre213 = List("M3")
61+
val pre213 = List("M4")
5762
val skipVersions = Set("2.11.9", "2.11.10")
5863
val scala211Versions =
5964
(earliest211 to latest211)
@@ -65,11 +70,12 @@ lazy val defaults = Seq(
6570
scala211Versions ++ (0 to latest212).map(i => s"2.12.$i") ++ pre213.map(s => s"2.13.0-$s")
6671
}
6772
},
73+
scalaMajorVersion := CrossVersion.partialVersion(scalaVersion.value).get._2.toInt,
6874
scalaTestVersion := {
69-
CrossVersion.partialVersion(scalaVersion.value) match {
70-
case Some((2, 13)) => "3.0.5-M1" // only version available for 2.13.0-M3
71-
case Some((2, 12)) => "3.0.4"
72-
case _ => "2.1.3"
75+
scalaMajorVersion.value match {
76+
case 13 => "3.0.6-SNAP1" // the version available for 2.13.0-M4
77+
case 12 => "3.0.4"
78+
case _ => "2.1.3"
7379
}
7480
},
7581
resolvers += Resolver.mavenLocal,

plugin/src/main/scala/com/typesafe/genjavadoc/BaseComments.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ trait BaseComments { this: TransformCake ⇒
3636
s"$prefix$link"
3737
case x x
3838
}
39-
.map(line (line /: replacements) { case (l, (from, to)) l.replace(from, to) })
40-
val (_, _, _, l2) = ((false, false, true, List.empty[String]) /: ll) {
39+
.map(line replacements.foldLeft(line) { case (l, (from, to)) l.replace(from, to) })
40+
val (_, _, _, l2) = ll.foldLeft((false, false, true, List.empty[String])) {
4141
// insert <p> line upon transition to empty, collapse contiguous empty lines
4242
case ((pre, code, empty, lines), line @ EmptyLine())
4343
val nl =

plugin/src/main/scala/com/typesafe/genjavadoc/BasicTransform.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,11 @@ trait BasicTransform { this: TransformCake ⇒
147147
ret
148148
}
149149

150-
private def addMethod(d: DefDef, comment: Seq[String]) {
150+
private def addMethod(d: DefDef, comment: Seq[String]): Unit = {
151151
clazz = clazz map (c c.addMember(MethodInfo(d, c.interface, comment, hasVararg = false, deprecation = deprecationInfo(d))))
152152
}
153153

154-
private def addVarargsMethod(d: DefDef, comment: Seq[String]) {
154+
private def addVarargsMethod(d: DefDef, comment: Seq[String]): Unit = {
155155
clazz = clazz map (c c.addMember(MethodInfo(d, c.interface, comment, hasVararg = true, deprecation = deprecationInfo(d))))
156156
}
157157

plugin/src/main/scala/com/typesafe/genjavadoc/JavaSig.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ trait JavaSig { this: TransformCake ⇒
178178
}
179179

180180
private object NeedsSigCollector extends TypeCollector(false) {
181-
def traverse(tp: Type) {
181+
def traverse(tp: Type): Unit = {
182182
if (!result) {
183183
tp match {
184184
case st: SubType

plugin/src/main/scala/com/typesafe/genjavadoc/Output.scala

+9-9
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ trait Output { this: TransformCake ⇒
99

1010
def outputBase: File
1111

12-
def write(out: Out, c: ClassInfo) {
12+
def write(out: Out, c: ClassInfo): Unit = {
1313
// TODO @param should be transformed to constructor comments
1414
c.comment foreach {line =>
1515
val replaced = line.replace("@param", "param: ") match {
@@ -30,7 +30,7 @@ trait Output { this: TransformCake ⇒
3030
out("}")
3131
}
3232

33-
def write(out: Out, m: MethodInfo) {
33+
def write(out: Out, m: MethodInfo): Unit = {
3434
m.comment foreach (out(_))
3535
out(m.sig)
3636
}
@@ -39,9 +39,9 @@ trait Output { this: TransformCake ⇒
3939
var ind = 0
4040

4141
def println(s: String): Unit
42-
def apply(s: String) { println(" " * ind + s) }
43-
def indent() { ind += 2 }
44-
def outdent() { ind -= 2 }
42+
def apply(s: String): Unit = { println(" " * ind + s) }
43+
def indent(): Unit = { ind += 2 }
44+
def outdent(): Unit = { ind -= 2 }
4545
def close(): Unit
4646
}
4747

@@ -50,8 +50,8 @@ trait Output { this: TransformCake ⇒
5050
f.getParentFile.mkdirs
5151
val w = new PrintStream(f, "UTF-8")
5252
new Out {
53-
def println(s: String) { w.println(s) }
54-
def close() { w.close() }
53+
def println(s: String): Unit = { w.println(s) }
54+
def close(): Unit = { w.close() }
5555
}
5656
}
5757

@@ -107,7 +107,7 @@ trait Output { this: TransformCake ⇒
107107

108108
// goes from object to companion class (not the other way around)
109109
private def fabricateCompanion(obj: ClassInfo): ClassInfo = {
110-
val com = (obj.comment /: obj.members)((c, mem) mem match {
110+
val com = obj.members.foldLeft(obj.comment)((c, mem) mem match {
111111
case x: MethodInfo if x.name == obj.name c ++ x.comment
112112
case _ c
113113
})
@@ -134,7 +134,7 @@ trait Output { this: TransformCake ⇒
134134
else flatten(obj.classMembers) ++ obj.methodMembers
135135
)
136136

137-
val (com: Seq[String], moduleMembers: Vector[Templ]) = ((obj.comment, Vector.empty[Templ]) /: members)((p, mem) mem match {
137+
val (com: Seq[String], moduleMembers: Vector[Templ]) = members.foldLeft((obj.comment, Vector.empty[Templ]))((p, mem) mem match {
138138
case x: MethodInfo if x.name == obj.name (p._1 ++ x.comment, p._2 :+ x.copy(name = x.name + '$', comment = Seq()))
139139
case x (p._1, p._2 :+ x)
140140
})

plugin/src/test/resources/patches/2.13.0.patch

+18-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@
1515
}
1616
/**
1717
* class A.B
18+
@@ -76,7 +76,7 @@
19+
* def b(args: java.lang.String*): Unit
20+
* @param args (undocumented)
21+
*/
22+
- public void b (scala.collection.Seq<java.lang.String> args) { throw new RuntimeException(); }
23+
+ public void b (scala.collection.immutable.Seq<java.lang.String> args) { throw new RuntimeException(); }
24+
public java.lang.String d (java.lang.String a, akka.rk.buh.is.it.X b) { throw new RuntimeException(); }
25+
}
26+
public class C implements akka.rk.buh.is.it.X {
1827
@@ -94,12 +94,12 @@
1928
public class C1$ {
2029
public C1$ () { throw new RuntimeException(); }
@@ -41,7 +50,15 @@
4150
* varargs
4251
* @param s (undocumented)
4352
* @return (undocumented)
44-
@@ -219,9 +224,4 @@
53+
@@ -212,16 +217,11 @@
54+
* @param s (undocumented)
55+
* @return (undocumented)
56+
*/
57+
- public int hello (scala.collection.Seq<java.lang.String> s) { throw new RuntimeException(); }
58+
+ public int hello (scala.collection.immutable.Seq<java.lang.String> s) { throw new RuntimeException(); }
59+
/**
60+
* throws
61+
* @return (undocumented)
4562
*/
4663
public int testthrows () throws java.lang.IllegalArgumentException, java.lang.NullPointerException { throw new RuntimeException(); }
4764
public scala.runtime.Null$ getNull () { throw new RuntimeException(); }

plugin/src/test/scala/com/typesafe/genjavadoc/SignatureSpec.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class SignatureSpec extends WordSpec with Matchers {
8484
val exception = "(akka.rk.buh.is.it.A\\$[C1D]+\\$)\\$"
8585
val replacemnt = "$1"
8686

87-
def check(jn: String) {
87+
def check(jn: String): Unit = {
8888
val jc: Class[_] = javaCL.loadClass(jn)
8989
val sc: Class[_] = scalaCL.loadClass(jn.replaceAll(exception, replacemnt))
9090

0 commit comments

Comments
 (0)