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
LambdaMetaFactory can only properly instantiate Java interfaces
(with one abstract method, of course). A trait always compiles
to an interface, but a subclass that can be instantiated may
require mixing in further members, which LMF cannot do.
(Nested traits, traits with fields,... do not qualify.)
Traits that cannot be instantiated by LMF are still SAM targets,
we simply created anonymous subclasses as before.
Copy file name to clipboardExpand all lines: src/compiler/scala/tools/nsc/transform/UnCurry.scala
+6-15Lines changed: 6 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -79,21 +79,12 @@ abstract class UnCurry extends InfoTransform
79
79
// (TODO: Can't use isInterface, yet, as it hasn't been updated for the new trait encoding)
80
80
valcanUseLambdaMetaFactory= inConstructorFlag ==0&& (fun.attachments.get[SAMFunction] match {
81
81
caseSome(SAMFunction(userDefinedSamTp, sam)) =>
82
-
valtpSym= erasure.javaErasure(userDefinedSamTp).typeSymbol // we only care about what ends up in the bytecode
83
-
(
84
-
// LMF only supports interfaces
85
-
(tpSym.isJavaInterface || tpSym.isTrait)
86
-
// Unless tpSym.isStatic, even if the constructor is zero-argument now, it may acquire arguments in explicit outer or lambdalift.
87
-
// This is an impl restriction to simplify the decision of whether to expand the SAM during uncurry
88
-
// (when we don't yet know whether it will receive an outer pointer in explicit outer or whether lambda lift will add proxies for captures).
89
-
// When we delay sam expansion until after explicit outer & lambda lift, we could decide there whether
90
-
// to expand sam at compile time or use LMF, and this implementation restriction could be lifted.
91
-
&& tpSym.isStatic
92
-
// 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)
93
-
// specialization and LMF are at odds, since LMF implements the single abstract method,
94
-
// but that's the one that specialization leaves generic, whereas we need to implement the specialized one to avoid boxing
// 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)
85
+
// specialization and LMF are at odds, since LMF implements the single abstract method,
86
+
// but that's the one that specialization leaves generic, whereas we need to implement the specialized one to avoid boxing
0 commit comments