Skip to content

[Diagnostics] Check whether missing conformance could be fixed by using .rawValue #36445

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 4 commits into from
Mar 17, 2021

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Mar 16, 2021

A lot of operators (and most likely regular functions a well) have
overloads that accept i.e. a generic parameter that conforms to
StringProtocol, so the best fix in situations when argument is
a raw representable type would be to check whether .rawValue
conforms to the expected protocol and use it if so.

Resolves rdar://problem/75367157

xedin added 2 commits March 15, 2021 16:53
…ng `.rawValue`

A lot of operators (and most likely regular functions a well) have
overloads that accept i.e. a generic parameter that conforms to
`StringProtocol`, so the best fix in situations when argument is
a raw representable type would be to check whether `.rawValue`
conforms to the expected protocol and use it if so.

Resolves rdar://problem/75367157
In situations like `""?` or `42?`, let's not record an unwrap fix
since it was incorrect to use `?` in the first place.
@xedin xedin requested a review from hborla March 16, 2021 00:18
…ble type doesn't conform but `.rawValue` does
@xedin
Copy link
Contributor Author

xedin commented Mar 16, 2021

@swift-ci please smoke test

…Value` still diagnose it as conformance issue

Conformance requirement failure is a more descriptive error,
augment it with a note about missing `.rawValue`.
@xedin
Copy link
Contributor Author

xedin commented Mar 17, 2021

@swift-ci please smoke test

@xedin
Copy link
Contributor Author

xedin commented Mar 17, 2021

@swift-ci please test Windows platform

@xedin
Copy link
Contributor Author

xedin commented Mar 17, 2021

@swift-ci please test macOS platform

@xedin
Copy link
Contributor Author

xedin commented Mar 17, 2021

@swift-ci please smoke test Windows platform

@xedin xedin merged commit 1dd914a into swiftlang:main Mar 17, 2021
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.

2 participants