A existential type of some protocol `P`, counterintuitively, doesn't conform to itself, unless it's an Objective-C protocol.
Because `S : Special` means S has to be a type that conforms to the protocol `Special`, and `special` is of the existential type `Special`, the existential type `Special` doesn't conform to the protocol `Special`, so it can't be used for `S`. Best, Austin > On Aug 9, 2017, at 7:19 AM, Mathew Huusko V via swift-evolution > <[email protected]> wrote: > > > Curious what part of generics the below would fall under? This hit me by > surprise/makes even non-generic/Self-depending protocols un-interchangeable > with classes.. > > ``` > protocol Special {} > > func doWithAndReturn<S: Special>(_ special: S) -> S { ... } > > let special: Special = ... > > // "error: Generics parameter 'S' could not be inferred" > // works fine when 'Special' is a class > let newSpecial: Special = doWithAndReturn(special) > ``` > _______________________________________________ > swift-evolution mailing list > [email protected] > https://lists.swift.org/mailman/listinfo/swift-evolution _______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
