-
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 coverage instrumentation of Java-defined and parameterless methods #15648
Conversation
Like #15530, I'll backport this to release-3.0 once it's good. |
Hey @TheElectronWill, just to be transparent, I know you tagged me on this but I'm no longer really working on any coverage related stuff apart from just cutting releases of scoverage, so probably best to tag someone else for a more timely review. |
No problem! Thanks for your transparence :) Tentatively assigning my homonym @smarter, who is suggested by GitHub (feel free to assign someone else if you don't have the time to review this, I know you've got things to write ^^). |
Yeah I wish I could but as I'm handing in my thesis in two weeks I definitely don't have the time to look at github, so passing the buck to @dwijnand 😅 |
Best of luck for your thesis! |
1. Select and TypeApply trees weren't properly handled for JavaDefined symbols, leading to a crash when selecting a static method with parameter types. 2. Select and Ident trees weren't properly handled, and many occurences of parameterless methods were missed. 3. Some methods like asInstanceOf and isInstanceOf must not be instrumented, otherwise it crashes in Erasure.
cc0bc92
to
3fbbbd9
Compare
While investigating a compiler crash using coverage (separate issue, ticket may be forthcoming), I observed what seems to be a regression with this PR. The following snippet now emits an error: import scala.compiletime.uninitialized
class Foo:
var x: AnyRef = uninitialized
It compiles without error using |
Ah yes, that's because it gets instrumented like this: var x = {
invoked(...)
uninitialized
} I'll add it to the blacklist. EDIT: done ✔️ |
@sjrd do you by any chance have some time to take a look at this PR? |
I'll find some time in the coming week. |
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.
The changes to the compiler code LGTM. I have not checked the test changes, as I don't know what I'm looking at. ;)
Auto-generated boring coverage data, essentially 😄 Thanks for the review! |
Note: dear reviewer, don't worry! Most of the changes are "expect" files for the tests. The actual changes in the compiler codebase are small :)
#13880 introduced code instrumentation for coverage analysis with the compiler option
-coverage-out
. #15530 fixed a few corner cases in the instrumentation, but 3 bugs remained:The right way to detect parameterless methods seems to be
Most of the changes in the expect files are caused by this fix.
asInstanceOf
andisInstanceOf
must not be instrumented, otherwise it crashes in Erasure. That is, we should never generate this:I've also ignored the calls to methods on primitive types, like
Int.+
, because it doesn't exist at runtime and doesn't seem interesting to instrument. Note that ina + f()
, the call tof
will be instrumented properly. Also, ifa
is a parameterless method, the call toa
will be instrumented.For example:
previously resulted in:
and now gives: