Skip to content

Commit ab16446

Browse files
moiseevairspeedswift
authored andcommitted
[5.0] Remove declarations obsoleted in Swift 4 (#22139)
* Remove a couple of obsoleted-in-4.0 methods (cherry picked from commit 80f0a69) * Add (false positive) removals to ABI checker file (cherry picked from commit 72c0006) * [stdlib] Remove a bunch of declarations marked as obsoleted in 4 (cherry picked from commit 54e79e2f2b4c9997881aae10f1947d8e667595ee) * List removals in ABI expected breakage test (cherry picked from commit 01e1c6ef4d517cec95e67ad71f10b50e8ee99c2f) * Update the validation test (cherry picked from commit 240be2d0e30241c2c4fbfca9ba7d4c62ee266e51)
1 parent f50ba81 commit ab16446

File tree

7 files changed

+97
-355
lines changed

7 files changed

+97
-355
lines changed

stdlib/public/SDK/CoreGraphics/CGFloat.swift.gyb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -347,12 +347,6 @@ extension CGFloat {
347347
public static var max: CGFloat {
348348
fatalError("unavailable")
349349
}
350-
351-
@available(swift, deprecated: 3.1, obsoleted: 4.0, message: "Please use the `abs(_:)` free function")
352-
@_transparent
353-
public static func abs(_ x: CGFloat) -> CGFloat {
354-
return x.magnitude
355-
}
356350
}
357351

358352
@available(*, unavailable, renamed: "CGFloat.leastNormalMagnitude")

stdlib/public/core/IntegerTypes.swift.gyb

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,6 @@ maskingShifts = [
5858
llvmName=lambda _: 'shl'),
5959
]
6060

61-
IntMax = 'Int%s' % int_max_bits
62-
UIntMax = 'UInt%s' % int_max_bits
63-
}%
64-
65-
// FIXME(integers): remove these two aliases
66-
/// The largest native signed integer type.
67-
@available(swift, obsoleted: 4.0, renamed: "${IntMax}")
68-
public typealias IntMax = ${IntMax}
69-
/// The largest native unsigned integer type.
70-
@available(swift, obsoleted: 4.0, renamed: "${UIntMax}")
71-
public typealias UIntMax = ${UIntMax}
72-
73-
%{
7461
#===-----------------------------------------------------------------------===//
7562
#===--- Operator Documentation --------------------------------------------===//
7663
#===-----------------------------------------------------------------------===//
@@ -1628,17 +1615,6 @@ ${assignmentOperatorComment(x.operator, True)}
16281615
}
16291616
% end
16301617

1631-
@available(swift, obsoleted: 4.0, message: "Use initializers instead")
1632-
public func to${U}IntMax() -> ${U}Int64 {
1633-
return numericCast(self)
1634-
}
1635-
1636-
@available(swift, obsoleted: 4, message: "Use bitWidth instead.")
1637-
public static var _sizeInBits: ${Self} { return ${bits} }
1638-
1639-
@available(swift, obsoleted: 4)
1640-
public static var _sizeInBytes: ${Self} { return ${bits}/8 }
1641-
16421618
/// Returns `-1` if this value is negative and `1` if it's positive;
16431619
/// otherwise, `0`.
16441620
///
@@ -1687,36 +1663,6 @@ extension ${Self} : _HasCustomAnyHashableRepresentation {
16871663
}
16881664
}
16891665

