[swift-evolution] [discussion] What generics feature would this be?

Mathew Huusko V mhuusko5 at gmail.com
Wed Aug 9 09:18:05 CDT 2017

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)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170809/1b853e6c/attachment.html>

More information about the swift-evolution mailing list