Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SI-9937 find nested java classes if InnerClass entry is missing #5822

Merged
merged 1 commit into from Jun 21, 2017

Conversation

lrytz
Copy link
Member

@lrytz lrytz commented Apr 3, 2017

When a classfile has a reference to an inner class C$D but no
InnerClass entry for it, the classfile parser would use the
top-level symbol C$D. In a different classfile, if there's also
a reference to C$D, but the InnerClass entry exists, the
symbol D owned by C (C.D) would be used. Therefore the two
signatures would be incompatible, which can lead to a spurious
type error.

Also, when an inner symbol C.D is resolved, the top-level
symbol C$D is invalidated and removed from the scope. A
subsequent lookup of the top-level symbol C$D (from a classfile
with a missing InnerClass entry) would fail.

This patch identifies the case when a class name containing
a $ is being looked up in a package. It splits the name, resolves
the outer class, and then searches for a member class.

@scala-jenkins scala-jenkins added this to the 2.12.3 milestone Apr 3, 2017
@lrytz
Copy link
Member Author

lrytz commented Apr 3, 2017

error: Class scala.Function1$mcZD not found - continuing with a stub

When a classfile has a reference to an inner class C$D but no
InnerClass entry for it, the classfile parser would use the
top-level symbol C$D. In a different classfile, if there's also
a reference to C$D, but the InnerClass entry exists, the
symbol D owned by C (C.D) would be used. Therefore the two
signatures would be incompatible, which can lead to a spurious
type error.

Also, when an inner symbol C.D is resolved, the top-level
symbol C$D is invalidated and removed from the scope. A
subsequent lookup of the top-level symbol C$D (from a classfile
with a missing InnerClass entry) would fail.

This patch identifies the case when a class name containing
a $ is being looked up in a package. It splits the name, resolves
the outer class, and then searches for a member class.
Copy link
Contributor

@adriaanm adriaanm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very well described solution! Just curious, is there a reason to look in the static scope before the instance scope?

@lrytz
Copy link
Member Author

lrytz commented Jun 21, 2017

No, there's no particular reason I did it in this order.

@lrytz lrytz merged commit 2c50123 into scala:2.12.x Jun 21, 2017
@SethTisue SethTisue changed the title SI-9937 find nested java classes if InnnerClass entry is missing SI-9937 find nested java classes if InnerClass entry is missing Jun 27, 2017
@lrytz lrytz deleted the t9937 branch July 20, 2017 14:28
smarter added a commit to dotty-staging/dotty that referenced this pull request Feb 7, 2022
This is a port of scala/scala#5822 which works
around a bug in Kotlin (https://youtrack.jetbrains.com/issue/KT-27936).

Fixes scala#12086.

Co-Authored-By: Lukas Rytz <lukas.rytz@gmail.com>
Co-Authored-By: Brandon Barker <beb82@cornell.edu>
smarter added a commit to dotty-staging/dotty that referenced this pull request Feb 7, 2022
This is a port of scala/scala#5822 which works
around a bug in Kotlin (https://youtrack.jetbrains.com/issue/KT-27936).

Fixes scala#12086.

Co-Authored-By: Lukas Rytz <lukas.rytz@gmail.com>
Co-Authored-By: Brandon Barker <beb82@cornell.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants