Skip to content

Conversation

@DougGregor
Copy link
Member

A throwing method can only be exposed to Objective-C if we can map the
return type convention, either because the return type is Void or
because it is something that is bridged to an object type (and can
therefore be nil to indicate error). Our predicate for checking
"bridged to an object type" didn't account for value types that are
exposed to (or come from) C, and therefore aren't actually bridged to
object types in the Objective-C thunk, meaning they cannot be
optional. An existing hack dealt with the largest class of
these---types like Int and Bool that can be dynamically bridged
to NSNumber---but generalize this by checking exactly how the result
type is going to be represented in Objective-C, rejecting @objc for
cases where the result type won't be an object type.

Resolves rdar://problem/28035614.

… thunk to be @objc.

A throwing method can only be exposed to Objective-C if we can map the
return type convention, either because the return type is Void or
because it is something that is bridged to an object type (and can
therefore be nil to indicate error). Our predicate for checking
"bridged to an object type" didn't account for value types that are
exposed to (or come from) C, and therefore aren't actually bridged to
object types in the Objective-C thunk, meaning they cannot be
optional. An existing hack dealt with the largest class of
these---types like Int and Bool that can be dynamically bridged
to NSNumber---but generalize this by checking exactly how the result
type is going to be represented in Objective-C, rejecting '@objc' for
cases where the result type won't be an object type.

Fixes rdar://problem/28035614 for real.

(cherry picked from commit cba7eb9)
@DougGregor DougGregor added this to the Swift 3.0 milestone Sep 7, 2016
@DougGregor
Copy link
Member Author

@swift-ci please test macOS

@DougGregor
Copy link
Member Author

@jrose-apple , mind taking a look?

@DougGregor
Copy link
Member Author

@rudkx , you might be interested in this

@jrose-apple
Copy link
Contributor

Huh. Are there any other places left over where we're not using the centralized checking? (LGTM.)

@DougGregor
Copy link
Member Author

This was the last use of use of getBridgedToObjC() in the @objc validation logic, at least.

@rudkx
Copy link
Contributor

rudkx commented Sep 7, 2016

👍

@tkremenek tkremenek merged commit 14df2a5 into swiftlang:swift-3.0-branch Sep 7, 2016
@DougGregor DougGregor deleted the objc-throwing-inference branch September 7, 2016 17:45
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.

4 participants