Commit c044420
authored
No warn implicit param of overriding method (#22901)
Fixes #22895
Fixes #22896
Follow-up to #22729
Follow-up to #22757
Since Scala 2, the check for unused parameters does not warn for an
overriding method, since the signature is dictated by the overridden
method. That behavior was intentionally omitted in 3.7 because it was
introduced in Scala 2 before `@nowarn` and `@unused` were available.
(The warning would be too noisy without mitigation.) A compiler option
for these heuristics was tried in a previous commit, but reverted.
(Compiler options are difficult to evolve once added.) So these commits
restore this heuristic without further ado. An option for "strict mode"
without allowances is future work.
The other issue was that detecting an override in a Java parent did not
work. The commit always checks `is(Override)` before searching for an
overridden member, since it is not necessary to verify the modifier
(which happens in RefChecks). Incorrect overriding would result in false
negatives, which is acceptable since it will error later.
Further asymmetry between checking implicit params and explicit class
param accessors may or may not be dubious.File tree
6 files changed
+71
-20
lines changed- compiler/src/dotty/tools/dotc
- core
- transform
- tests/warn
- i22896
6 files changed
+71
-20
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1953 | 1953 | | |
1954 | 1954 | | |
1955 | 1955 | | |
1956 | | - | |
| 1956 | + | |
1957 | 1957 | | |
1958 | 1958 | | |
1959 | 1959 | | |
| |||
Lines changed: 26 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
590 | 590 | | |
591 | 591 | | |
592 | 592 | | |
593 | | - | |
| 593 | + | |
594 | 594 | | |
595 | 595 | | |
596 | 596 | | |
| |||
614 | 614 | | |
615 | 615 | | |
616 | 616 | | |
| 617 | + | |
617 | 618 | | |
618 | 619 | | |
619 | 620 | | |
| |||
891 | 892 | | |
892 | 893 | | |
893 | 894 | | |
894 | | - | |
895 | | - | |
| 895 | + | |
| 896 | + | |
896 | 897 | | |
897 | 898 | | |
898 | 899 | | |
899 | 900 | | |
900 | | - | |
| 901 | + | |
901 | 902 | | |
902 | 903 | | |
903 | 904 | | |
904 | 905 | | |
905 | | - | |
| 906 | + | |
906 | 907 | | |
907 | | - | |
| 908 | + | |
908 | 909 | | |
909 | 910 | | |
910 | 911 | | |
911 | 912 | | |
912 | 913 | | |
913 | 914 | | |
914 | | - | |
915 | | - | |
| 915 | + | |
| 916 | + | |
916 | 917 | | |
917 | 918 | | |
918 | | - | |
| 919 | + | |
919 | 920 | | |
920 | | - | |
| 921 | + | |
921 | 922 | | |
922 | 923 | | |
923 | 924 | | |
924 | | - | |
| 925 | + | |
925 | 926 | | |
926 | | - | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
927 | 936 | | |
928 | | - | |
| 937 | + | |
929 | 938 | | |
930 | 939 | | |
931 | 940 | | |
| |||
939 | 948 | | |
940 | 949 | | |
941 | 950 | | |
942 | | - | |
| 951 | + | |
943 | 952 | | |
944 | | - | |
| 953 | + | |
945 | 954 | | |
946 | 955 | | |
947 | 956 | | |
948 | | - | |
| 957 | + | |
949 | 958 | | |
950 | 959 | | |
951 | 960 | | |
952 | 961 | | |
953 | 962 | | |
954 | 963 | | |
955 | 964 | | |
956 | | - | |
| 965 | + | |
957 | 966 | | |
958 | 967 | | |
959 | 968 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
| 125 | + | |
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
138 | 146 | | |
139 | 147 | | |
140 | 148 | | |
| |||
0 commit comments