Commit e91afd4
committed
Allow partial eta expansion
Allow partial eta expansion using the following rule:
Assume we have an application
(x_1, ..., x_m) => f(<arg_1, ..., arg_n>)
every `x_i` occurs exactly once as argument to `f`, and typing `f` with `(?, ..., ?) => ?`
as expected type (where there are n occurrences of `?` in the argument list)
yields a method type `(T_1, ..., T_n)R`. Let `p` be the mapping from `1..m` to `1..n`
which maps every parameter `x_i` to the position where it occurs in `<arg_1, ..., arg_n>`.
In this case, if one of the parameter types `x_i` is not given and not inferred from the
expected type, assume `T_p(i)` as the type of `x_i`, provided `T_p(i)` is fully defined
and not a repeated type `T*` or `=>T*`.
The reason for excluding repeated types `T*` is that `T*` is not a valid type for a
lambda parameter.1 parent a082b9c commit e91afd4
File tree
4 files changed
+84
-24
lines changed- compiler/src/dotty/tools/dotc
- core
- typer
- tests/pos
4 files changed
+84
-24
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1044 | 1044 | | |
1045 | 1045 | | |
1046 | 1046 | | |
1047 | | - | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
1048 | 1054 | | |
1049 | 1055 | | |
1050 | 1056 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1056 | 1056 | | |
1057 | 1057 | | |
1058 | 1058 | | |
1059 | | - | |
1060 | | - | |
1061 | | - | |
1062 | | - | |
1063 | 1059 | | |
1064 | | - | |
| 1060 | + | |
1065 | 1061 | | |
1066 | 1062 | | |
1067 | 1063 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
724 | 724 | | |
725 | 725 | | |
726 | 726 | | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
727 | 744 | | |
728 | | - | |
729 | | - | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
730 | 751 | | |
731 | 752 | | |
732 | | - | |
733 | | - | |
734 | | - | |
735 | | - | |
736 | | - | |
737 | | - | |
738 | | - | |
739 | | - | |
740 | | - | |
741 | | - | |
742 | | - | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
743 | 770 | | |
744 | 771 | | |
745 | 772 | | |
746 | 773 | | |
747 | 774 | | |
748 | 775 | | |
749 | | - | |
750 | | - | |
751 | | - | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
752 | 780 | | |
753 | 781 | | |
754 | 782 | | |
755 | 783 | | |
756 | 784 | | |
757 | 785 | | |
758 | | - | |
| 786 | + | |
759 | 787 | | |
760 | 788 | | |
761 | | - | |
| 789 | + | |
| 790 | + | |
762 | 791 | | |
763 | 792 | | |
764 | 793 | | |
| |||
| 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 | + | |
0 commit comments