-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix 13777 - refine check for caching companion in sum mirror #14035
Conversation
Edit- was fine after re-running CI |
cache the mirror in the companion if: - the class is not scala 2 defined & the class has a companion & the class was either: - defined in source - from tasty and its companion is a subtype of Mirror.Sum
@smarter I have implemented the simpler version of a from-source check |
self.linkedClass.exists | ||
&& !self.is(Scala2x) | ||
&& ( | ||
// self is from source, or companion is a subtype of Sum |
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'd be good to explain why for things which are not from source we need the more precise check (i.e., the difference in code generation between scala 3.0 and 3.1).
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 more about the other way round: ideally we can just check is subclass (which is only true in scala 3.1+). But we call this check before that parent is added, for code in compilation, so have to handle that specially.
Feels like the two new ones would subsume !self.is(Scala2x)
, right? (minor)
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.
I have clarified the comment to explain why we check if its from source
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, Jamie, for picking this up. Good to see it didn't spin out from the fix we had theorycrafted. Good to go, for me. I would hope this could make the 3.1.1 patch release.
This also exposes a check to see if a file is a "lateCompile" in the current run, as a late-compiled symbol's type info is derived from source - aka a companion that is late-compiled would not subtypeMirror.Sum
.Edit: the above is no longer a part of these changes
cache the mirror in the companion if:
& the class has a companion
& the class was either:
fixes #13777