Commit f3fec58
authored
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!File tree
44 files changed
+2205
-1078
lines changed- compiler/src/dotty/tools/dotc
- coverage
- transform
- tests/coverage
- pos
- run
- currying
- erased
- extend-case-class
- inheritance
- inline-def
- interpolation
- java-methods
- lifting-bool
- lifting
- parameterless
- trait
- varargs
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
44 files changed
+2205
-1078
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | | - | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | | - | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
29 | | - | |
| 30 | + | |
30 | 31 | | |
31 | | - | |
32 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
33 | 35 | | |
| 36 | + | |
34 | 37 | | |
35 | 38 | | |
36 | 39 | | |
| |||
42 | 45 | | |
43 | 46 | | |
44 | 47 | | |
45 | | - | |
46 | | - | |
| 48 | + | |
| 49 | + | |
47 | 50 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
65 | | - | |
66 | | - | |
67 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
68 | 69 | | |
69 | | - | |
70 | | - | |
| 70 | + | |
| 71 | + | |
71 | 72 | | |
72 | 73 | | |
73 | 74 | | |
74 | | - | |
| 75 | + | |
75 | 76 | | |
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
79 | | - | |
| 80 | + | |
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
83 | 84 | | |
84 | 85 | | |
85 | 86 | | |
86 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
0 commit comments