What are you trying to accomplish here, more concretely?

My first thought is that you shouldn't implement the same function in both
a protocol extension and a conforming class. Why not just give them
different names and call the function from within the extension instead of
from the class? E.g.

protocol FooPro {

    func _fooFunc()

}


extension FooPro {

    func fooFunc() {

        print("fooFunc default")

        _fooFunc()

    }

}


class FooClass: FooPro {

    func _fooFunc() {

        print("fooFunc FooClass")

    }

}


let fc = FooClass()

fc.fooFunc()

Dan

On Tue, Nov 15, 2016 at 4:28 PM, Rick Mann via swift-users <
swift-users@swift.org> wrote:

> The following gives Xcode 8.1 a very hard time. Eventually I get a Bad
> Access on the last line. I'm guessing it's a recursive call. Is there any
> way to call the default implementation from a "real" implementation?
>
> protocol FooPro
> {
>         func fooFunc()
> }
>
> extension FooPro
> {
>         func
>         fooFunc()
>         {
>                 print("fooFunc default")
>         }
> }
>
> class FooClass : FooPro
> {
>         func
>         fooFunc()
>         {
>                 (self as FooPro).fooFunc()
>                 print("fooFunc FooClass")
>         }
> }
>
> let fc: FooPro = FooClass()
> fc.fooFunc()
>
>
> Thanks!
>
>
> --
> Rick Mann
> rm...@latencyzero.com
>
>
> _______________________________________________
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to