1690-
% for src_type in all_integer_types(word_bits):
1691-
% srcBits = src_type.bits
1692-
% srcSigned = src_type.is_signed
1693-
% Src = src_type.stdlib_name
1694-
% if should_define_truncating_bit_pattern_init(src_ty=src_type, dst_ty=self_type):
1695-
extension ${Self} {
1696-
/// Creates a new instance with the same bitwise representation as the least
1697-
/// significant bits of the given value.
1698-
///
1699-
/// This initializer performs no range or overflow checking. The resulting
1700-
/// instance may have a different numeric value from `source`.
1701-
///
1702-
/// - Parameter source: An integer to use as the source of the new value's
1703-
/// bit pattern.
1704-
@available(swift, obsoleted: 4.0, renamed: "init(truncatingIfNeeded:)")
1705-
@_transparent
1706-
public init(truncatingBitPattern source: ${Src}) {
1707-
let src = source._value
1708-
% if self_type.bits == src_type.bits:
1709-
let dstNotWord = src
1710-
% else:
1711-
let dstNotWord = Builtin.trunc_Int${srcBits}_Int${bits}(src)
1712-
% end
1713-
self._value = dstNotWord
1714-
}
1715-
}
1716-
% end
1717-
% end
1718-
1719-
17201666
// FIXME(integers): this section here is to help the typechecker,
17211667
// as it seems to have problems with a pattern where the nonmutating operation
17221668
// is defined on a protocol in terms of a mutating one that is itself defined
@@ -1733,32 +1679,6 @@ ${operatorComment(x.operator, True)}
17331679
return lhs
17341680
}
17351681

1736-
% end
1737-
1738-
% for op in maskingShifts:
1739-
1740-
${operatorComment(x.operator, True)}
1741-
@available(swift, obsoleted: 4)
1742-
@_semantics("optimize.sil.specialize.generic.partial.never")
1743-
@_transparent
1744-
public static func ${op.nonMaskingOperator}(
1745-
lhs: ${Self}, rhs: ${Self}
1746-
) -> ${Self} {
1747-
var lhs = lhs
1748-
${op.helper}Generic(&lhs, rhs)
1749-
return lhs
1750-
}
1751-
1752-
${assignmentOperatorComment(x.operator, True)}
1753-
@available(swift, obsoleted: 4)
1754-
@_semantics("optimize.sil.specialize.generic.partial.never")
1755-
@_transparent
1756-
public static func ${op.nonMaskingOperator}=(
1757-
lhs: inout ${Self}, rhs: ${Self}
1758-
) {
1759-
${op.helper}Generic(&lhs, rhs)
1760-
}
1761-
17621682
% end
17631683

17641684
@_transparent

stdlib/public/core/Integers.swift

Lines changed: 0 additions & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -3566,145 +3566,6 @@ public func numericCast<T : BinaryInteger, U : BinaryInteger>(_ x: T) -> U {
35663566
return U(x)
35673567
}
35683568

