How does ArrayLiteralElement get defaulted in SetAlgebra?

The SetAlgebra protocol refines Equatable and ExpressibleByArrayLiteral. There is a default implementation when the set's and array-literal's element types are the same. I just made up a set type and had "public typealias ArrayLiteralElement = Element" in it to get the provided implementation. I then commented out the line, and everything still worked, without a request to define ArrayLiteralElement. I did a search over the SetAlgebra file and the entire repository, and I don't see how an unspecified ALE gets a default assignment to Element.

That's exactly how it gets defaulted to that type:

The where clause is simply ignored. :face_with_head_bandage:

For more information on that read this thread:


Are there any further stdlib development related questions, otherwise I'd move this thread into #swift-users?!

I agree with you in that thread; it looks like a mis-feature where the compiler is being too smart. The line looks descriptive, and almost always is, but here (and only when there's exactly one such extension) it's being proscriptive.

Terms of Service

Privacy Policy

Cookie Policy