Skip to content
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

[SR-2344] Objective-C properties & methods with nullable NS_EXTENSIBLE_STRING_ENUM types can't be overridden in Swift #44951

Closed
swift-ci opened this issue Aug 15, 2016 · 2 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-2344
Radar rdar://problem/27855806
Original Reporter rydermackay (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Xcode 8.0 beta 6 (8S201h)

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, ClangImporter
Assignee @belkadan
Priority Medium

md5: aaf7ef6e6f9c50f435ac1314f3009bb6

Issue Description:

According to SE-0033, attribute((swift_wrapper(enum))) and attribute((swift_wrapper(struct))) Objective-C types should be transparently bridged to Swift and back. However, attempting to override Objective-C methods and properties that contain nullable "string enum" parameters or return values results in a "type cannot be represented in Objective-C" error:

typedef NSString * UIActivityType NS_EXTENSIBLE_STRING_ENUM;
@interface UIActivity : NSObject
@property(nonatomic, readonly, nullable) UIActivityType activityType;
// more declarations…
@end

class CopyActivity: UIActivity {
    // Property cannot be an @objc override because its type cannot be represented in Objective-C
    // '@objc' getter for non-'@objc' property
    // adding '@nonobjc' fixes the error, but the method isn't called at runtime
    override var activityType: UIActivityType? {
        return UIActivityType("com.example.Copy")
    }

    // overriding with a non-optional works
    override var activityType: UIActivityType {
        return UIActivityType("com.example.Copy")
    }
}

SE-0033: https://github.com/apple/swift-evolution/blob/master/proposals/0033-import-objc-constants.md

@belkadan
Copy link
Contributor

#4337

@belkadan
Copy link
Contributor

Merged into the Swift 3 branch in #4360

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

2 participants