From 075f6f260ccfba83b118c308195d1ede2e66ad18 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 4 Nov 2013 16:51:20 -0800 Subject: SI-6546 InnerClasses attribute refers to absent class At issue is that the optimizer would eliminate closure classes completely, then neglect to eliminate those classes from the container's InnerClasses attribute. This breaks tooling which expects those entries to correspond to real classes. The code change is essentially mgarcia's - I minimized it and put the caches in perRunCaches, and added the test case which verifies that after being compiled under -optimise, there are no inner classes. Before/after: 7,8d6 < InnerClasses: < public final #22; //class A_1$$anonfun$f$1 37,45c35,40 < #21 = Utf8 A_1$$anonfun$f$1 < #22 = Class #21 // A_1$$anonfun$f$1 < #23 = Utf8 Code --- > #21 = Utf8 Code --- test/files/run/t6546.flags | 1 + test/files/run/t6546/A_1.scala | 6 ++++++ test/files/run/t6546/B_2.scala | 8 ++++++++ 3 files changed, 15 insertions(+) create mode 100644 test/files/run/t6546.flags create mode 100644 test/files/run/t6546/A_1.scala create mode 100644 test/files/run/t6546/B_2.scala (limited to 'test') diff --git a/test/files/run/t6546.flags b/test/files/run/t6546.flags new file mode 100644 index 0000000000..eb4d19bcb9 --- /dev/null +++ b/test/files/run/t6546.flags @@ -0,0 +1 @@ +-optimise \ No newline at end of file diff --git a/test/files/run/t6546/A_1.scala b/test/files/run/t6546/A_1.scala new file mode 100644 index 0000000000..bd086c08f8 --- /dev/null +++ b/test/files/run/t6546/A_1.scala @@ -0,0 +1,6 @@ +final class Opt { + @inline def getOrElse(x: => String): String = "" +} +class A_1 { + def f(x: Opt): String = x getOrElse null +} diff --git a/test/files/run/t6546/B_2.scala b/test/files/run/t6546/B_2.scala new file mode 100644 index 0000000000..64ec966f75 --- /dev/null +++ b/test/files/run/t6546/B_2.scala @@ -0,0 +1,8 @@ +import scala.tools.partest.BytecodeTest + +object Test extends BytecodeTest { + def show: Unit = { + val node = loadClassNode("A_1") + assert(node.innerClasses.isEmpty, node.innerClasses) + } +} -- cgit v1.2.3