summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/transform/Delambdafy.scala
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@typesafe.com>2016-07-22 08:59:49 +0200
committerGitHub <noreply@github.com>2016-07-22 08:59:49 +0200
commit8d87b62f6c68ede3402371fea74e989b924c81b8 (patch)
tree117134e60d869a5bdb9e47135613c6f948ff65bc /src/compiler/scala/tools/nsc/transform/Delambdafy.scala
parent49a4750eec0cc92edd472a7539003bd00c16d468 (diff)
parent3e64fdda48b8f2506756fc458f01f2e549d71720 (diff)
downloadscala-8d87b62f6c68ede3402371fea74e989b924c81b8.tar.gz
scala-8d87b62f6c68ede3402371fea74e989b924c81b8.tar.bz2
scala-8d87b62f6c68ede3402371fea74e989b924c81b8.zip
Merge pull request #5278 from retronym/ticket/SD-120
SD-120 Non FunctionN lambdas should not be universally serializable
Diffstat (limited to 'src/compiler/scala/tools/nsc/transform/Delambdafy.scala')
-rw-r--r--src/compiler/scala/tools/nsc/transform/Delambdafy.scala6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/Delambdafy.scala b/src/compiler/scala/tools/nsc/transform/Delambdafy.scala
index 88837842fa..855e53710b 100644
--- a/src/compiler/scala/tools/nsc/transform/Delambdafy.scala
+++ b/src/compiler/scala/tools/nsc/transform/Delambdafy.scala
@@ -28,7 +28,7 @@ abstract class Delambdafy extends Transform with TypingTransformers with ast.Tre
/** the following two members override abstract members in Transform */
val phaseName: String = "delambdafy"
- final case class LambdaMetaFactoryCapable(target: Symbol, arity: Int, functionalInterface: Symbol, sam: Symbol)
+ final case class LambdaMetaFactoryCapable(target: Symbol, arity: Int, functionalInterface: Symbol, sam: Symbol, isSerializable: Boolean, addScalaSerializableMarker: Boolean)
/**
* Get the symbol of the target lifted lambda body method from a function. I.e. if
@@ -95,6 +95,8 @@ abstract class Delambdafy extends Transform with TypingTransformers with ast.Tre
// no need for adaptation when the implemented sam is of a specialized built-in function type
val lambdaTarget = if (isSpecialized) target else createBoxingBridgeMethodIfNeeded(fun, target, functionalInterface, sam)
+ val isSerializable = samUserDefined == NoSymbol || samUserDefined.owner.isNonBottomSubClass(definitions.JavaSerializableClass)
+ val addScalaSerializableMarker = samUserDefined == NoSymbol
// The backend needs to know the target of the lambda and the functional interface in order
// to emit the invokedynamic instruction. We pass this information as tree attachment.
@@ -102,7 +104,7 @@ abstract class Delambdafy extends Transform with TypingTransformers with ast.Tre
// see https://docs.oracle.com/javase/8/docs/api/java/lang/invoke/LambdaMetafactory.html
// instantiatedMethodType is derived from lambdaTarget's signature
// samMethodType is derived from samOf(functionalInterface)'s signature
- apply.updateAttachment(LambdaMetaFactoryCapable(lambdaTarget, fun.vparams.length, functionalInterface, sam))
+ apply.updateAttachment(LambdaMetaFactoryCapable(lambdaTarget, fun.vparams.length, functionalInterface, sam, isSerializable, addScalaSerializableMarker))
apply
}