Re: Swift generics, circular type declarations, and segfaults, oh my!
Re: Swift generics, circular type declarations, and segfaults, oh my!
- Subject: Re: Swift generics, circular type declarations, and segfaults, oh my!
- From: Charles Srstka <email@hidden>
- Date: Tue, 08 Sep 2015 10:38:40 -0500
> On Sep 8, 2015, at 4:18 AM, has <email@hidden> 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 (email@hidden)
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:
This email sent to email@hidden
References: | |
| >Swift generics, circular type declarations, and segfaults, oh my! (From: has <email@hidden>) |
| >Re: Swift generics, circular type declarations, and segfaults, oh my! (From: Fritz Anderson <email@hidden>) |
| >Re: Swift generics, circular type declarations, and segfaults, oh my! (From: has <email@hidden>) |
| >Re: Swift generics, circular type declarations, and segfaults, oh my! (From: Quincey Morris <email@hidden>) |
| >Re: Swift generics, circular type declarations, and segfaults, oh my! (From: has <email@hidden>) |
| >Re: Swift generics, circular type declarations, and segfaults, oh my! (From: Quincey Morris <email@hidden>) |
| >Re: Swift generics, circular type declarations, and segfaults, oh my! (From: Charles Srstka <email@hidden>) |
| >Re: Swift generics, circular type declarations, and segfaults, oh my! (From: has <email@hidden>) |
| >Re: Swift generics, circular type declarations, and segfaults, oh my! (From: Quincey Morris <email@hidden>) |
| >Re: Swift generics, circular type declarations, and segfaults, oh my! (From: Charles Srstka <email@hidden>) |
| >Re: Swift generics, circular type declarations, and segfaults, oh my! (From: has <email@hidden>) |