Skip to content

Add support for Scala 2.12.0-M4 #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ env:
script:
- admin/build.sh
scala:
- 2.11.7
- 2.12.0-M3
- 2.11.8
- 2.12.0-M4
jdk:
- oraclejdk8
notifications:
Expand Down
26 changes: 14 additions & 12 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ val disableDocs = sys.props("nodocs") == "true"
lazy val JavaDoc = config("genjavadoc") extend Compile

def jwrite(dir: java.io.File)(name: String, content: String) = {
val f = dir / "scala" / "compat" / "java8" / s"${name}.java"
val f = dir / "scala" / "runtime" / "java8" / s"${name}.java"
IO.write(f, content)
f
}

lazy val commonSettings = Seq(
scalaVersion := "2.11.7",
crossScalaVersions := List("2.11.7", "2.12.0-M3"),
scalaVersion := "2.11.8",
crossScalaVersions := List("2.11.8", "2.12.0-M4"),
organization := "org.scala-lang.modules",
version := "0.6.0-SNAPSHOT"
version := "0.8.0-SNAPSHOT"
)

lazy val fnGen = (project in file("fnGen")).
Expand Down Expand Up @@ -61,14 +61,16 @@ lazy val root = (project in file(".")).
(out ** "*.scala").get
}.taskValue,

sourceGenerators in Compile <+= sourceManaged in Compile map { dir =>
val write = jwrite(dir) _
Seq(write("JFunction", CodeGen.factory)) ++
(0 to 22).map(n => write("JFunction" + n, CodeGen.fN(n))) ++
(0 to 22).map(n => write("JProcedure" + n, CodeGen.pN(n))) ++
CodeGen.specializedF0.map(write.tupled) ++
CodeGen.specializedF1.map(write.tupled) ++
CodeGen.specializedF2.map(write.tupled)
sourceGenerators in Compile <+= (sourceManaged in Compile, scalaVersion) map { (dir, v) =>
if(v.startsWith("2.11.")) {
val write = jwrite(dir) _
Seq(write("JFunction", CodeGen.factory)) ++
(0 to 22).map(n => write("JFunction" + n, CodeGen.fN(n))) ++
(0 to 22).map(n => write("JProcedure" + n, CodeGen.pN(n))) ++
CodeGen.specializedF0.map(write.tupled) ++
CodeGen.specializedF1.map(write.tupled) ++
CodeGen.specializedF2.map(write.tupled)
} else Seq.empty
},

sourceGenerators in Test <+= sourceManaged in Test map { dir =>
Expand Down
2 changes: 1 addition & 1 deletion project/CodeGen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ object Type {
}

object CodeGen {
def packaging = "package scala.compat.java8;"
def packaging = "package scala.runtime.java8;"
case class arity(n: Int) {
val ns = (1 to n).toList

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/scala/compat/java8/SpecializedTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package scala.compat.java8

import org.junit.Test
import scala.compat.java8.SpecializedTestSupport.IntIdentity
import scala.runtime.java8.SpecializedTestSupport.IntIdentity

class SpecializedTest {
@Test def specializationWorks() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2012-2015 Typesafe Inc. <http://www.typesafe.com>
*/
package scala.compat.java8;
package scala.runtime.java8;

import org.junit.Test;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/*
* Copyright (C) 2012-2015 Typesafe Inc. <http://www.typesafe.com>
*/
package scala.compat.java8;
package scala.runtime.java8;

import org.apache.commons.lang3.SerializationUtils;
import scala.runtime.*;

import static junit.framework.Assert.assertEquals;
import static scala.compat.java8.JFunction.*;
import static scala.compat.java8.TestAPI.*;
import static scala.runtime.java8.JFunction.*;
import static scala.runtime.java8.TestAPI.*;

import org.junit.Test;

Expand Down Expand Up @@ -99,20 +99,23 @@ public void lambdaDemo() {
acceptFunction22Unit( proc((v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) -> {v1.toUpperCase(); return;}));
}

/*
// The JFunctions in 2.12.0-M4 are not Serializable anymore
@Test
public void isSerializable() {
scala.compat.java8.JFunction0<String> f0 = () -> "foo";
scala.runtime.java8.JFunction0<String> f0 = () -> "foo";
assertEquals("foo", SerializationUtils.clone(f0).apply());

scala.compat.java8.JFunction1<String, String> f1 = (a) -> a.toUpperCase();
scala.runtime.java8.JFunction1<String, String> f1 = (a) -> a.toUpperCase();
assertEquals("FOO", SerializationUtils.clone(f1).apply("foo"));

scala.compat.java8.JFunction2<String, String, String> f2 = (a, b) -> a + b;
scala.runtime.java8.JFunction2<String, String, String> f2 = (a, b) -> a + b;
assertEquals("foobar", SerializationUtils.clone(f2).apply("foo", "bar"));

scala.compat.java8.JFunction3<String, String, String, String> f3 = (a, b, c) -> a + b + c;
scala.runtime.java8.JFunction3<String, String, String, String> f3 = (a, b, c) -> a + b + c;
assertEquals("foobarbaz", SerializationUtils.clone(f3).apply("foo", "bar", "baz"));
}
*/

private static scala.concurrent.Future<Integer> futureExample(
scala.concurrent.Future<String> future, scala.concurrent.ExecutionContext ec) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2012-2015 Typesafe Inc. <http://www.typesafe.com>
*/
package scala.compat.java8;
package scala.runtime.java8;

import org.junit.Test;
import scala.runtime.BoxedUnit;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2012-2015 Typesafe Inc. <http://www.typesafe.com>
*/
package scala.compat.java8;
package scala.runtime.java8;

import java.util.Arrays;
import java.util.List;
Expand Down