Skip to content

[Sema] Translate names in unused result warnings of implicit functions #13622

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
Jan 5, 2018

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Dec 26, 2017

Problem

Currently, an unused call to synthesized == of enums and structs warns about an unused call to the functions __derived_enum_equals and __derived_struct_equals.

Solution

This PR adds a special case to translate these calls back to the call to the operator ==.

Example

enum Bar {
  case A, B
}

// Before
Bar.A == .B // Result of call to '__derived_enum_equals' is unused

// Now
Bar.A == .B // Result of call to operator '==' is unused

I just found this bug and it is not tracked by an SR yet.

Instead of warning about an unused result of a call to an implicit
function '__derived_enum_equals' or '__derived_struct_equals' use its
user-facing name '=='.
@ahoppen
Copy link
Member Author

ahoppen commented Dec 26, 2017

@swift-ci Please smoke test

@rudkx
Copy link
Contributor

rudkx commented Dec 26, 2017

LGTM. I'm curious why these have a special name to begin with, though?

Also, you'll need to run full tests to merge at the moment, not just smoke tests.

@ahoppen
Copy link
Member Author

ahoppen commented Dec 27, 2017

Thanks for having a look. I don't know why the special names are needed but it looks like they were introduced by #8735 by @graydon to remove inter-file-dependencies of operators.

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Jan 5, 2018

@swift-ci Please test and merge

@swift-ci swift-ci merged commit fbea78a into swiftlang:master Jan 5, 2018
@ahoppen ahoppen deleted the unused-result-implicit-funcs branch August 22, 2018 15:53
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.

3 participants