Clang auto-attaching @discardableResult attribute on imported declarations


(Pär Strindevall) #1

Hey!

I got sick of having to assign unused results with _ = when using Objective-C dependencies so I decided to fork and fix the one I was using before finishing the line. When I searched for solutions to the problem I stumbled upon SE-0047 here: https://bugs.swift.org/browse/SR-1052

I noted that suggested patch 3 was to change the clang importer to attach @discardableResult automatically to imported declarations like the one I was using. Did this not happen? Is there any way for me to suppress the warnings that flood Xcode when not assigning unused results to nada if the dependency I’m bleep-blooping with is implemented in Objective-C?

Swiftly,

Pär Strindevall


(Chris Lattner) #2

Hi Pär,

I’m confused what you’re saying. If I understand you correctly, you’re saying that you’re interfacing with ObjC code and getting a bunch of warnings saying that you’re ignoring the results of calls to these functions. If that is the case, then there is certainly a compiler bug at work. Can you provide an example that reproduces this behavior? If I’m misunderstanding the situation, please clarify. Thanks!

-Chris

···

On Oct 21, 2016, at 4:55 AM, Pär Strindevall via swift-evolution <swift-evolution@swift.org> wrote:

Hey!

I got sick of having to assign unused results with _ = when using Objective-C dependencies so I decided to fork and fix the one I was using before finishing the line. When I searched for solutions to the problem I stumbled upon SE-0047 here: https://bugs.swift.org/browse/SR-1052

I noted that suggested patch 3 was to change the clang importer to attach @discardableResult automatically to imported declarations like the one I was using. Did this not happen? Is there any way for me to suppress the warnings that flood Xcode when not assigning unused results to nada if the dependency I’m bleep-blooping with is implemented in Objective-C?