The optimized-build behavior of UnsafeBufferPointer bounds/overflow
checking cannot be tested. The standard library always compiles with debug
checking enabled, so the behavior of the optimized test depends on whether
the inlining heuristics decide to inline these methods. To fix this, we need
a way to force @_inlineable UnsafeBufferPointer methods to be emitted inside
the client code, and thereby subject the stdlib implementation to the test
case's compile options.
The various _*Indexable protocols only exist to work around the lack of
recursive protocol constraints. Eliminate all of the *_Indexable protocols,
collapsing their requirements into the corresponding Collection protocol
(e.g., _MutableIndexable —> Collection).
This introduces a number of extraneous requirements into the various
Collection protocols to work around bugs in associated type
inference. Specifically, to work around the lack of "global" inference
of associated type witnesses. These hacks were implicitly present in
the *Indexable protocols; I've made marked them as ABI FIXMEs here so
we can remove them when associated type inference improves.
Fixes rdar://problem/21935030 and a number of ABI FIXMEs in the library.
Rather than using the default slice type when slicing the collection produced
by a lazy map or filter, slice the base collection and form a new
lazy map/filter collection from it. This allows any optimizations provided by
the collection SubSequence type to kick in, as well as ensuring that slicing
a lazy collection provides the same type as producing a lazy collection of a
slice.
This is technically source-breaking, because someone could have spelled out
the types of slicing a lazy filter or map… but it seems unlikely to matter
in practice and the benefits could be significant.
Fixes ABI FIXME’s #28 and #46.
Strideable declares a default witness for Equatable and Comparable
extension Strideable {
@_inlineable
public static func < (x: Self, y: Self) -> Bool {
return x.distance(to: y) > 0
}
@_inlineable
public static func == (x: Self, y: Self) -> Bool {
return x.distance(to: y) == 0
}
}
This witness is implemented recursively because the expectation
is that Stride != Self. However, it is possible to implement
SignedNumeric and Strideable together and inherit this conformance
which will cause undefined behavior - usually a crash.
Provide an overload when Stride == Self and crash with custom message
that mentions that Equatable and Comparable have to be implemented
in this case.
- It's better than nothing.
* Unify the capitalization across all user-visible error messages (fatal errors, assertion failures, precondition failures) produced by the runtime, standard library and the compiler.
* Update some more tests to the new expectations.