scala / scala3

The Scala 3 compiler, also known as Dotty.
https://dotty.epfl.ch
Apache License 2.0
5.89k stars 1.06k forks source link

necessary and sufficient conditions for inclusion in InnerClasses JVM attribute #24

Open magarciaEPFL opened 10 years ago

magarciaEPFL commented 10 years ago

Emitting a class file involves populating its InnerClass table as per the JVM spec.

For that, GenBCode follows the same strategy GenASM does (which in turn follows what GenJVM did): intercepting via asmClassType() each usage of a class-name in the class file being emitted.

That gives the right answer about 99.9% of the time. However as https://issues.scala-lang.org/browse/SI-6759 explains, there are cases where that approach includes too much in the InnerClasses table.

GenBCode has a solution for that, refreshInnerClasses(), which should be adopted as the primary mechanism (throwing away the innerClassBufferASM that's part of the BCInnerClassGen trait).

DarkDimius commented 9 years ago

I'm not going to work on this any time soon and this is low priority.

lrytz commented 9 years ago

I recently re-wrote how we compute the InnerClass table in scalac, this should just work for dotty, too. https://github.com/scala/scala/pull/4807.

dwijnand commented 2 years ago

See also the PRs linked in the original issue: https://github.com/scala/bug/issues/6759#issuecomment-292415629, which include a thorough set of test cases.