3569-
// FIXME(integers): These overloads allow expressions like the following in
3570-
// Swift 3 compatibility mode:
3571-
// let x = 1 << i32
3572-
// f(i32: x)
3573-
// At the same time, since they are obsolete in Swift 4, this will not cause
3574-
// `u8 << -1` to fail due to an overflow in an unsigned value.
3575-
extension FixedWidthInteger {
3576-
@available(swift, obsoleted: 4)
3577-
@_semantics("optimize.sil.specialize.generic.partial.never")
3578-
@_transparent
3579-
public static func >>(lhs: Self, rhs: Self) -> Self {
3580-
var lhs = lhs
3581-
_nonMaskingRightShiftGeneric(&lhs, rhs)
3582-
return lhs
3583-
}
3584-
3585-
@available(swift, obsoleted: 4)
3586-
@_semantics("optimize.sil.specialize.generic.partial.never")
3587-
@_transparent
3588-
public static func >>=(lhs: inout Self, rhs: Self) {
3589-
_nonMaskingRightShiftGeneric(&lhs, rhs)
3590-
}
3591-
3592-
@available(swift, obsoleted: 4)
3593-
@_semantics("optimize.sil.specialize.generic.partial.never")
3594-
@_transparent
3595-
public static func <<(lhs: Self, rhs: Self) -> Self {
3596-
var lhs = lhs
3597-
_nonMaskingLeftShiftGeneric(&lhs, rhs)
3598-
return lhs
3599-
}
3600-
3601-
@available(swift, obsoleted: 4)
3602-
@_semantics("optimize.sil.specialize.generic.partial.never")
3603-
@_transparent
3604-
public static func <<=(lhs: inout Self, rhs: Self) {
3605-
_nonMaskingLeftShiftGeneric(&lhs, rhs)
3606-
}
3607-
}
3608-
3609-
extension FixedWidthInteger {
3610-
@available(swift, obsoleted: 4, message: "Use addingReportingOverflow(_:) instead.")
3611-
@inlinable
3612-
public static func addWithOverflow(
3613-
_ lhs: Self, _ rhs: Self
3614-
) -> (Self, overflow: Bool) {
3615-
let (partialValue, overflow) =
3616-
lhs.addingReportingOverflow( rhs)
3617-
return (partialValue, overflow: overflow)
3618-
}
3619-
3620-
@available(swift, obsoleted: 4, message: "Use subtractingReportingOverflow(_:) instead.")
3621-
@inlinable
3622-
public static func subtractWithOverflow(
3623-
_ lhs: Self, _ rhs: Self
3624-
) -> (Self, overflow: Bool) {
3625-
let (partialValue, overflow) =
3626-
lhs.subtractingReportingOverflow( rhs)
3627-
return (partialValue, overflow: overflow)
3628-
}
3629-
3630-
@inlinable
3631-
@available(swift, obsoleted: 4, message: "Use multipliedReportingOverflow(by:) instead.")
3632-
public static func multiplyWithOverflow(
3633-
_ lhs: Self, _ rhs: Self
3634-
) -> (Self, overflow: Bool) {
3635-
let (partialValue, overflow) =
3636-
lhs.multipliedReportingOverflow(by: rhs)
3637-
return (partialValue, overflow: overflow)
3638-
}
3639-
3640-
@inlinable
3641-
@available(swift, obsoleted: 4, message: "Use dividedReportingOverflow(by:) instead.")
3642-
public static func divideWithOverflow(
3643-
_ lhs: Self, _ rhs: Self
3644-
) -> (Self, overflow: Bool) {
3645-
let (partialValue, overflow) =
3646-
lhs.dividedReportingOverflow(by: rhs)
3647-
return (partialValue, overflow: overflow)
3648-
}
3649-
3650-
@inlinable
3651-
@available(swift, obsoleted: 4, message: "Use remainderReportingOverflow(dividingBy:) instead.")
3652-
public static func remainderWithOverflow(
3653-
_ lhs: Self, _ rhs: Self
3654-
) -> (Self, overflow: Bool) {
3655-
let (partialValue, overflow) =
3656-
lhs.remainderReportingOverflow(dividingBy: rhs)
3657-
return (partialValue, overflow: overflow)
3658-
}
3659-
}
3660-
3661-
extension BinaryInteger {
3662-
@inlinable
3663-
@available(swift, obsoleted: 3.2,
3664-
message: "Please use FixedWidthInteger protocol as a generic constraint and addingReportingOverflow(_:) method instead.")
3665-
public static func addWithOverflow(
3666-
_ lhs: Self, _ rhs: Self
3667-
) -> (Self, overflow: Bool) {
3668-
fatalError("Unavailable")
3669-
}
3670-
3671-
@inlinable
3672-
@available(swift, obsoleted: 3.2,
3673-
message: "Please use FixedWidthInteger protocol as a generic constraint and subtractingReportingOverflow(_:) method instead.")
3674-
public static func subtractWithOverflow(
3675-
_ lhs: Self, _ rhs: Self
3676-
) -> (Self, overflow: Bool) {
3677-
fatalError("Unavailable")
3678-
}
3679-
3680-
@inlinable
3681-
@available(swift, obsoleted: 3.2,
3682-
message: "Please use FixedWidthInteger protocol as a generic constraint and multipliedReportingOverflow(by:) method instead.")
3683-
public static func multiplyWithOverflow(
3684-
_ lhs: Self, _ rhs: Self
3685-
) -> (Self, overflow: Bool) {
3686-
fatalError("Unavailable")
3687-
}
3688-
3689-
@inlinable
3690-
@available(swift, obsoleted: 3.2,
3691-
message: "Please use FixedWidthInteger protocol as a generic constraint and dividedReportingOverflow(by:) method instead.")
3692-
public static func divideWithOverflow(
3693-
_ lhs: Self, _ rhs: Self
3694-
) -> (Self, overflow: Bool) {
3695-
fatalError("Unavailable")
3696-
}
3697-
3698-
@inlinable
3699-
@available(swift, obsoleted: 3.2,
3700-
message: "Please use FixedWidthInteger protocol as a generic constraint and remainderReportingOverflow(dividingBy:) method instead.")
3701-
public static func remainderWithOverflow(
3702-
_ lhs: Self, _ rhs: Self
3703-
) -> (Self, overflow: Bool) {
3704-
fatalError("Unavailable")
3705-
}
3706-
}
3707-
37083569
// FIXME(integers): Absence of &+ causes ambiguity in the code like the
37093570
// following:
37103571
// func f<T : SignedInteger>(_ x: T, _ y: T) {
@@ -3720,24 +3581,10 @@ extension SignedInteger {
37203581
fatalError("Should be overridden in a more specific type")
37213582
}
37223583

