[swift-evolution] Protocol conformance error
Saagar Jha
saagar at saagarjha.com
Wed Jan 17 02:42:54 CST 2018
If we have:
class N: A {}
you can pass an N into C’s test(x:), since N is an A, but not M’s test(x:), since N is not a B. Thus, it’s not a valid conformance.
Saagar Jha
> On Jan 17, 2018, at 00:04, Roshan via swift-evolution <swift-evolution at swift.org> wrote:
>
> Hi,
>
> Cross posting from swift-users in case this behaviour isn't part of
> the language and might be interesting to you folks.
>
> Here is some sample code that gives a protocol conformance error in a
> playground:
>
> protocol A {}
> protocol B: A {}
>
> protocol C {
> func test(x: A)
> }
>
> class M: C {
> func test(x: B) {}
> }
>
> Is there a reason why the compiler doesn't infer that ((B) -> ())
> matches ((A) -> ()) because of inheritance?
>
> --
> Warm regards
> Roshan
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20180117/2037590a/attachment.html>
More information about the swift-evolution
mailing list