Skip to content

[CSOptimizer] A narrow fix for nil coalescing operator optimization #83365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 28, 2025

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Jul 28, 2025

?? is overloaded on optionality of the second parameter, prevent ranking the argument candidates for this parameter if there are candidates that come from failable initializer overloads because non-optional candidates are always going to be better and that can skew the selection.

I think this should be handled by logic that checks whether generic parameter type is "unconstrained" but I'd need to look into modifying that for invertiable protocols.

Resolves: rdar://156853018

`??` is overloaded on optionality of the second parameter,
prevent ranking the argument candidates for this parameter
if there are candidates that come from failable initializer
overloads because non-optional candidates are always going
to be better and that can skew the selection.

Resolves: rdar://156853018
@xedin xedin requested a review from hborla as a code owner July 28, 2025 08:00
@xedin
Copy link
Contributor Author

xedin commented Jul 28, 2025

@swift-ci please test

@xedin xedin merged commit 72299f6 into swiftlang:main Jul 28, 2025
5 checks passed
xedin added a commit to xedin/swift that referenced this pull request Jul 30, 2025
…tional injection

This makes sure that optional and non-optional types are ranked
uniformly when matched against a generic parameter type that
could accept either of them.

This is a more general fix for swiftlang#83365
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