Commit 54e2f59
committed
Properly support
This option is meant to avoid overcompilation involving sealed classes. By
default, Zinc invalidates all usages of a sealed class when a child is added or
removed, even though `val x: Sealed = new Child1` will work the same if
`Sealed` gets an extra child. When this option is on, Zinc only takes children
into account if the name usage is reported with `UseScope.PatMatTarget`. Note
that currently this is only set when traversing the scrutinee of a pattern
match (just like in the Scala 2 implementation), but to safely turn this option
on by default we would need to kept track of all call to `children` and
`sealedDescendants` in the compiler.
There were two issues related to this option before this commit:
- ExtractAPI was unnecessarily extracting the `@Child`
annotation, so the API hash of a sealed class changed even with
`useOptimizedSealed` enabled.
- When registering a used name with `UseScope.PatMatTarget` we should also
register it with `UseScope.Default` because (part of) the scrutinee type
might not be a sealed class, in which case it won't have
a name hash for PatMatTarget but should still lead to invalidations.
Since we only ever use two values for the `UseScope` parameter of the
`usedName` callback, we create two vals `DefaultScopes` and `PatMatScopes` that
we reuse for performance.xsbti.compile.IncOptions#useOptimizedSealed
1 parent 5b7913c commit 54e2f59
File tree
10 files changed
+150
-38
lines changed- compiler/src/dotty/tools/dotc/sbt
- sbt-test/source-dependencies/useOptimizedSealed
- changes
- project
10 files changed
+150
-38
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
676 | 676 | | |
677 | 677 | | |
678 | 678 | | |
679 | | - | |
680 | | - | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
681 | 686 | | |
682 | 687 | | |
683 | | - | |
| 688 | + | |
684 | 689 | | |
685 | 690 | | |
686 | 691 | | |
| |||
Lines changed: 66 additions & 35 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | 111 | | |
135 | 112 | | |
136 | 113 | | |
| |||
144 | 121 | | |
145 | 122 | | |
146 | 123 | | |
147 | | - | |
| 124 | + | |
148 | 125 | | |
149 | 126 | | |
150 | 127 | | |
| |||
202 | 179 | | |
203 | 180 | | |
204 | 181 | | |
205 | | - | |
| 182 | + | |
206 | 183 | | |
207 | 184 | | |
208 | 185 | | |
| |||
322 | 299 | | |
323 | 300 | | |
324 | 301 | | |
325 | | - | |
| 302 | + | |
326 | 303 | | |
327 | 304 | | |
328 | 305 | | |
| |||
347 | 324 | | |
348 | 325 | | |
349 | 326 | | |
350 | | - | |
351 | | - | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
352 | 331 | | |
353 | | - | |
354 | | - | |
| 332 | + | |
| 333 | + | |
355 | 334 | | |
356 | | - | |
357 | | - | |
| 335 | + | |
358 | 336 | | |
359 | | - | |
| 337 | + | |
360 | 338 | | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
361 | 356 | | |
362 | | - | |
| 357 | + | |
363 | 358 | | |
364 | 359 | | |
365 | 360 | | |
366 | | - | |
| 361 | + | |
367 | 362 | | |
368 | 363 | | |
369 | 364 | | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
370 | 401 | | |
371 | 402 | | |
372 | 403 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
Lines changed: 29 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
0 commit comments