> On Sep 8, 2015, at 4:18 AM, has <hengist.p...@virgin.net> wrote:
> 
> But after adding a protocol to supply this information, SourceKit and swiftc 
> crash upon reading the code:
> 
> 
>     protocol Object {
>         init()
>     }
> 
>     class MyObject<T: Object> {
>         required init() {}
>         func foo() -> T { T() }
>     }
> 
>     class YourObject: MyObject<YourObject>, Object {
>         required init() {}
>     }
> 
>     let obj = YourObject()

That’s true; however, adding a second “YourObjectProt" protocol, making 
YourObject conform to it, adding all of YourObject’s methods into the protocol, 
and using YourObjectProt as the parameter instead of YourObject, will solve the 
issue.

Swift wants you to use protocols rather than objects anyway, so perhaps the way 
to go is to put all the logic in the protocols and protocol extensions, and 
make MyObject, YourObject, etc, just bare-bones objects (or structs) that just 
belong to the protocol and don’t do anything else.

Charles

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to