From 818a2e6597f23a82f848cd1f7d3b2e29129390a6 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Sat, 8 Dec 2012 18:15:08 +0100 Subject: SI-6555 Better parameter name retention We were losing track of parameter names in two places: 1. Uncurry was using fresh names for the apply method parameters during Function expansion. (The parameter names in the tree were actually correct, they just had synthetic symbols with "x$1" etc.) 2. When adding specialized overrides, the parameter names of the overriden method were used, rather than the parameter names from the overriding method in the class to which we are adding methods. The upshot of this is that when you're stopped in the debugger in the body of, say, `(i: Int) => i * i`, you see `v1` rather than `i`. This commit changes Uncurry and SpecializeTypes to remedy this. --- test/files/run/t6555.check | 22 ++++++++++++++++++++++ test/files/run/t6555.scala | 15 +++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 test/files/run/t6555.check create mode 100644 test/files/run/t6555.scala (limited to 'test/files/run') diff --git a/test/files/run/t6555.check b/test/files/run/t6555.check new file mode 100644 index 0000000000..04117b7c2f --- /dev/null +++ b/test/files/run/t6555.check @@ -0,0 +1,22 @@ +[[syntax trees at end of specialize]] // newSource1 +package { + class Foo extends Object { + def (): Foo = { + Foo.super.(); + () + }; + private[this] val f: Int => Int = { + @SerialVersionUID(0) final class $anonfun extends scala.runtime.AbstractFunction1$mcII$sp with Serializable { + def (): anonymous class $anonfun = { + $anonfun.super.(); + () + }; + final def apply(param: Int): Int = $anonfun.this.apply$mcII$sp(param); + def apply$mcII$sp(param: Int): Int = param + }; + (new anonymous class $anonfun(): Int => Int) + }; + def f(): Int => Int = Foo.this.f + } +} + diff --git a/test/files/run/t6555.scala b/test/files/run/t6555.scala new file mode 100644 index 0000000000..b1a6137786 --- /dev/null +++ b/test/files/run/t6555.scala @@ -0,0 +1,15 @@ +import scala.tools.partest._ +import java.io.{Console => _, _} + +object Test extends DirectTest { + + override def extraSettings: String = "-usejavacp -Xprint:specialize -d " + testOutput.path + + override def code = "class Foo { val f = (param: Int) => param } " + + override def show(): Unit = { + Console.withErr(System.out) { + compile() + } + } +} -- cgit v1.2.3