You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add bridges for overridden methods in lambda indy call
If a SAM trait's abstract method overrides a method in a
supertrait while changing the return type, the generated
invokedynamic instruction needs to pass the types of the
overridden methods to `LambdaMetaFactory` so that bridge
methods can be added to the generated lambda.
SAM `Function` trees now have a synthetic `ClassSymbol`,
into which we enter an overriding concrete method symbol
that represents the runtime LMF-generated implementation
of that function. `erasure` then computes bridge methods
for that class, which are added to the `LMF.metafactory`
call in `jvm`.
Java does this instead by generating a default method in
the subinterface overriding the superinterface's method.
Theoretically, we could generate the bridges in the same
way, but that has the downside that the project with the
interfaces would need recompiled, which might not be the
project that creates the lambdas. Generating bridges the
LMF way means that only the classes affected by this bug
need to be recompiled to get the fix.
Honestly I'm surprised that this hasn't come up already.
Fixesscala/bug#10512.
// impl restriction -- we currently use the boxed apply, so not really useful to allow specialized sam types (https://github.com/scala/scala/pull/4971#issuecomment-198119167)
0 commit comments