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-2704] T: Protocol generic constraint doesn't accept protocol existentials #45308

Closed
swift-ci opened this issue Sep 20, 2016 · 0 comments
Closed
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

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

swift 3.0, both in xcode 8 and in the swiftc 3 toolchain.

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

md5: 2e6e3deb4b4efc9e73cefa9c355867b0

duplicates:

  • SR-55 non-@objc protocol existentials do not conform to their own protocol type

Issue Description:

I would expect the following to compile. The protocol used as an existential type should also conform to the constraint given in the generic function concrete.

However, it gives the error: error: cannot invoke 'concrete' with an argument list of type '(P)'

protocol P {
    func go()
}

extension String: P {
    func go() {
        print("String")
    }
}
extension Int: P {
    func go() {
        print("Int")
    }
}

func concrete<T: P>(_ a: T) {
    a.go()
}

func abstract(a: P) {
    concrete(a)
}
@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 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

1 participant