SD-120 Non FunctionN lambdas should not be universally serializable#5278
SD-120 Non FunctionN lambdas should not be universally serializable#5278lrytz merged 1 commit intoscala:2.12.xfrom
Conversation
| val bridgeCount = 0 | ||
| import java.lang.invoke.LambdaMetafactory.{FLAG_MARKERS, FLAG_SERIALIZABLE} | ||
| def flagIf(b: Boolean, flag: Int): Int = if (b) flag else 0 | ||
| val flags = flagIf(markerInterfaces.isEmpty, FLAG_MARKERS) | flagIf(serializable, FLAG_SERIALIZABLE) |
There was a problem hiding this comment.
Weird, now I don't trust my test 😦
There was a problem hiding this comment.
Oh, we can just always provide that flag, even if we have marker count of 0.
583c474 to
551beaf
Compare
Instead, we follow the example set by javac, and predicate serializability of bot anon-class and invokedynamic-based lambdas on whether or not the SAM type extends java.io.Serializable. Fixes scala/scala-dev#120
|
@lrytz review comments addressed and rebased. |
|
LGTM |
|
Actually, I'm wondering now: for SAM types that extend Comparing that to Java, when does javac set the |
|
That's what I mean to do, I'll double check and submit a follow up PR to
|
|
We do set the |
|
|
ok, thanks. i double-checked again, i confused the meanings of the |
Infrastructure taken from scala/scala#5278
Test infrastructure taken from scala/scala#5278
Instead, we follow the example set by javac, and predicate serializability
of bot anon-class and invokedynamic-based lambdas on whether or not the
SAM type extends java.io.Serializable.
Fixes scala/scala-dev#120