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

bobergj opened this issue Aug 8, 2018 · 6 comments


Copy link

@bobergj bobergj commented Aug 8, 2018

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

Attachment: Download


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;

Where ProtocolA defines a getter for a property:

@protocol ProtocolA
- (nullable NSString *)aProperty;

A subclass that redefines the property as readwrite:

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

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.

Copy link

@belkadan belkadan commented Aug 8, 2018

Thanks, Jonas!

@swift-ci create

Copy link

@belkadan 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.

Copy link

@belkadan belkadan commented Aug 16, 2018

Copy link

@bobergj 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.

Copy link

@belkadan belkadan commented Sep 13, 2018

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

Copy link

@AnnaZaks AnnaZaks mannequin commented Jul 23, 2019

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


@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
None yet

No branches or pull requests

2 participants