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 /src/compiler/scala/tools/nsc/backend/jvm/opt/Inliner.scala | |
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 'src/compiler/scala/tools/nsc/backend/jvm/opt/Inliner.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/jvm/opt/Inliner.scala | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/opt/Inliner.scala b/src/compiler/scala/tools/nsc/backend/jvm/opt/Inliner.scala index a2ee4f8ad4..f88c131e8d 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/opt/Inliner.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/opt/Inliner.scala @@ -299,7 +299,7 @@ class Inliner[BT <: BTypes](val btypes: BT) { // New labels for the cloned instructions val labelsMap = cloneLabels(callee) - val (clonedInstructions, instructionMap) = cloneInstructions(callee, labelsMap) + val (clonedInstructions, instructionMap, hasSerializableClosureInstantiation) = cloneInstructions(callee, labelsMap) val keepLineNumbers = callsiteClass == calleeDeclarationClass if (!keepLineNumbers) { removeLineNumberNodes(clonedInstructions) @@ -431,6 +431,11 @@ class Inliner[BT <: BTypes](val btypes: BT) { callsiteMethod.maxStack = math.max(callsiteMethod.maxStack, math.max(stackHeightAtNullCheck, maxStackOfInlinedCode)) + if (hasSerializableClosureInstantiation && !indyLambdaHosts(callsiteClass.internalName)) { + indyLambdaHosts += callsiteClass.internalName + addLambdaDeserialize(byteCodeRepository.classNode(callsiteClass.internalName).get) + } + callGraph.addIfMissing(callee, calleeDeclarationClass) def mapArgInfo(argInfo: (Int, ArgInfo)): Option[(Int, ArgInfo)] = argInfo match { |