Commit f663727
committed
[ConstraintSystem] Increase score only if members found on
Unresolved member lookup is allowed to perform implicit optional
unwrap of a base type to find members. Previously if there were
any members directly on `Optional`, lookup would stop there. But
since SR-13815 it became possible for solver to attempt members
found on unwrapped type even if there are viable ones on
`Optional` as well.
New score kind has been introduced to guard against possible ambiguities
with new scheme - `SK_UnresolvedMemberViaOptional`. It's used very
time member found via base type unwrap is attempted. Unfortunately,
doing so can lead to behavior changes in existing code because it's
possible that base was wrapped into optional implicitly based on
context e.g. unresolved member passed in as an argument to a parameter
of optional type.
To fix situations like that, `SK_UnresolvedMemberViaOptional` should
only be increased if there is a mix of members to attempt - both directly
on `Optional` and on unwrapped type, in all other cases score should stay
the same because there could be no ambiguity.
Resolves: rdar://73027153Optional and its unwrapped type1 parent d710cfc commit f663727
File tree
4 files changed
+62
-13
lines changed- include/swift/Sema
- lib/Sema
- test/Constraints
4 files changed
+62
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
76 | 81 | | |
77 | 82 | | |
78 | | - | |
| 83 | + | |
79 | 84 | | |
80 | 85 | | |
81 | 86 | | |
| |||
175 | 180 | | |
176 | 181 | | |
177 | 182 | | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
178 | 187 | | |
179 | | - | |
| 188 | + | |
180 | 189 | | |
181 | 190 | | |
182 | 191 | | |
183 | | - | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
184 | 195 | | |
185 | 196 | | |
186 | 197 | | |
187 | 198 | | |
188 | | - | |
| 199 | + | |
189 | 200 | | |
190 | 201 | | |
191 | 202 | | |
| |||
219 | 230 | | |
220 | 231 | | |
221 | 232 | | |
| 233 | + | |
222 | 234 | | |
223 | 235 | | |
224 | 236 | | |
| |||
256 | 268 | | |
257 | 269 | | |
258 | 270 | | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
259 | 277 | | |
260 | 278 | | |
261 | 279 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6672 | 6672 | | |
6673 | 6673 | | |
6674 | 6674 | | |
6675 | | - | |
6676 | | - | |
| 6675 | + | |
| 6676 | + | |
| 6677 | + | |
6677 | 6678 | | |
6678 | 6679 | | |
6679 | 6680 | | |
| |||
6694 | 6695 | | |
6695 | 6696 | | |
6696 | 6697 | | |
6697 | | - | |
6698 | | - | |
| 6698 | + | |
| 6699 | + | |
| 6700 | + | |
6699 | 6701 | | |
6700 | 6702 | | |
6701 | 6703 | | |
| |||
6719 | 6721 | | |
6720 | 6722 | | |
6721 | 6723 | | |
6722 | | - | |
| 6724 | + | |
6723 | 6725 | | |
6724 | 6726 | | |
6725 | 6727 | | |
| |||
6802 | 6804 | | |
6803 | 6805 | | |
6804 | 6806 | | |
| 6807 | + | |
| 6808 | + | |
| 6809 | + | |
| 6810 | + | |
6805 | 6811 | | |
6806 | 6812 | | |
6807 | 6813 | | |
6808 | | - | |
6809 | | - | |
| 6814 | + | |
| 6815 | + | |
| 6816 | + | |
6810 | 6817 | | |
6811 | 6818 | | |
6812 | 6819 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2799 | 2799 | | |
2800 | 2800 | | |
2801 | 2801 | | |
2802 | | - | |
2803 | | - | |
| 2802 | + | |
2804 | 2803 | | |
2805 | 2804 | | |
2806 | 2805 | | |
| |||
| 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 | + | |
0 commit comments