Skip to content

[Sema] Look through OpenExistentialExpr in checkIgnoreExpr() #21833

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 14, 2019
Merged

[Sema] Look through OpenExistentialExpr in checkIgnoreExpr() #21833

merged 1 commit into from
Jan 14, 2019

Conversation

theblixguy
Copy link
Collaborator

@theblixguy theblixguy commented Jan 13, 2019

This PR fixes an issue where the DiscardableResultAttr would be ignored if the sub-expression of an OptionalEvaluationExpr was an OpenExistentialExpr.

Example:

protocol FooProtocol {}

extension FooProtocol {
  @discardableResult
  static func returnSomething() -> Bool? {
    return true
  }
}

class Foo {
  var myOptionalFooProtocol: FooProtocol.Type?

  func doSomething() {
    myOptionalFooProtocol?.returnSomething() // Expression of type 'Bool?' is unused
  }
}

Resolves SR-9646.

@theblixguy
Copy link
Collaborator Author

cc @jrose-apple @slavapestov @xedin

Copy link
Contributor

@xedin xedin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

I noticed all of indentation commits across your PRs. Here is the workflow I suggest - there is git-clang-format in llvm project, if you compiling your project with -r add following to your PATH - <path-to-swift-directory>/swift/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/bin so you can do git clang-format <filename>? (for debug (-d) default build directory name is - Ninja-DebugAssert).

When I'm working on something and about to commit I git add all of the modified files and do git clang-format, add re-formatted files and commit.

If you already made a commit but to format code you do git commit --amend and (force) push changes to your branch. You can also use git squash HEAD~2 if you have formatting commit directly after changes.

@xedin
Copy link
Contributor

xedin commented Jan 14, 2019

@theblixguy Want to try squashing re-ident + name update into first commit before we merge?

@theblixguy
Copy link
Collaborator Author

@xedin done :)

@xedin
Copy link
Contributor

xedin commented Jan 14, 2019

@swift-ci please smoke test

@theblixguy
Copy link
Collaborator Author

All tests have passed ✅ @xedin

@xedin xedin merged commit e320fa7 into swiftlang:master Jan 14, 2019
@theblixguy theblixguy deleted the fix/SR-9646 branch January 14, 2019 06:50
@jrose-apple
Copy link
Contributor

I wonder if this was originally deliberate, to remind people to check whether the action actually occurred, but that's not actually so useful in practice. Thanks, @theblixguy!

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