diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2015-09-24 12:54:19 +1000 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2015-09-24 12:54:19 +1000 |
commit | 58a5c5a57c1ada086c4e728586537d64dca765ef (patch) | |
tree | 54bf3c3c75a1911f7a570ab16831d71c3fbd4ef4 /test | |
parent | df704ef7389ff6265afc1278783489ee97ee4ce7 (diff) | |
parent | b0b5b09f90b84696695538a42e7b7ff36555c0f9 (diff) | |
download | scala-58a5c5a57c1ada086c4e728586537d64dca765ef.tar.gz scala-58a5c5a57c1ada086c4e728586537d64dca765ef.tar.bz2 scala-58a5c5a57c1ada086c4e728586537d64dca765ef.zip |
Merge pull request #4763 from lrytz/inlineDeserializeLambda
Add $deserializeLambda$ when inlining an indyLambda into a class
Diffstat (limited to 'test')
4 files changed, 23 insertions, 3 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[_, _]]) +} diff --git a/test/junit/scala/tools/nsc/backend/jvm/analysis/NullnessAnalyzerTest.scala b/test/junit/scala/tools/nsc/backend/jvm/analysis/NullnessAnalyzerTest.scala index f78d450db1..a7d1dc168a 100644 --- a/test/junit/scala/tools/nsc/backend/jvm/analysis/NullnessAnalyzerTest.scala +++ b/test/junit/scala/tools/nsc/backend/jvm/analysis/NullnessAnalyzerTest.scala @@ -31,7 +31,7 @@ object NullnessAnalyzerTest extends ClearAfterClass.Clearable { class NullnessAnalyzerTest extends ClearAfterClass { ClearAfterClass.stateToClear = NullnessAnalyzerTest val noOptCompiler = NullnessAnalyzerTest.noOptCompiler - import noOptCompiler.genBCode.bTypes.analyzers._ + import noOptCompiler.genBCode.bTypes.backendUtils._ def newNullnessAnalyzer(methodNode: MethodNode, classInternalName: InternalName = "C") = new AsmAnalyzer(methodNode, classInternalName, new NullnessAnalyzer) diff --git a/test/junit/scala/tools/nsc/backend/jvm/analysis/ProdConsAnalyzerTest.scala b/test/junit/scala/tools/nsc/backend/jvm/analysis/ProdConsAnalyzerTest.scala index 155e0a6017..4835eb3cdf 100644 --- a/test/junit/scala/tools/nsc/backend/jvm/analysis/ProdConsAnalyzerTest.scala +++ b/test/junit/scala/tools/nsc/backend/jvm/analysis/ProdConsAnalyzerTest.scala @@ -26,7 +26,7 @@ object ProdConsAnalyzerTest extends ClearAfterClass.Clearable { class ProdConsAnalyzerTest extends ClearAfterClass { ClearAfterClass.stateToClear = ProdConsAnalyzerTest val noOptCompiler = ProdConsAnalyzerTest.noOptCompiler - import noOptCompiler.genBCode.bTypes.analyzers._ + import noOptCompiler.genBCode.bTypes.backendUtils._ def prodToString(producer: AbstractInsnNode) = producer match { case p: InitialProducer => p.toString diff --git a/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala b/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala index 8429a583b5..1108a37266 100644 --- a/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala +++ b/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala @@ -68,7 +68,7 @@ class InlinerTest extends ClearAfterClass { val compiler = InlinerTest.compiler import compiler.genBCode.bTypes._ - import compiler.genBCode.bTypes.analyzers._ + import compiler.genBCode.bTypes.backendUtils._ def compile(scalaCode: String, javaCode: List[(String, String)] = Nil, allowMessage: StoreReporter#Info => Boolean = _ => false): List[ClassNode] = { InlinerTest.notPerRun.foreach(_.clear()) |