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-8490] objc readonly property overriden to readwrite in subclass incorrectly bridged as get-only (Swift 4.2 regression) #51011

Closed
bobergj opened this issue Aug 8, 2018 · 6 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself regression swift 4.2

Comments

@bobergj
Copy link

bobergj commented Aug 8, 2018

Previous ID SR-8490
Radar rdar://problem/43057062
Original Reporter @bobergj
Type Bug
Status Closed
Resolution Done

Attachment: Download

Environment

Xcode 10.0 beta 5 (10L221o)

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

md5: 263f93699fc38d78453e79f78753428c

Issue Description:

Given a objc base class that has a readonly property and also conforms to ProtocolA:

@interface ClassA : NSObject <ProtocolA>
@property (readonly, nonatomic, nullable) NSString *aProperty;
@end

Where ProtocolA defines a getter for a property:

@protocol ProtocolA
- (nullable NSString *)aProperty;
@end

A subclass that redefines the property as readwrite:

@interface ClassB : ClassA
@property (readwrite, nonatomic, nullable) NSString *aProperty;
@end

The property is incorrectly bridged to readonly in Swift:

let classB = ClassB()
classB.aProperty = "foo" // Error: Cannot assign to property: 'aProperty' is a get-only property

This is a regression from Swift 4 / Xcode 9.4.1 (9F2000) where the property is bridged as readwrite.

Attached sample project that includes the code above.

@belkadan
Copy link
Contributor

belkadan commented Aug 8, 2018

Thanks, Jonas!

@swift-ci create

@belkadan
Copy link
Contributor

belkadan commented Aug 8, 2018

The protocol is relevant, too. I guess we're refusing to import the "conflicting" property before realizing that there's one in the superclass anyway.

@belkadan
Copy link
Contributor

#18749

@bobergj
Copy link
Author

bobergj commented Sep 13, 2018

@belkadan: I still see this issue in Xcode 10 GM - Version 10.0 (10A254a). Perhaps the commit was simply to late to be included in the release branch? But I am not sure which release branch to check.

@belkadan
Copy link
Contributor

That's correct, the fix did not make it into the release branch. Sorry for the trouble.

@AnnaZaks
Copy link
Mannequin

AnnaZaks mannequin commented Jul 23, 2019

@bobergj, Could you verify if the problem is fixed and if so move the JIRA to "Closed"?

Thanks!
Anna

@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 regression swift 4.2
Projects
None yet
Development

No branches or pull requests

3 participants