Skip to content

Commit 35eeffd

Browse files
committed
SI-8359 Limit change in param order to delamdafy targets
The previous commit described three options for making our lambda targets amenable to use in LambdaMetafactory. It implemented a broad change (Option #1), which changed the parameter order of all lambda-lifted methods. This commit pares things back to only make this change for synthetic methods that hold lambda bodies. This is a more conservative approach for the 2.11.x series.
1 parent 4547e53 commit 35eeffd

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/compiler/scala/tools/nsc/transform/LambdaLift.scala

+4-1
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,10 @@ abstract class LambdaLift extends InfoTransform {
563563
} // class LambdaLifter
564564

565565
private def addFree[A](sym: Symbol, free: List[A], original: List[A]): List[A] = {
566-
val prependFree = !sym.isConstructor
566+
val prependFree = (
567+
!sym.isConstructor // this condition is redundant for now. It will be needed if we remove the second condition in 2.12.x
568+
&& (settings.Ydelambdafy.value == "method" && sym.isDelambdafyTarget) // SI-8359 Makes the lambda body a viable as the target MethodHandle for a call to LambdaMetafactory
569+
)
567570
if (prependFree) free ::: original
568571
else original ::: free
569572
}

src/reflect/scala/reflect/internal/Symbols.scala

+1
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
789789

790790
final def isAnonymousFunction = isSynthetic && (name containsName tpnme.ANON_FUN_NAME)
791791
final def isDelambdafyFunction = isSynthetic && (name containsName tpnme.DELAMBDAFY_LAMBDA_CLASS_NAME)
792+
final def isDelambdafyTarget = isSynthetic && isMethod && (name containsName tpnme.ANON_FUN_NAME)
792793
final def isDefinedInPackage = effectiveOwner.isPackageClass
793794
final def needsFlatClasses = phase.flatClasses && rawowner != NoSymbol && !rawowner.isPackageClass
794795

0 commit comments

Comments
 (0)