3723-
@_transparent
3724-
@available(swift, obsoleted: 4.0,
3725-
message: "Please use 'FixedWidthInteger' instead of 'SignedInteger' to get '&+' in generic code.")
3726-
public static func &+ (lhs: Self, rhs: Self) -> Self {
3727-
return _maskingAdd(lhs, rhs)
3728-
}
3729-
37303584
@_transparent
37313585
public static func _maskingSubtract(_ lhs: Self, _ rhs: Self) -> Self {
37323586
fatalError("Should be overridden in a more specific type")
37333587
}
3734-
3735-
@_transparent
3736-
@available(swift, obsoleted: 4.0,
3737-
message: "Please use 'FixedWidthInteger' instead of 'SignedInteger' to get '&-' in generic code.")
3738-
public static func &- (lhs: Self, rhs: Self) -> Self {
3739-
return _maskingSubtract(lhs, rhs)
3740-
}
37413588
}
37423589

37433590
extension SignedInteger where Self : FixedWidthInteger {

stdlib/public/core/MigrationSupport.swift

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -244,26 +244,6 @@ extension String.UnicodeScalarView : _CustomPlaygroundQuickLookable {
244244
}
245245

246246
//===--- Slicing Support --------------------------------------------------===//
247-
// In Swift 3.2, in the absence of type context,
248-
//
249-
// someString.unicodeScalars[
250-
// someString.unicodeScalars.startIndex
251-
// ..< someString.unicodeScalars.endIndex]
252-
//
253-
// was deduced to be of type `String.UnicodeScalarView`. Provide a
254-
// more-specific Swift-3-only `subscript` overload that continues to produce
255-
// `String.UnicodeScalarView`.
256-
extension String.UnicodeScalarView {
257-
@available(swift, obsoleted: 4)
258-
public subscript(bounds: Range<Index>) -> String.UnicodeScalarView {
259-
Builtin.unreachable()
260-
}
261-
262-
@available(swift, obsoleted: 4)
263-
public subscript(bounds: ClosedRange<Index>) -> String.UnicodeScalarView {
264-
Builtin.unreachable()
265-
}
266-
}
267247

268248
// @available(swift,deprecated: 5.0, renamed: "Unicode.UTF8")
269249
public typealias UTF8 = Unicode.UTF8
@@ -327,11 +307,6 @@ extension Substring {
327307
_precondition(range.upperBound <= endIndex,
328308
"String index range is out of bounds")
329309
}
330-
331-
@available(swift, obsoleted: 4)
332-
public subscript(bounds: ClosedRange<Index>) -> String {
333-
Builtin.unreachable()
334-
}
335310
}
336311

337312
extension Substring : _CustomPlaygroundQuickLookable {
@@ -567,13 +542,6 @@ extension Sequence {
567542
) rethrows -> [ElementOfResult] {
568543
return try _compactMap(transform)
569544
}
570-
571-
@available(swift, obsoleted: 4)
572-
public func flatMap(
573-
_ transform: (Element) throws -> String
574-
) rethrows -> [String] {
575-
return try map(transform)
576-
}
577545
}
578546

579547
extension Collection {

0 commit comments

Comments
 (0)