Commit 53bea78
authored
Revise capability hierarchy and fix classifiers (#23656)
We now make `Capability` a sealed trait with two subtraits:
`SharedCapability` and `ExclusiveCapability`. This forces one to pick
one or the other when defining a new `Capability` type. Most tests were
changed to use `SharedCapability` instead of `Capability`. Since
classifiers are now much more common than before, this showed up some
bugs and anomalies for classifyer handling, which are also addressed in
this PR.
Details:
1. Further improvement to error messages. We now explain why FreshCaps
cannot subsume a capability.
3. We turn caching off by default for `captureSetOfInfo`. During
experimentation I found that sometimes `captureSetOfInfo` could be
cached too early, leading to a locked in universal cap in the info where
we would expect to see a fresh cap. On the standard library it did not
look like this had a noticeable performance impact.
4. Fixes to `tryClassifyAs` and `transClassifiers`. In particular, we
need to distinguish `FreshCap`s that can still be classified from ones
that cannot. Once a `FreshCap` is part of a constant capture set, it
gets classified by the type that prefixes the set and that
classification cannot be changed anymore. But other `FreshCap`s are
created as members of variable sets and then their classification status
is open and can be constrained further.
5. Convert a fresh cap to a reach capability only if the reach
capability might subcapture the fresh cap. Since fresh caps are now
classified that is not always the case.
6. Turn pre-type closure results on for parametric expected function
types. This gives sometimes better errors and avoids premature mapings
to scoped result types in closure bodies.
7. Use `cap.rd` as implicitly added capability only for references
extending `ExclusiveCapability`. Use `cap` for the others.
We also include now captures in the result type of a function in the
`captureSetofInfo` of that function.File tree
178 files changed
+913
-455
lines changed- compiler/src/dotty/tools/dotc
- cc
- core
- printing
- library/src/scala/caps
- tests
- disabled/pos
- neg-custom-args/captures
- caseclass
- pos-custom-args/captures
- run-tasty-inspector
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
178 files changed
+913
-455
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
155 | 166 | | |
156 | 167 | | |
157 | 168 | | |
158 | 169 | | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
159 | 188 | | |
160 | 189 | | |
161 | 190 | | |
| |||
477 | 506 | | |
478 | 507 | | |
479 | 508 | | |
480 | | - | |
| 509 | + | |
481 | 510 | | |
482 | 511 | | |
483 | 512 | | |
| |||
495 | 524 | | |
496 | 525 | | |
497 | 526 | | |
498 | | - | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
499 | 532 | | |
500 | 533 | | |
501 | 534 | | |
| |||
524 | 557 | | |
525 | 558 | | |
526 | 559 | | |
527 | | - | |
| 560 | + | |
| 561 | + | |
528 | 562 | | |
529 | 563 | | |
530 | 564 | | |
| |||
534 | 568 | | |
535 | 569 | | |
536 | 570 | | |
537 | | - | |
| 571 | + | |
| 572 | + | |
538 | 573 | | |
539 | 574 | | |
540 | 575 | | |
| |||
547 | 582 | | |
548 | 583 | | |
549 | 584 | | |
550 | | - | |
551 | | - | |
| 585 | + | |
| 586 | + | |
552 | 587 | | |
553 | 588 | | |
554 | 589 | | |
| |||
677 | 712 | | |
678 | 713 | | |
679 | 714 | | |
680 | | - | |
| 715 | + | |
681 | 716 | | |
682 | 717 | | |
683 | 718 | | |
| |||
686 | 721 | | |
687 | 722 | | |
688 | 723 | | |
689 | | - | |
| 724 | + | |
690 | 725 | | |
691 | 726 | | |
692 | 727 | | |
| |||
696 | 731 | | |
697 | 732 | | |
698 | 733 | | |
699 | | - | |
| 734 | + | |
700 | 735 | | |
701 | 736 | | |
702 | 737 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
378 | 378 | | |
379 | 379 | | |
380 | 380 | | |
381 | | - | |
| 381 | + | |
| 382 | + | |
382 | 383 | | |
383 | 384 | | |
384 | 385 | | |
| |||
401 | 402 | | |
402 | 403 | | |
403 | 404 | | |
404 | | - | |
405 | 405 | | |
406 | | - | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
407 | 411 | | |
408 | 412 | | |
409 | 413 | | |
| |||
599 | 603 | | |
600 | 604 | | |
601 | 605 | | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
602 | 611 | | |
603 | 612 | | |
604 | 613 | | |
| |||
647 | 656 | | |
648 | 657 | | |
649 | 658 | | |
650 | | - | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
651 | 662 | | |
652 | 663 | | |
653 | 664 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
263 | 263 | | |
264 | 264 | | |
265 | 265 | | |
266 | | - | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
267 | 273 | | |
268 | 274 | | |
269 | 275 | | |
270 | 276 | | |
271 | | - | |
272 | | - | |
| 277 | + | |
| 278 | + | |
273 | 279 | | |
274 | 280 | | |
275 | 281 | | |
| |||
436 | 442 | | |
437 | 443 | | |
438 | 444 | | |
439 | | - | |
| 445 | + | |
440 | 446 | | |
441 | 447 | | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
442 | 457 | | |
443 | 458 | | |
444 | 459 | | |
| |||
611 | 626 | | |
612 | 627 | | |
613 | 628 | | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
614 | 632 | | |
615 | 633 | | |
616 | | - | |
| 634 | + | |
| 635 | + | |
617 | 636 | | |
618 | 637 | | |
619 | 638 | | |
| |||
692 | 711 | | |
693 | 712 | | |
694 | 713 | | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
695 | 717 | | |
696 | 718 | | |
697 | 719 | | |
| |||
743 | 765 | | |
744 | 766 | | |
745 | 767 | | |
| 768 | + | |
746 | 769 | | |
747 | 770 | | |
748 | 771 | | |
749 | 772 | | |
750 | 773 | | |
751 | 774 | | |
752 | | - | |
| 775 | + | |
753 | 776 | | |
754 | 777 | | |
755 | 778 | | |
| |||
778 | 801 | | |
779 | 802 | | |
780 | 803 | | |
781 | | - | |
| 804 | + | |
782 | 805 | | |
783 | 806 | | |
784 | 807 | | |
| |||
1246 | 1269 | | |
1247 | 1270 | | |
1248 | 1271 | | |
1249 | | - | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
1250 | 1279 | | |
1251 | 1280 | | |
1252 | 1281 | | |
| |||
1258 | 1287 | | |
1259 | 1288 | | |
1260 | 1289 | | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
1261 | 1322 | | |
1262 | 1323 | | |
1263 | 1324 | | |
| |||
1274 | 1335 | | |
1275 | 1336 | | |
1276 | 1337 | | |
1277 | | - | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
1278 | 1343 | | |
1279 | 1344 | | |
1280 | 1345 | | |
| |||
1487 | 1552 | | |
1488 | 1553 | | |
1489 | 1554 | | |
1490 | | - | |
| 1555 | + | |
1491 | 1556 | | |
1492 | 1557 | | |
1493 | 1558 | | |
1494 | | - | |
1495 | | - | |
1496 | | - | |
1497 | | - | |
1498 | 1559 | | |
1499 | 1560 | | |
1500 | 1561 | | |
| |||
1510 | 1571 | | |
1511 | 1572 | | |
1512 | 1573 | | |
1513 | | - | |
| 1574 | + | |
1514 | 1575 | | |
1515 | | - | |
1516 | | - | |
1517 | | - | |
1518 | | - | |
1519 | | - | |
| 1576 | + | |
1520 | 1577 | | |
1521 | 1578 | | |
1522 | 1579 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
44 | 43 | | |
45 | 44 | | |
46 | 45 | | |
| |||
0 commit comments