summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/transform/Delambdafy.scala
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2016-03-25 19:08:23 -0700
committerAdriaan Moors <adriaan.moors@typesafe.com>2016-03-28 17:48:23 -0700
commit3ae39036771acb107cbb4a37fe6113c243d89acc (patch)
tree31479991adc4552fb0b95800cf461b9b791900dd /src/compiler/scala/tools/nsc/transform/Delambdafy.scala
parenta17d247a8acea2daaddb39263ebf1dcf5673bcba (diff)
downloadscala-3ae39036771acb107cbb4a37fe6113c243d89acc.tar.gz
scala-3ae39036771acb107cbb4a37fe6113c243d89acc.tar.bz2
scala-3ae39036771acb107cbb4a37fe6113c243d89acc.zip
Target FunctionN, not scala/runtime/java8/JFunction.
We compile FunctionN to Java 8's idea of a function now, so no need to target the artisanal JFunction and friends, except when the function is specialized, as I don't yet see how we can use LMF with the way specialization handles FunctionN: First, the working status quo -- the hand-crafted specialized versions of JFunction0. Notice how `apply$mcB$sp` is looking pretty SAMmy: ``` @FunctionalInterface public interface JFunction0$mcB$sp extends JFunction0 { @Override public byte apply$mcB$sp(); @Override default public Object apply() { return BoxesRunTime.boxToByte(this.apply$mcB$sp()); } } ``` Contrast this with our specialized standard FunctionN: ``` public interface Function0<R> { public R apply(); default public byte apply$mcB$sp() { return BoxesRunTime.unboxToByte(this.apply()); } } public interface Function0$mcB$sp extends Function0<Object> { } ``` The single abstract method in `Function0$mcB$sp` is `apply`, and the method that would let us avoid boxing, if it were abstract, is `apply$mcB$sp`... TODO (after M4): - do same for specialized functions (issues with boxing?) - remove scala/runtime/java8/JFunction* (need new STARR?)
Diffstat (limited to 'src/compiler/scala/tools/nsc/transform/Delambdafy.scala')
-rw-r--r--src/compiler/scala/tools/nsc/transform/Delambdafy.scala2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/Delambdafy.scala b/src/compiler/scala/tools/nsc/transform/Delambdafy.scala
index 7ccaec2f50..76c84bd428 100644
--- a/src/compiler/scala/tools/nsc/transform/Delambdafy.scala
+++ b/src/compiler/scala/tools/nsc/transform/Delambdafy.scala
@@ -241,7 +241,7 @@ abstract class Delambdafy extends Transform with TypingTransformers with ast.Tre
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"))
- else currentRun.runDefinitions.Scala_Java8_CompatPackage_JFunction(originalFunction.vparams.length)
+ else FunctionClass(originalFunction.vparams.length)
(functionalInterface, isSpecialized)
}