-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Open
Labels
ownershipFeature: Ownership modifiers and semanticsFeature: Ownership modifiers and semantics
Description
Suppose I have a custom sequence type like
public struct MySequence<Element: ~Escapable> {
@inlinable
public func forEach<Error>(_ body: (Element) throws(Error) -> Void) throws(Error) {
fatalError("TODO")
}
}Now, I would naïvely write this as follows
public protocol MySequenceProtocol {
associatedtype Element: ~Copyable // error: Cannot suppress 'Copyable' requirement of an associated type
func forEach(_ body: (Element) -> Void)
}Removing the ~Copyable constraint on the associated type gives me the following errors:
public struct MySequence<Element: ~Escapable>: MySequenceProtocol { // error: type 'MySequence<Element>' does not conform to protocol 'MySequenceProtocol'
@inlinable
public func forEach(_ body: (Element) -> Void) { // note: note: candidate can not infer 'Element' = 'Element' because 'Element' is not a nominal type and so can't conform to 'Escapable'
fatalError("TODO")
}
}As far as I can tell, there’s no way to model this at the moment.
Metadata
Metadata
Assignees
Labels
ownershipFeature: Ownership modifiers and semanticsFeature: Ownership modifiers and semantics