summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/transform/Delambdafy.scala
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2016-07-22 14:19:19 +1000
committerJason Zaugg <jzaugg@gmail.com>2016-07-22 14:27:25 +1000
commite4a978d06b410700b2ee85696b9ad6f6aa7ff183 (patch)
tree65e9d3d203b08f3b2ef36d002fbf72743fceb732 /src/compiler/scala/tools/nsc/transform/Delambdafy.scala
parent6b99dfe746cbb76828db495b58e55db2a0265ee2 (diff)
downloadscala-e4a978d06b410700b2ee85696b9ad6f6aa7ff183.tar.gz
scala-e4a978d06b410700b2ee85696b9ad6f6aa7ff183.tar.bz2
scala-e4a978d06b410700b2ee85696b9ad6f6aa7ff183.zip
SD-121 Remove now-unneeded J{Function,Proc}N functional interfaces
Non specialized functions can directly use `scala.FunctionN` as the functional interface, now that mixin generates default methods in the new trait encoding. Unfortunately we can't do this for specialized functions as things stand: specialization leaves the wrong method abstract. In principle, we could/should amend the specialization transform to fix this. But my earlier attempts at this weren't sucessful, so for now we have to stick with the fallback plan of keeping some hand rolled functional interfaces around. This commit reduces the surface area of `scala.runtime.java8` to the minimal requiremnt: one functional interface for each specialized variant of `Function{0,1,2}`.
Diffstat (limited to 'src/compiler/scala/tools/nsc/transform/Delambdafy.scala')
-rw-r--r--src/compiler/scala/tools/nsc/transform/Delambdafy.scala8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/Delambdafy.scala b/src/compiler/scala/tools/nsc/transform/Delambdafy.scala
index 804bcddb7b..88837842fa 100644
--- a/src/compiler/scala/tools/nsc/transform/Delambdafy.scala
+++ b/src/compiler/scala/tools/nsc/transform/Delambdafy.scala
@@ -241,8 +241,12 @@ abstract class Delambdafy extends Transform with TypingTransformers with ast.Tre
exitingErasure(target.info.paramTypes).map(reboxValueClass) :+ reboxValueClass(exitingErasure(target.info.resultType))).toTypeName
val isSpecialized = specializedName != funSym.name
- val functionalInterface = // TODO: this is no longer needed, right? we can just use the regular function classes
- if (isSpecialized) currentRun.runDefinitions.Scala_Java8_CompatPackage.info.decl(specializedName.prepend("J"))
+ val functionalInterface =
+ if (isSpecialized) {
+ // Unfortunately we still need to use custom functional interfaces for specialized functions so that the
+ // unboxed apply method is left abstract for us to implement.
+ currentRun.runDefinitions.Scala_Java8_CompatPackage.info.decl(specializedName.prepend("J"))
+ }
else FunctionClass(originalFunction.vparams.length)
(functionalInterface, isSpecialized)