From 7c42b5aa4de0d88e02b73bdcda49309bde834be6 Mon Sep 17 00:00:00 2001 From: Grzegorz Kossakowski Date: Mon, 16 Jul 2012 16:52:22 +0200 Subject: SI-6035: Specialization and separate compilation. Fix an issue when specialization wouldn't work properly in a setting where separate compilation was involved. E.g. if you inherit from a class that is specialized and has been compiled separately you might not get proper forwarders generated. A test-case that this commit adds covers that scenario. The root cause of this issue was the fact that SPECIALIZED flag was not pickled. Thanks to recent Flags reorganization (see a9b85db) all that needs to be done is to set the flag before pickling. We choose to that in superaccessors phase because it's a phase that runs before pickling and after type checking (so we can check if given symbol has an annotation). Removed old logic from uncurry that was responsible for setting flags that is not needed anymore because we set them in superaccessors. Review by @axel22 and @paulp. --- test/files/specialized/t6035.check | 1 + test/files/specialized/t6035/first_1.scala | 5 +++++ test/files/specialized/t6035/second_2.scala | 13 +++++++++++++ 3 files changed, 19 insertions(+) create mode 100644 test/files/specialized/t6035.check create mode 100644 test/files/specialized/t6035/first_1.scala create mode 100644 test/files/specialized/t6035/second_2.scala (limited to 'test/files') diff --git a/test/files/specialized/t6035.check b/test/files/specialized/t6035.check new file mode 100644 index 0000000000..573541ac97 --- /dev/null +++ b/test/files/specialized/t6035.check @@ -0,0 +1 @@ +0 diff --git a/test/files/specialized/t6035/first_1.scala b/test/files/specialized/t6035/first_1.scala new file mode 100644 index 0000000000..1289e9f48e --- /dev/null +++ b/test/files/specialized/t6035/first_1.scala @@ -0,0 +1,5 @@ +trait Foo[@specialized(Int) A] { + def foo(x: A): A +} + +abstract class Inter extends Foo[Int] diff --git a/test/files/specialized/t6035/second_2.scala b/test/files/specialized/t6035/second_2.scala new file mode 100644 index 0000000000..fb317e2a6a --- /dev/null +++ b/test/files/specialized/t6035/second_2.scala @@ -0,0 +1,13 @@ +class Baz extends Inter { + def foo(x: Int) = x + 1 +} + +object Test { + def main(args: Array[String]) { + // it's important that the type is Inter so we do not call Baz.foo(I)I directly! + val baz: Inter = new Baz + // here we should go through specialized version of foo and thus have zero boxing + baz.foo(1) + println(runtime.BoxesRunTime.integerBoxCount) + } +} -- cgit v1.2.3