diff options
author | Lukas Rytz <lukas.rytz@gmail.com> | 2015-10-15 10:48:23 +0200 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@gmail.com> | 2015-10-20 21:24:59 +0200 |
commit | 48c2d7bebb6ac41a897e58bd991cfa06818c7d71 (patch) | |
tree | 33a35ec2ba3bf6b7d37deb8359dc57858b302c0c /test/files | |
parent | 6df88b024f720a10d3f7451750ab620addf725b9 (diff) | |
download | scala-48c2d7bebb6ac41a897e58bd991cfa06818c7d71.tar.gz scala-48c2d7bebb6ac41a897e58bd991cfa06818c7d71.tar.bz2 scala-48c2d7bebb6ac41a897e58bd991cfa06818c7d71.zip |
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.
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/jvm/innerClassAttribute/Classes_1.scala | 6 | ||||
-rw-r--r-- | test/files/jvm/innerClassAttribute/Test.scala | 2 |
2 files changed, 4 insertions, 4 deletions
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 } diff --git a/test/files/jvm/innerClassAttribute/Test.scala b/test/files/jvm/innerClassAttribute/Test.scala index 702e5e279a..903d08f72d 100644 --- a/test/files/jvm/innerClassAttribute/Test.scala +++ b/test/files/jvm/innerClassAttribute/Test.scala @@ -23,7 +23,7 @@ object Test extends BytecodeTest { def testInner(cls: String, fs: (InnerClassNode => Unit)*) = { val ns = innerClassNodes(cls) - assert(ns.length == fs.length, ns) + assert(ns.length == fs.length, ns.map(_.name)) (ns zip fs.toList) foreach { case (n, f) => f(n) } } |