summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/transform/UnCurry.scala
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2015-04-13 20:28:24 -0700
committerAdriaan Moors <adriaan.moors@typesafe.com>2015-04-13 20:28:24 -0700
commit029cce77bd72cd8255c6dee08a227796cdb158b1 (patch)
tree262d72adf01ad011d11dd7967bc5e3ed6b28a981 /src/compiler/scala/tools/nsc/transform/UnCurry.scala
parent8623c2be74f8de0c400dcc04eb6f83168c6272c0 (diff)
parentea61b3f66007b1a0029a5f22a7de334924390f7c (diff)
downloadscala-029cce77bd72cd8255c6dee08a227796cdb158b1.tar.gz
scala-029cce77bd72cd8255c6dee08a227796cdb158b1.tar.bz2
scala-029cce77bd72cd8255c6dee08a227796cdb158b1.zip
Merge pull request #4367 from retronym/topic/indylambda-specialization
Disable -Ydelambdafy:method for specialized FunctionN
Diffstat (limited to 'src/compiler/scala/tools/nsc/transform/UnCurry.scala')
-rw-r--r--src/compiler/scala/tools/nsc/transform/UnCurry.scala18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
index 3330fbcae2..6484d96a52 100644
--- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala
+++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
@@ -71,6 +71,14 @@ abstract class UnCurry extends InfoTransform
private val noApply = mutable.HashSet[Tree]()
private val newMembers = mutable.Map[Symbol, mutable.Buffer[Tree]]()
+ private lazy val forceSpecializationInfoTransformOfFunctionN: Unit = {
+ if (currentRun.specializePhase != NoPhase) { // be robust in case of -Ystop-after:uncurry
+ exitingSpecialize {
+ FunctionClass.seq.foreach(cls => cls.info)
+ }
+ }
+ }
+
/** Add a new synthetic member for `currentOwner` */
private def addNewMember(t: Tree): Unit =
newMembers.getOrElseUpdate(currentOwner, mutable.Buffer()) += t
@@ -221,8 +229,16 @@ abstract class UnCurry extends InfoTransform
def mkMethod(owner: Symbol, name: TermName, additionalFlags: FlagSet = NoFlags): DefDef =
gen.mkMethodFromFunction(localTyper)(fun, owner, name, additionalFlags)
- val canUseDelamdafyMethod = (inConstructorFlag == 0) // Avoiding synthesizing code prone to SI-6666, SI-8363 by using old-style lambda translation
+ def isSpecialized = {
+ forceSpecializationInfoTransformOfFunctionN
+ val specialized = specializeTypes.specializedType(fun.tpe)
+ !(specialized =:= fun.tpe)
+ }
+ def canUseDelamdafyMethod = (
+ (inConstructorFlag == 0) // Avoiding synthesizing code prone to SI-6666, SI-8363 by using old-style lambda translation
+ && !isSpecialized // DelambdafyTransformer currently only emits generic FunctionN-s, use the old style in the meantime
+ )
if (inlineFunctionExpansion || !canUseDelamdafyMethod) {
val parents = addSerializable(abstractFunctionForFunctionType(fun.tpe))
val anonClass = fun.symbol.owner newAnonymousFunctionClass(fun.pos, inConstructorFlag) addAnnotation SerialVersionUIDAnnotation