You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SR-5479 protocol associatedtype where-clause rules not consistent with direct colon constraint rules
relates to:
SR-6225 Swift compiler crashes if two protocols refer the type of each other spreat around diffenrent files.
SR-4979 SubSequence is not a Sequence, can't be zipped?
Issue Description:
From the Generics Manifesto:
Currently, an associated type cannot be required to conform to its enclosing protocol (or any protocol that inherits that protocol). For example, in the standard library SubSequence type of a Sequence should itself be a Sequence:
protocolSequence {
associatedtypeIterator : IteratorProtocol
...
associatedtypeSubSequence : Sequence// currently ill-formed, but should be possible
}
The compiler currently rejects this protocol, which is unfortunate: it effectively pushes the SubSequence-must-be-a-Sequence requirement into every consumer of SubSequence, and does not communicate the intent of this abstraction well.
The text was updated successfully, but these errors were encountered:
This code currently compiles, but it is impossible to create an instance of `Foo` since you cannot write a type that is parameterized by itself. I guess I would also expect recursive typealiases to work as well.
What is the status on this? Seems a critical piece to the generic puzzle. 🙂
Code from a library I'm writing:
public protocol QueryBridgeable {
associatedtype Base = Self where Base : Queryable & QueryBridgeable
var query:QueryFactory<Base> { get } // Error "'query' used within its own type"
func query(_ options:SubQueryOptions) -> QueryFactory<Base>
}
All items that are "query bridgeable" should be able to generate ("query") items that are themselves "query bridgeable" so they have access to the same interface.
I'm going to mark this as "done" for now. While there are some known bugs (including non-trivial ones!), we've rolled out the feature in the standard library and developers should be able to use it in Swift 4.1.
Additional Detail from JIRA
md5: 4b84506f25ece4c8bff8423d20b24de5
blocks:
is duplicated by:
relates to:
Issue Description:
From the Generics Manifesto:
Currently, an associated type cannot be required to conform to its enclosing protocol (or any protocol that inherits that protocol). For example, in the standard library SubSequence type of a Sequence should itself be a Sequence:
The compiler currently rejects this protocol, which is unfortunate: it effectively pushes the SubSequence-must-be-a-Sequence requirement into every consumer of SubSequence, and does not communicate the intent of this abstraction well.
The text was updated successfully, but these errors were encountered: