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-7398] Preserve availability on ObjC subscript getters and setters #49941

Closed
belkadan opened this issue Apr 10, 2018 · 4 comments
Closed

[SR-7398] Preserve availability on ObjC subscript getters and setters #49941

belkadan opened this issue Apr 10, 2018 · 4 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself good first issue Good for newcomers

Comments

@belkadan
Copy link
Contributor

Previous ID SR-7398
Radar rdar://problem/18636764
Original Reporter @belkadan
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, ClangImporter, StarterBug
Assignee @ChristopherRogers
Priority Medium

md5: f62fe61cb3743b3aba8e5875b9480892

relates to:

  • SR-7201 Setter should support @available

Issue Description:

@import Foundation;

@interface DeprecatedGetter: NSObject
- (id)objectAtIndexedSubscript:(NSInteger)i __attribute__((deprecated("bad getter")));
- (void)setObject:(id)obj atIndexedSubscript:(NSInteger)i;
@end

@interface DeprecatedSetter: NSObject
- (id)objectAtIndexedSubscript:(NSInteger)i;
- (void)setObject:(id)obj atIndexedSubscript:(NSInteger)i __attribute__((deprecated("bad setter")));
@end

When the Objective-C code above is imported into Swift, the methods are mapped to a true subscript declaration. However, any availability attributes on the original methods are lost…or rather, the getter's availability is copied onto the subscript, but not the setter's.

The relevant functions here are buildSubscriptGetterDecl and buildSubscriptSetterDecl in ClangImporter.cpp; these functions should call Impl.importAttributes to get the correct attributes for the getter and setter. We also need to figure out what's pulling the getter's availability onto the subscript; that's not really correct if the getter is deprecated but the setter is not.

Tests for this would look something like b0e12f4#diff-348ce3800f609e6140007f774b227469R874.

@belkadan
Copy link
Contributor Author

A bit complicated for a StarterBug. Maybe good for someone's second compiler bug?

@ChristopherRogers
Copy link
Contributor

#17105

@belkadan
Copy link
Contributor Author

Ah, please don't mark a bug as Resolved until after the PR gets merged! (Sometimes people have to leave their PR in the middle of review for whatever reason.)

@ChristopherRogers
Copy link
Contributor

Thanks for clearing that up. I wasn't sure how to interpret the description in the tooltip. I assumed I was the developer in this case and you would close it once merged.

@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 good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants