mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
The standard library has two versions of the `abs(_:)` function: ``` func abs<T : SignedNumeric>(_ x: T) -> T where T.Magnitude == T func abs<T : SignedNumeric & Comparable>(_ x: T) -> T ``` The first is more specialized than the second because `T.Magnitude` is known to conform to `Comparable`. Indeed, it’s a more specialized implementation that returns `magnitude`. However, this overload behaves oddly: in the expression `abs(-8)`, the type checker will pick the first overload because it is more specialized. That’s a general guiding principle for overloading: pick the most specialized overload that works. However, to select that overload, it needs to pick a type for the literal “8” for which that overload works, and it chooses `Double`. The “obvious” answer, `Int`, doesn’t work because `Int.Magnitude == UInt`. There is a conflict between the two rules, here: we prefer more-specialized overloads (but we’ll fall back to less-specialized if those don’t work) and we prefer to use `Int` for integer literals (but we’ll fall back to `Double` if it doesn’t work). We have a few options from a type-checker perspective: 1. Consider the more-specialized-function rule to be more important 2. Consider the integer-literals-prefer-`Int` rule to be more important 3. Call the result ambiguous and make the user annotate it The type checker currently does #1, although at some point in the past it did #2. Moving forward, #1 is a better choice because it prunes the number of overloads that need to be considered: if the more-specialized overload succeeds its type-check, the others need not be considered. It’s also easier to reason about than the literal-scoring approach, because there can be a direct definition for “more specialized than” that can be reasoned about. I think we should dodge the issue by removing the more-specialized version of `abs(_:)`. Its use of `magnitude` seems unlikely to provide a significant performance benefit, and the presence of overloading either forces us to consider both overloads always (which is bad for type checker performance) or accept the regression that `abs(-8)` is `Double`. Better to eliminate the overloading and, if needed in the future, find a better way to introduce the more-specialized implementation without it being a separate signature. Fixes rdar://problem/42345366.
216 lines
17 KiB
Plaintext
216 lines
17 KiB
Plaintext
|
|
/* Generic Signature Changes */
|
|
Protocol Numeric has generic signature change from <Self : Equatable, Self : ExpressibleByIntegerLiteral, Self.Magnitude : Comparable, Self.Magnitude : Numeric> to <Self : AdditiveArithmetic, Self : ExpressibleByIntegerLiteral, Self.Magnitude : Comparable, Self.Magnitude : Numeric>
|
|
Protocol StringProtocol has generic signature change from <Self : BidirectionalCollection, Self : Comparable, Self : ExpressibleByStringLiteral, Self : Hashable, Self : LosslessStringConvertible, Self : TextOutputStream, Self : TextOutputStreamable, Self.Element == Character, Self.Index == String.Index, Self.SubSequence : StringProtocol, Self.UTF16View : BidirectionalCollection, Self.UTF8View : Collection, Self.UnicodeScalarView : BidirectionalCollection, Self.UTF16View.Element == UInt16, Self.UTF16View.Index == String.Index, Self.UTF8View.Element == UInt8, Self.UTF8View.Index == String.Index, Self.UnicodeScalarView.Element == Unicode.Scalar, Self.UnicodeScalarView.Index == String.Index, Self.SubSequence.UTF16View.Index == String.Index, Self.SubSequence.UTF8View.Index == String.Index, Self.SubSequence.UnicodeScalarView.Index == String.Index> to <Self : BidirectionalCollection, Self : Comparable, Self : ExpressibleByStringInterpolation, Self : Hashable, Self : LosslessStringConvertible, Self : TextOutputStream, Self : TextOutputStreamable, Self.Element == Character, Self.Index == String.Index, Self.StringInterpolation == DefaultStringInterpolation, Self.SubSequence : StringProtocol, Self.UTF16View : BidirectionalCollection, Self.UTF8View : Collection, Self.UnicodeScalarView : BidirectionalCollection, Self.UTF16View.Element == UInt16, Self.UTF16View.Index == String.Index, Self.UTF8View.Element == UInt8, Self.UTF8View.Index == String.Index, Self.UnicodeScalarView.Element == Unicode.Scalar, Self.UnicodeScalarView.Index == String.Index, Self.SubSequence.UTF16View.Index == String.Index, Self.SubSequence.UTF8View.Index == String.Index, Self.SubSequence.UnicodeScalarView.Index == String.Index>
|
|
|
|
/* RawRepresentable Changes */
|
|
|
|
/* Removed Decls */
|
|
Constructor String.init(stringInterpolationSegment:) has been removed
|
|
Func Collection.prefix(through:) has been removed
|
|
Func Collection.prefix(upTo:) has been removed
|
|
Func Collection.suffix(from:) has been removed
|
|
Func Numeric.+(_:) has been removed
|
|
Func Numeric.+(_:_:) has been removed
|
|
Func Numeric.+=(_:_:) has been removed
|
|
Func Numeric.-(_:_:) has been removed
|
|
Func Numeric.-=(_:_:) has been removed
|
|
Func Sequence.filter(_:) has been removed
|
|
Func Sequence.forEach(_:) has been removed
|
|
Func Sequence.map(_:) has been removed
|
|
TypeAlias ExpressibleByStringInterpolation has been removed (deprecated)
|
|
Var AnyBidirectionalCollection.first has been removed
|
|
Var AnyBidirectionalCollection.last has been removed
|
|
Var AnyCollection.first has been removed
|
|
Var AnyRandomAccessCollection.first has been removed
|
|
Var AnyRandomAccessCollection.last has been removed
|
|
Var BidirectionalCollection.last has been removed
|
|
Var Collection.first has been removed
|
|
Var Dictionary.first has been removed
|
|
Var Set.first has been removed
|
|
Var String.characters has been removed (deprecated)
|
|
Var Substring.characters has been removed (deprecated)
|
|
|
|
TypeAlias Unicode.UTF16.EncodedScalar has underlying type change from _UIntBuffer<UInt32, UInt16> to _UIntBuffer<UInt16>
|
|
TypeAlias Unicode.UTF8.EncodedScalar has underlying type change from _ValidUTF8Buffer<UInt32> to _ValidUTF8Buffer
|
|
|
|
/* Moved Decls */
|
|
|
|
/* Renamed Decls */
|
|
|
|
/* Type Changes */
|
|
Constructor String.init(stringInterpolation:) has parameter 0 type change from [String] to DefaultStringInterpolation
|
|
Protocol BinaryFloatingPoint has added inherited protocol AdditiveArithmetic
|
|
Protocol BinaryInteger has added inherited protocol AdditiveArithmetic
|
|
Protocol FixedWidthInteger has added inherited protocol AdditiveArithmetic
|
|
Protocol FloatingPoint has added inherited protocol AdditiveArithmetic
|
|
Protocol Numeric has added inherited protocol AdditiveArithmetic
|
|
Protocol SignedInteger has added inherited protocol AdditiveArithmetic
|
|
Protocol SignedNumeric has added inherited protocol AdditiveArithmetic
|
|
|
|
/* Decl Attribute changes */
|
|
|
|
/* Protocol Requirement Changes */
|
|
Protocol StringProtocol has added inherited protocol ExpressibleByStringInterpolation
|
|
Protocol UnsignedInteger has added inherited protocol AdditiveArithmetic
|
|
|
|
/* SE-0234 */
|
|
AssociatedType Sequence.SubSequence has been removed
|
|
Constructor ClosedRange.init(_:) has been removed (deprecated)
|
|
Constructor Range.init(_:) has been removed (deprecated)
|
|
Func AnyBidirectionalCollection.split(maxSplits:omittingEmptySubsequences:whereSeparator:) has been removed
|
|
Func AnyCollection.split(maxSplits:omittingEmptySubsequences:whereSeparator:) has been removed
|
|
Func AnyRandomAccessCollection.split(maxSplits:omittingEmptySubsequences:whereSeparator:) has been removed
|
|
Func AnySequence.dropLast(_:) has return type change from AnySequence<Element> to [Element]
|
|
Func AnySequence.prefix(while:) has return type change from AnySequence<Element> to [Element]
|
|
Func AnySequence.split(maxSplits:omittingEmptySubsequences:whereSeparator:) has been removed
|
|
Func AnySequence.suffix(_:) has return type change from AnySequence<Element> to [Element]
|
|
Func Collection.distance(from:to:) has been removed (deprecated)
|
|
Func Collection.flatMap(_:) has been removed (deprecated)
|
|
Func Collection.formIndex(_:offsetBy:) has been removed (deprecated)
|
|
Func Collection.formIndex(_:offsetBy:limitedBy:) has been removed (deprecated)
|
|
Func Collection.index(_:offsetBy:) has been removed (deprecated)
|
|
Func Collection.index(_:offsetBy:limitedBy:) has been removed (deprecated)
|
|
Func Collection.joined() has been removed
|
|
Func DropFirstSequence.dropFirst(_:) has return type change from AnySequence<DropFirstSequence<Base>.Element> to DropFirstSequence<Base>
|
|
Func PrefixSequence.prefix(_:) has return type change from AnySequence<Base.Element> to PrefixSequence<Base>
|
|
Func Sequence.drop(while:) has return type change from Self.SubSequence to DropWhileSequence<Self>
|
|
Func Sequence.dropFirst() has been removed
|
|
Func Sequence.dropFirst(_:) has return type change from Self.SubSequence to DropFirstSequence<Self>
|
|
Func Sequence.dropLast() has been removed
|
|
Func Sequence.dropLast(_:) has return type change from Self.SubSequence to [Self.Element]
|
|
Func Sequence.prefix(_:) has return type change from Self.SubSequence to PrefixSequence<Self>
|
|
Func Sequence.prefix(while:) has return type change from Self.SubSequence to [Self.Element]
|
|
Func Sequence.split(maxSplits:omittingEmptySubsequences:whereSeparator:) has return type change from [Self.SubSequence] to [ArraySlice<Self.Element>]
|
|
Func Sequence.split(separator:maxSplits:omittingEmptySubsequences:) has return type change from [Self.SubSequence] to [ArraySlice<Self.Element>]
|
|
Func Sequence.suffix(_:) has return type change from Self.SubSequence to [Self.Element]
|
|
Func String.withMutableCharacters(_:) has been removed (deprecated)
|
|
Func Substring.withMutableCharacters(_:) has been removed (deprecated)
|
|
Func UnsafeMutablePointer.deallocate(capacity:) has been removed (deprecated)
|
|
Func UnsafeMutablePointer.deinitialize() has been removed (deprecated)
|
|
Func UnsafeMutablePointer.initialize(from:) has been removed (deprecated)
|
|
Func UnsafeMutablePointer.initialize(to:count:) has been removed (deprecated)
|
|
Func UnsafeMutableRawBufferPointer.allocate(count:) has been removed (deprecated)
|
|
Func UnsafeMutableRawBufferPointer.copyBytes(from:) has been removed (deprecated)
|
|
Func UnsafeMutableRawPointer.allocate(bytes:alignedTo:) has been removed (deprecated)
|
|
Func UnsafeMutableRawPointer.copyBytes(from:count:) has been removed (deprecated)
|
|
Func UnsafeMutableRawPointer.deallocate(bytes:alignedTo:) has been removed (deprecated)
|
|
Func UnsafeMutableRawPointer.initializeMemory(as:at:count:to:) has been removed (deprecated)
|
|
Func UnsafeMutableRawPointer.initializeMemory(as:from:) has been removed (deprecated)
|
|
Func abs(_:) has been removed
|
|
Protocol Collection has generic signature change from <Self : Sequence, Self.Index : Comparable, Self.Index == Self.Indices.Element, Self.Indices : Collection, Self.Indices == Self.Indices.SubSequence, Self.SubSequence : Collection, Self.Indices.Element == Self.Indices.Index, Self.Indices.Index == Self.SubSequence.Index, Self.SubSequence.Index == Self.Indices.Indices.Element, Self.Indices.Indices.Element == Self.Indices.Indices.Index, Self.Indices.Indices.Index == Self.SubSequence.Indices.Element, Self.SubSequence.Indices.Element == Self.SubSequence.Indices.Index, Self.SubSequence.Indices.Index == Self.SubSequence.Indices.Indices.Element, Self.SubSequence.Indices.Indices.Element == Self.SubSequence.Indices.Indices.Index> to <Self : Sequence, Self.Element == Self.SubSequence.Element, Self.Index : Comparable, Self.Index == Self.Indices.Element, Self.Indices : Collection, Self.Indices == Self.Indices.SubSequence, Self.SubSequence : Collection, Self.SubSequence == Self.SubSequence.SubSequence, Self.Indices.Element == Self.Indices.Index, Self.Indices.Index == Self.SubSequence.Index, Self.SubSequence.Index == Self.Indices.Indices.Element, Self.Indices.Indices.Element == Self.Indices.Indices.Index, Self.Indices.Indices.Index == Self.SubSequence.Indices.Element, Self.SubSequence.Indices.Element == Self.SubSequence.Indices.Index, Self.SubSequence.Indices.Index == Self.SubSequence.Indices.Indices.Element, Self.SubSequence.Indices.Indices.Element == Self.SubSequence.Indices.Indices.Index>
|
|
Protocol Sequence has generic signature change from <Self.Element == Self.Iterator.Element, Self.Iterator : IteratorProtocol, Self.SubSequence : Sequence, Self.SubSequence == Self.SubSequence.SubSequence, Self.Iterator.Element == Self.SubSequence.Element, Self.SubSequence.Element == Self.SubSequence.Iterator.Element> to <Self.Element == Self.Iterator.Element, Self.Iterator : IteratorProtocol>
|
|
Protocol _SequenceWrapper has been removed
|
|
Struct AnySequence has removed conformance to Sequence
|
|
Struct Iterator has been removed
|
|
Struct LazySequence has removed conformance to _SequenceWrapper
|
|
Struct ReversedCollection has removed conformance to LazyCollectionProtocol
|
|
Struct Slice has removed conformance to LazyCollectionProtocol
|
|
TypeAlias AnyIterator.SubSequence has been removed
|
|
TypeAlias AnySequence.SubSequence has been removed
|
|
TypeAlias ArrayLiteralConvertible has been removed (deprecated)
|
|
TypeAlias BidirectionalIndexable has been removed (deprecated)
|
|
TypeAlias BidirectionalSlice has been removed (deprecated)
|
|
TypeAlias BooleanLiteralConvertible has been removed (deprecated)
|
|
TypeAlias ClosedRangeIndex has been removed (deprecated)
|
|
TypeAlias CustomPlaygroundQuickLookable has been removed (deprecated)
|
|
TypeAlias DefaultBidirectionalIndices has been removed (deprecated)
|
|
TypeAlias DefaultRandomAccessIndices has been removed (deprecated)
|
|
TypeAlias DictionaryLiteralConvertible has been removed (deprecated)
|
|
TypeAlias EmptyCollection.Iterator.SubSequence has been removed
|
|
TypeAlias EmptyIterator has been removed (deprecated)
|
|
TypeAlias EnumeratedSequence.Iterator.SubSequence has been removed
|
|
TypeAlias EnumeratedSequence.SubSequence has been removed
|
|
TypeAlias ExtendedGraphemeClusterLiteralConvertible has been removed (deprecated)
|
|
TypeAlias FlattenBidirectionalCollection has been removed (deprecated)
|
|
TypeAlias FlattenBidirectionalCollectionIndex has been removed (deprecated)
|
|
TypeAlias FlattenCollectionIndex has been removed (deprecated)
|
|
TypeAlias FlattenSequence.Iterator.SubSequence has been removed
|
|
TypeAlias FlattenSequence.SubSequence has generic signature change from <Base where Base : Sequence, Base.Element : Sequence> to <Base where Base : BidirectionalCollection, Base.Element : BidirectionalCollection>
|
|
TypeAlias FlattenSequence.SubSequence has underlying type change from AnySequence<Base.Element.Element> to Slice<FlattenSequence<Base>>
|
|
TypeAlias FloatLiteralConvertible has been removed (deprecated)
|
|
TypeAlias Indexable has been removed (deprecated)
|
|
TypeAlias IndexableBase has been removed (deprecated)
|
|
TypeAlias IntegerLiteralConvertible has been removed (deprecated)
|
|
TypeAlias IteratorOverOne has been removed (deprecated)
|
|
TypeAlias IteratorSequence.SubSequence has been removed
|
|
TypeAlias JoinedIterator has been removed (deprecated)
|
|
TypeAlias JoinedSequence.SubSequence has been removed
|
|
TypeAlias LazyBidirectionalCollection has been removed (deprecated)
|
|
TypeAlias LazyDropWhileBidirectionalCollection has been removed (deprecated)
|
|
TypeAlias LazyDropWhileIndex has been removed (deprecated)
|
|
TypeAlias LazyDropWhileIterator has been removed (deprecated)
|
|
TypeAlias LazyDropWhileSequence.SubSequence has generic signature change from <Base where Base : Sequence> to <Base where Base : Collection>
|
|
TypeAlias LazyDropWhileSequence.SubSequence has underlying type change from AnySequence<LazyDropWhileSequence<Base>.Element> to Slice<LazyDropWhileCollection<Base>>
|
|
TypeAlias LazyFilterBidirectionalCollection has been removed (deprecated)
|
|
TypeAlias LazyFilterIndex has been removed (deprecated)
|
|
TypeAlias LazyFilterIterator has been removed (deprecated)
|
|
TypeAlias LazyFilterSequence.Iterator.SubSequence has been removed
|
|
TypeAlias LazyFilterSequence.SubSequence has generic signature change from <Base where Base : Sequence> to <Base where Base : Collection>
|
|
TypeAlias LazyFilterSequence.SubSequence has underlying type change from AnySequence<Base.Element> to LazyFilterCollection<Base.SubSequence>
|
|
TypeAlias LazyMapBidirectionalCollection has been removed (deprecated)
|
|
TypeAlias LazyMapIterator has been removed (deprecated)
|
|
TypeAlias LazyMapRandomAccessCollection has been removed (deprecated)
|
|
TypeAlias LazyMapSequence.Iterator.SubSequence has been removed
|
|
TypeAlias LazyMapSequence.SubSequence has generic signature change from <Base, Element where Base : Sequence> to <Base, Element where Base : Collection>
|
|
TypeAlias LazyMapSequence.SubSequence has underlying type change from AnySequence<Element> to LazyMapCollection<Base.SubSequence, Element>
|
|
TypeAlias LazyPrefixWhileBidirectionalCollection has been removed (deprecated)
|
|
TypeAlias LazyPrefixWhileIndex has been removed (deprecated)
|
|
TypeAlias LazyPrefixWhileIterator has been removed (deprecated)
|
|
TypeAlias LazyPrefixWhileSequence.Iterator.SubSequence has been removed
|
|
TypeAlias LazyPrefixWhileSequence.SubSequence has generic signature change from <Base where Base : Sequence> to <Base where Base : Collection>
|
|
TypeAlias LazyPrefixWhileSequence.SubSequence has underlying type change from AnySequence<LazyPrefixWhileSequence<Base>.Element> to Slice<LazyPrefixWhileCollection<Base>>
|
|
TypeAlias LazyRandomAccessCollection has been removed (deprecated)
|
|
TypeAlias LazySequence.Base has been removed
|
|
TypeAlias LazySequence.SubSequence has generic signature change from <Base where Base : Sequence> to <Base where Base : Collection>
|
|
TypeAlias LazySequence.SubSequence has underlying type change from Base.SubSequence to Slice<LazySequence<Base>>
|
|
TypeAlias MutableBidirectionalSlice has been removed (deprecated)
|
|
TypeAlias MutableIndexable has been removed (deprecated)
|
|
TypeAlias MutableRandomAccessSlice has been removed (deprecated)
|
|
TypeAlias MutableRangeReplaceableBidirectionalSlice has been removed (deprecated)
|
|
TypeAlias MutableRangeReplaceableRandomAccessSlice has been removed (deprecated)
|
|
TypeAlias MutableRangeReplaceableSlice has been removed (deprecated)
|
|
TypeAlias MutableSlice has been removed (deprecated)
|
|
TypeAlias NilLiteralConvertible has been removed (deprecated)
|
|
TypeAlias PartialRangeFrom.SubSequence has been removed
|
|
TypeAlias RandomAccessIndexable has been removed (deprecated)
|
|
TypeAlias RandomAccessSlice has been removed (deprecated)
|
|
TypeAlias RangeReplaceableBidirectionalSlice has been removed (deprecated)
|
|
TypeAlias RangeReplaceableIndexable has been removed (deprecated)
|
|
TypeAlias RangeReplaceableRandomAccessSlice has been removed (deprecated)
|
|
TypeAlias RangeReplaceableSlice has been removed (deprecated)
|
|
TypeAlias ReversedCollection.Iterator.SubSequence has been removed
|
|
TypeAlias ReversedIndex has been removed (deprecated)
|
|
TypeAlias ReversedRandomAccessCollection has been removed (deprecated)
|
|
TypeAlias StrideThrough.SubSequence has been removed
|
|
TypeAlias StrideTo.SubSequence has been removed
|
|
TypeAlias String.CharacterView has been removed (deprecated)
|
|
TypeAlias StringInterpolationConvertible has been removed (deprecated)
|
|
TypeAlias StringLiteralConvertible has been removed (deprecated)
|
|
TypeAlias Substring.CharacterView has been removed (deprecated)
|
|
TypeAlias UnfoldSequence.SubSequence has been removed
|
|
TypeAlias UnicodeScalarLiteralConvertible has been removed (deprecated)
|
|
TypeAlias UnsafeBufferPointerIterator has been removed (deprecated)
|
|
TypeAlias UnsafeMutableRawBufferPointerIterator has been removed (deprecated)
|
|
TypeAlias UnsafeRawBufferPointer.Iterator.SubSequence has been removed
|
|
TypeAlias UnsafeRawBufferPointerIterator has been removed (deprecated)
|
|
TypeAlias Zip2Iterator has been removed (deprecated)
|
|
TypeAlias Zip2Sequence.Stream1 has been removed (deprecated)
|
|
TypeAlias Zip2Sequence.Stream2 has been removed (deprecated)
|
|
TypeAlias Zip2Sequence.SubSequence has been removed
|
|
Var Collection.lazy has been removed
|
|
|
|
AssociatedType LazyCollectionProtocol.Elements has been removed
|
|
Func LazyCollectionProtocol.compactMap(_:) has been removed
|
|
Func LazyCollectionProtocol.drop(while:) has been removed
|
|
Func LazyCollectionProtocol.filter(_:) has been removed
|
|
Func LazyCollectionProtocol.flatMap(_:) has been removed
|
|
Func LazyCollectionProtocol.flatMap(_:) has been removed (deprecated)
|
|
Func LazyCollectionProtocol.joined() has been removed
|
|
Func LazyCollectionProtocol.map(_:) has been removed
|
|
Func LazyCollectionProtocol.prefix(while:) has been removed
|
|
Func LazyCollectionProtocol.reversed() has been removed
|
|
Var LazyCollectionProtocol.lazy has declared type change from LazyCollection<Self.Elements> to LazySequence<Self.Elements>
|
|
|
|
Func Sequence.reduce(into:_:) has parameter 0 changing from Default to Owned
|