[swift-users] Compiler crashes while resolving generics constraints

Игорь Никитин devnikor at icloud.com
Sun Dec 25 12:05:05 CST 2016


I have few protocols with associated types:
protocol Remote {
    associatedtype Credentials: RemoteCredentials

    static var url: URI { get }
    static var name: String { get }
    static var credentials: Credentials.Type { get }
protocol RemoteAuthenticating {
    associatedtype Remote: App.Remote

    func authenticate(with credentials: Remote.Credentials) throws -> (RemoteUser, ResponseRepresentable?)
protocol RemoteAuthenticationServiceBuilder {
    associatedtype Service: RemoteAuthenticating

    // TODO: `Service.Remote` should be constrained to `Remote` but compiler crashes
    func authenticationService<Remote: App.Remote>(for: Remote.Type) -> Service? // where Service.Remote == Remote
It works fine until I uncomment the last where statement
If I trying to constraint Service.Remote type compiler will crash with segfault 11
I can guess that it's a compiler bug, but maybe I’m using generics in wrong way?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20161225/a5d28c49/attachment.html>

More information about the swift-users mailing list