Skip to content

Conversation

@xedin
Copy link
Contributor

@xedin xedin commented Nov 11, 2025

…olved result type

?? operator is overloaded on optionality of its result. When the first argument matches exactly, the ranking is going to be skewed towards selecting an overload choice that returns a non-optional type. This is not always correct i.e. when operator is involved in optional chaining. To avoid producing an incorrect favoring, let's skip the this disjunction when constraints associated with result type indicate that it should be optional.

Simply adding it as a binding won't work because if the second argument is non-optional the overload that returns T? would still have a lower score.

Resolves: rdar://164201746

@xedin xedin requested a review from hborla as a code owner November 11, 2025 23:07
@xedin
Copy link
Contributor Author

xedin commented Nov 11, 2025

@swift-ci please test

@xedin
Copy link
Contributor Author

xedin commented Nov 11, 2025

@swift-ci please test source compatibility

…olved result type

`??` operator is overloaded on optionality of its result. When the
first argument matches exactly, the ranking is going to be skewed
towards selecting an overload choice that returns a non-optional type.
This is not always correct i.e. when operator is involved in optional
chaining. To avoid producing an incorrect favoring, let's skip the this
disjunction when constraints associated with result type indicate
that it should be optional.

Simply adding it as a binding won't work because if the second argument
is non-optional the overload that returns `T?` would still have a lower
score.

Resolves: rdar://164201746
@xedin
Copy link
Contributor Author

xedin commented Nov 11, 2025

@swift-ci please test

@xedin
Copy link
Contributor Author

xedin commented Nov 11, 2025

@swift-ci please test source compatibility

1 similar comment
@xedin
Copy link
Contributor Author

xedin commented Nov 12, 2025

@swift-ci please test source compatibility

@xedin
Copy link
Contributor Author

xedin commented Nov 13, 2025

Source compatibility suite is failing because of UPASS'ing projects.

@xedin xedin merged commit 4bd370f into swiftlang:main Nov 13, 2025
5 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant