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-2693] Cannot assign to property of an instance of a class declared in a protocol extension #45298

Closed
swift-ci opened this issue Sep 19, 2016 · 0 comments

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Sep 19, 2016

Previous ID SR-2693
Radar None
Original Reporter broadway_lamb (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate
Environment

macOS, Swift 3.0 (release), XCode 8

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: bfa278005f843cb192490c7098e9ff0c

duplicates:

  • SR-142 mutating function in protocol extension erroneously requires var declaration of class variables

Issue Description:

This code:

protocol Bar {}

extension Bar {
    var property: String {
        get {
            return ""
        }
        set {
            
        }
    }
}

class Foo: Bar {}

let foo = Foo()

foo.property = "?!" // error: cannot assign to property: 'foo' is a 'let' constant

will not compile, but it should.

The thing is, if foo were of type Bar, then I would have had to make Bar a class-only protocol in order to make it compile. But foo is of type Foo.

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

No branches or pull requests

1 participant