[ConstraintSystem] Increase score only if members found on Optional
…
#35381
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
… and its unwrapped type
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. Butsince 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 verytime 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
shouldonly 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 staythe same because there could be no ambiguity.
Resolves: rdar://73027153