From 48c2d7bebb6ac41a897e58bd991cfa06818c7d71 Mon Sep 17 00:00:00 2001 From: Lukas Rytz Date: Thu, 15 Oct 2015 10:48:23 +0200 Subject: Simplify and correctify calculation of the InnerClass attribute The InnerClass attribute needs to contain an entry for every nested class that is defined or referenced in a class. Details are in a doc comment in BTypes.scala. Instead of collecting ClassBTypes of nested classes into a hash map during code generation, traverse the class before writing it out to disk. The previous approach was incorrect as soon as the generated bytecode was modified by the optimzier (DCE, inlining). Fixes https://github.com/scala/scala-dev/issues/21. --- test/files/jvm/innerClassAttribute/Classes_1.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'test/files/jvm/innerClassAttribute/Classes_1.scala') diff --git a/test/files/jvm/innerClassAttribute/Classes_1.scala b/test/files/jvm/innerClassAttribute/Classes_1.scala index 2b690bdd7b..5b821d43f8 100644 --- a/test/files/jvm/innerClassAttribute/Classes_1.scala +++ b/test/files/jvm/innerClassAttribute/Classes_1.scala @@ -13,7 +13,7 @@ object A3 { class A4 { def f(l: List[String]): List[String] = { - l map (_ + "1") + l map (_ + "1") : @noinline // inlining adds a reference to the nested class scala/collection/generic/GenTraversableFactory$GenericCanBuildFrom } } @@ -274,8 +274,8 @@ object NestedInValueClass { class A(val arg: String) extends AnyVal { // A has InnerClass entries for the two closures (and for A and A$). not for B / C def f = { - def g = List().map(x => ((s: String) => x)) // outer class A, no outer method (g is moved to the companion, doesn't exist in A) - g.map(x => ((s: String) => x)) // outer class A, outer method f + def g = List().map(x => ((s: String) => x)): @noinline // outer class A, no outer method (g is moved to the companion, doesn't exist in A) + g.map(x => ((s: String) => x)): @noinline // outer class A, outer method f } // statements and field declarations are not allowed in value classes } -- cgit v1.2.3