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-5266] Swift protocol doesn't compile when using a subclass in the property implementation #47841

Closed
swift-ci opened this issue Jun 20, 2017 · 0 comments
Labels
compiler The Swift compiler in itself conformances Feature → protocol: protocol conformances duplicate Resolution: Duplicates another issue feature A feature request or implementation improvement protocol Feature → type declarations: Protocol declarations type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Jun 20, 2017

Previous ID SR-5266
Radar None
Original Reporter yariv (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate

Attachment: Download

Environment

Xcode 9 beta, Swift 3.2

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

md5: d50728b6922dd2c2c5a9a28b1ece2df2

duplicates:

  • SR-522 Protocol funcs cannot have covariant returns

Issue Description:

The following code should compile:

class Animal {
    func talk(to: Animal) {}
}

protocol AnimalShelter {
    var animal: Animal { get }
}

class Dog: Animal {
    func bark() {}
}

class DoggyShelter: AnimalShelter {
    var animal = Dog()
    
    func goTo(shelter: AnimalShelter) {
        animal.talk(to: shelter.animal)
    }
}
@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added duplicate Resolution: Duplicates another issue feature A feature request or implementation type checker Area → compiler: Semantic analysis conformances Feature → protocol: protocol conformances protocol Feature → type declarations: Protocol declarations improvement and removed bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. labels Jan 27, 2023
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler The Swift compiler in itself conformances Feature → protocol: protocol conformances duplicate Resolution: Duplicates another issue feature A feature request or implementation improvement protocol Feature → type declarations: Protocol declarations type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

2 participants