-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make coverage instrumentation more robust (#16235)
*As with the last coverage PR, don't worry: most of the changes are "expect" files for tests. On top of that, many files have only changed by the order in which the statements are recorded, but this order doesn't matter.* Small changes which, together, make the instrumentation more robust and fix many bugs: 1. Address comments in #15739 by introducing a type `InstrumentedParts`. The initial problem was that `TypeApply` cannot be instrumented in a straightforward way: `expr[T]` cannot be turned into `{invoked(...); expr}[T]` but must be `{invoked(...); expr[T]}`. To do this, we first try to instrument `expr` and then, if it was successfully instrumented, we move the call to `invoked(...)` to the right place. This gives us the following code in `transform`: ```scala case TypeApply(fun, args) => val InstrumentedParts(pre, coverageCall, expr) = tryInstrument(fun) // may generate a call to invoked(...), but it's not part of the resulting tree yet if coverageCall.isEmpty then tree else Block( pre :+ coverageCall, // put the call at the right place (pre contains lifted definitions, if any) cpy.TypeApply(tree)(expr, args) ) ``` 2. Exclude more trees from instrumentation, like `Erased` trees and calls to the parents' constructor in `Template#parents`. 3. Escape special characters in `Serializer`. 4. Reposition `Inlined` trees to the current source in order to avoid referencing an unreachable compilation unit. This might be the most controversial change because I've called `Inlines.dropInlined` 👀. Any suggestion is welcome!
- Loading branch information
Showing
44 changed files
with
2,205 additions
and
1,078 deletions.
There are no files selected for viewing
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
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
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
Oops, something went wrong.