diff options
author | Lukas Rytz <lukas.rytz@gmail.com> | 2015-09-23 15:11:01 +0200 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@gmail.com> | 2015-09-23 15:12:29 +0200 |
commit | b0b5b09f90b84696695538a42e7b7ff36555c0f9 (patch) | |
tree | 54bf3c3c75a1911f7a570ab16831d71c3fbd4ef4 /test/files/run | |
parent | f9dbade4dbc3a888f927983c164b83ef5d500af9 (diff) | |
download | scala-b0b5b09f90b84696695538a42e7b7ff36555c0f9.tar.gz scala-b0b5b09f90b84696695538a42e7b7ff36555c0f9.tar.bz2 scala-b0b5b09f90b84696695538a42e7b7ff36555c0f9.zip |
Add $deserializeLambda$ when inlining an indyLambda into a class
Fixes https://github.com/scala/scala-dev/issues/39
When inlining an indyLambda closure instantiation into a class, and
the closure type is serializable, make sure that the target class has
the synthetic `$deserializeLambda$` method.
Diffstat (limited to 'test/files/run')
-rw-r--r-- | test/files/run/inlineAddDeserializeLambda.scala | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/files/run/inlineAddDeserializeLambda.scala b/test/files/run/inlineAddDeserializeLambda.scala new file mode 100644 index 0000000000..a6bafd0f49 --- /dev/null +++ b/test/files/run/inlineAddDeserializeLambda.scala @@ -0,0 +1,20 @@ +class C { @inline final def f: Int => Int = (x: Int) => x + 1 } + +object Test extends App { + import java.io._ + + def serialize(obj: AnyRef): Array[Byte] = { + val buffer = new ByteArrayOutputStream + val out = new ObjectOutputStream(buffer) + out.writeObject(obj) + buffer.toByteArray + } + def deserialize(a: Array[Byte]): AnyRef = { + val in = new ObjectInputStream(new ByteArrayInputStream(a)) + in.readObject + } + + def serializeDeserialize[T <: AnyRef](obj: T) = deserialize(serialize(obj)).asInstanceOf[T] + + assert(serializeDeserialize((new C).f).isInstanceOf[Function1[_, _]]) +} |