-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #1648: don't define companion object for java.lang.Object #1724
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
Conversation
13d5fab
to
0e8fd73
Compare
It seems the fix works. I'm not sure if it's the right way to do it. Could you please advise, @odersky ? |
modFlags = flags.toTermFlags & RetainedModuleValFlags, | ||
clsFlags = flags.toTypeFlags & RetainedModuleClassFlags, | ||
scope = scope) | ||
|
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.
It's a way to do it, but not very elegant to test this for every class and module that's entered.
I played with an alternative strategy, which also seems to work and is less intrusive: IN line 196 of Definitions, where we define ObjectClass, insert:
val companion = JavaLangPackageVal.info.decl(nme.Object).symbol
companion.info = NoType // to indicate that it does not really exist
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.
Note: The NoType
technique is not an accident. It is used for all companion objects that are entered (because we see their file name) but turn out to not exist after class loading. Here we have to do it before class loading because once we try to load Object's classfile it is already too late.
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.
Thanks @odersky , this is much more elegant 👍 . I've pushed a new commit adopting the approach.
0e8fd73
to
e6ad1fb
Compare
e6ad1fb
to
9f8c81c
Compare
LGTM |
The bug is already fixed in PR scala#1724 while fixing another issue
The bug is already fixed in PR scala#1724 while fixing another issue
Fix #1648:
java.lang.Object
has no static methods, there's no need to define module object for it.