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
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
lrytz
force-pushed
the
t9937
branch
2 times, most recently
from
April 4, 2017 12:25
e2e8e96
to
811faf4
Compare
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.
adriaanm
approved these changes
Jun 20, 2017
There was a problem hiding this 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?
No, there's no particular reason I did it in this order. |
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.