Commit 5b46ac2
committed
Fix variance checking in default getters
This is needed to compile geny in the community build which does:
def count(f: A => Boolean = ((_: Any) => true))
This happened to work before the previous commit because the inferred
type of the getter was `Any => Boolean`.
Crucially, we can only disable variance checking for default getters
whose result type matches the parameter type of the method, see
default-getter-variance.scala for a detailed justification of why this
is safe.
This fixes lets us get rid of an unjustified usage of
`@uncheckedVariance` when desugaring case classes.1 parent 6fde5c1 commit 5b46ac2
File tree
3 files changed
+50
-10
lines changed- compiler/src/dotty/tools/dotc
- ast
- typer
- tests/pos
3 files changed
+50
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
602 | 602 | | |
603 | 603 | | |
604 | 604 | | |
605 | | - | |
606 | | - | |
| 605 | + | |
607 | 606 | | |
608 | | - | |
609 | | - | |
610 | | - | |
611 | | - | |
612 | 607 | | |
613 | 608 | | |
614 | 609 | | |
| |||
638 | 633 | | |
639 | 634 | | |
640 | 635 | | |
641 | | - | |
642 | | - | |
643 | 636 | | |
644 | | - | |
| 637 | + | |
645 | 638 | | |
646 | 639 | | |
647 | 640 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1442 | 1442 | | |
1443 | 1443 | | |
1444 | 1444 | | |
1445 | | - | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
1446 | 1448 | | |
1447 | 1449 | | |
1448 | 1450 | | |
| |||
| 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 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
0 commit comments