Jon_Shier
(Jon Shier)
1
Swifters:
I just encountered the error “Superclass constraint ‘RepeatableNetworkOperation<U>’ cannot depend on a type parameter” on this definition:
class RepeatedNetworkOperation<T, U where U: Decodable, U == U.DecodedType, U: Repeatable, T: RepeatableNetworkOperation<U>>: RepeatedOperation<T> { … }
where the relevant other classes are defined as:
class InterruptibleNetworkOperation<T: Decodable where T == T.DecodedType>: GroupOperation { … }
class RepeatedOperation<T where T: NSOperation>: GroupOperation { … }
class RepeatableNetworkOperation<T where T: Decodable, T == T.DecodedType, T: Repeatable>: InterruptibleNetworkOperation<T>, Repeatable { … }
I understand the error, but am I correct in thinking this is just a limitation of Swift’s current type and/or generics systems? I’m not a language theorist, but it seems perfectly reasonable that something like this should work. If it is just a limitation and not something I’m doing wrong, are there any suggestions for a workaround? The class I’m trying to write would really clean up my code.
Jon
Hi Jon,
You are right that this is a limitation of the current implementation in Swift 2.2. I may have fixed this recently in master:
It would be great if you could try the latest compiler with your code.
Slava
···
On Mar 9, 2016, at 12:48 PM, Jon Shier via swift-users <swift-users@swift.org> wrote:
Swifters:
I just encountered the error “Superclass constraint ‘RepeatableNetworkOperation<U>’ cannot depend on a type parameter” on this definition:
class RepeatedNetworkOperation<T, U where U: Decodable, U == U.DecodedType, U: Repeatable, T: RepeatableNetworkOperation<U>>: RepeatedOperation<T> { … }
where the relevant other classes are defined as:
class InterruptibleNetworkOperation<T: Decodable where T == T.DecodedType>: GroupOperation { … }
class RepeatedOperation<T where T: NSOperation>: GroupOperation { … }
class RepeatableNetworkOperation<T where T: Decodable, T == T.DecodedType, T: Repeatable>: InterruptibleNetworkOperation<T>, Repeatable { … }
I understand the error, but am I correct in thinking this is just a limitation of Swift’s current type and/or generics systems? I’m not a language theorist, but it seems perfectly reasonable that something like this should work. If it is just a limitation and not something I’m doing wrong, are there any suggestions for a workaround? The class I’m trying to write would really clean up my code.
Jon
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users
Jon_Shier
(Jon Shier)
3
Slava:
I won’t be able to test my actual code, as the Operations and Alamofire libraries haven’t been updated for Swift 3 (which I wouldn’t expect), but I’ll try to put together a test cast that is similar and see if it works? When will this change be part of the package I can download for Xcode 7.3?
Jon
···
On Mar 17, 2016, at 1:01 PM, Slava Pestov <spestov@apple.com> wrote:
Hi Jon,
You are right that this is a limitation of the current implementation in Swift 2.2. I may have fixed this recently in master:
ArchetypeBuilder: Allow generic signature superclass constraints to c… · apple/swift@3aacf5d · GitHub
It would be great if you could try the latest compiler with your code.
Slava
On Mar 9, 2016, at 12:48 PM, Jon Shier via swift-users <swift-users@swift.org <mailto:swift-users@swift.org>> wrote:
Swifters:
I just encountered the error “Superclass constraint ‘RepeatableNetworkOperation<U>’ cannot depend on a type parameter” on this definition:
class RepeatedNetworkOperation<T, U where U: Decodable, U == U.DecodedType, U: Repeatable, T: RepeatableNetworkOperation<U>>: RepeatedOperation<T> { … }
where the relevant other classes are defined as:
class InterruptibleNetworkOperation<T: Decodable where T == T.DecodedType>: GroupOperation { … }
class RepeatedOperation<T where T: NSOperation>: GroupOperation { … }
class RepeatableNetworkOperation<T where T: Decodable, T == T.DecodedType, T: Repeatable>: InterruptibleNetworkOperation<T>, Repeatable { … }
I understand the error, but am I correct in thinking this is just a limitation of Swift’s current type and/or generics systems? I’m not a language theorist, but it seems perfectly reasonable that something like this should work. If it is just a limitation and not something I’m doing wrong, are there any suggestions for a workaround? The class I’m trying to write would really clean up my code.
Jon
_______________________________________________
swift-users mailing list
swift-users@swift.org <mailto:swift-users@swift.org>
https://lists.swift.org/mailman/listinfo/swift-users