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-7312] Conforming to protocol using constrained generic #49860

Closed
swift-ci opened this issue Mar 30, 2018 · 0 comments
Closed

[SR-7312] Conforming to protocol using constrained generic #49860

swift-ci opened this issue Mar 30, 2018 · 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 Mar 30, 2018

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

Apple Swift version 4.1 (swiftlang-902.0.48 clang-902.0.39.1)

MacOS High Sierra 10.13.3

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

md5: 5f5dcbf98e3828cb5594b010415dac60

duplicates:

  • SR-522 Protocol funcs cannot have covariant returns

Issue Description:

I would expect this to compile:

protocol A {}  
protocol B {    
    var a: A { get }   
}
class C<T: A>: B {  
    var a: T
    init(a: T) {  
        self.a = a  
    }  
}

Instead I get a compiler warning: C<T> does not conform to protocol B. Note that T: A.

If I change the definition of C to:

class C<T: A>: B {
    var a: A
    init(a: T) {
        self.a = a
    }
}

then all is well.

@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 compiler The Swift compiler in itself 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