Skip to content

[5.0] Remove declarations obsoleted in Swift 4 #22139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions stdlib/public/SDK/CoreGraphics/CGFloat.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -347,12 +347,6 @@ extension CGFloat {
public static var max: CGFloat {
fatalError("unavailable")
}

@available(swift, deprecated: 3.1, obsoleted: 4.0, message: "Please use the `abs(_:)` free function")
@_transparent
public static func abs(_ x: CGFloat) -> CGFloat {
return x.magnitude
}
}

@available(*, unavailable, renamed: "CGFloat.leastNormalMagnitude")
Expand Down
80 changes: 0 additions & 80 deletions stdlib/public/core/IntegerTypes.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,6 @@ maskingShifts = [
llvmName=lambda _: 'shl'),
]

IntMax = 'Int%s' % int_max_bits
UIntMax = 'UInt%s' % int_max_bits
}%

// FIXME(integers): remove these two aliases
/// The largest native signed integer type.
@available(swift, obsoleted: 4.0, renamed: "${IntMax}")
public typealias IntMax = ${IntMax}
/// The largest native unsigned integer type.
@available(swift, obsoleted: 4.0, renamed: "${UIntMax}")
public typealias UIntMax = ${UIntMax}

%{
#===-----------------------------------------------------------------------===//
#===--- Operator Documentation --------------------------------------------===//
#===-----------------------------------------------------------------------===//
Expand Down Expand Up @@ -1628,17 +1615,6 @@ ${assignmentOperatorComment(x.operator, True)}
}
% end

@available(swift, obsoleted: 4.0, message: "Use initializers instead")
public func to${U}IntMax() -> ${U}Int64 {
return numericCast(self)
}

@available(swift, obsoleted: 4, message: "Use bitWidth instead.")
public static var _sizeInBits: ${Self} { return ${bits} }

@available(swift, obsoleted: 4)
public static var _sizeInBytes: ${Self} { return ${bits}/8 }

/// Returns `-1` if this value is negative and `1` if it's positive;
/// otherwise, `0`.
///
Expand Down Expand Up @@ -1687,36 +1663,6 @@ extension ${Self} : _HasCustomAnyHashableRepresentation {
}
}

% for src_type in all_integer_types(word_bits):
% srcBits = src_type.bits
% srcSigned = src_type.is_signed
% Src = src_type.stdlib_name
% if should_define_truncating_bit_pattern_init(src_ty=src_type, dst_ty=self_type):
extension ${Self} {
/// Creates a new instance with the same bitwise representation as the least
/// significant bits of the given value.
///
/// This initializer performs no range or overflow checking. The resulting
/// instance may have a different numeric value from `source`.
///
/// - Parameter source: An integer to use as the source of the new value's
/// bit pattern.
@available(swift, obsoleted: 4.0, renamed: "init(truncatingIfNeeded:)")
@_transparent
public init(truncatingBitPattern source: ${Src}) {
let src = source._value
% if self_type.bits == src_type.bits:
let dstNotWord = src
% else:
let dstNotWord = Builtin.trunc_Int${srcBits}_Int${bits}(src)
% end
self._value = dstNotWord
}
}
% end
% end


// FIXME(integers): this section here is to help the typechecker,
// as it seems to have problems with a pattern where the nonmutating operation
// is defined on a protocol in terms of a mutating one that is itself defined
Expand All @@ -1733,32 +1679,6 @@ ${operatorComment(x.operator, True)}
return lhs
}

% end

% for op in maskingShifts:

${operatorComment(x.operator, True)}
@available(swift, obsoleted: 4)
@_semantics("optimize.sil.specialize.generic.partial.never")
@_transparent
public static func ${op.nonMaskingOperator}(
lhs: ${Self}, rhs: ${Self}
) -> ${Self} {
var lhs = lhs
${op.helper}Generic(&lhs, rhs)
return lhs
}

${assignmentOperatorComment(x.operator, True)}
@available(swift, obsoleted: 4)
@_semantics("optimize.sil.specialize.generic.partial.never")
@_transparent
public static func ${op.nonMaskingOperator}=(
lhs: inout ${Self}, rhs: ${Self}
) {
${op.helper}Generic(&lhs, rhs)
}

% end

@_transparent
Expand Down
153 changes: 0 additions & 153 deletions stdlib/public/core/Integers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3566,145 +3566,6 @@ public func numericCast<T : BinaryInteger, U : BinaryInteger>(_ x: T) -> U {
return U(x)
}

// FIXME(integers): These overloads allow expressions like the following in
// Swift 3 compatibility mode:
// let x = 1 << i32
// f(i32: x)
// At the same time, since they are obsolete in Swift 4, this will not cause
// `u8 << -1` to fail due to an overflow in an unsigned value.
extension FixedWidthInteger {
@available(swift, obsoleted: 4)
@_semantics("optimize.sil.specialize.generic.partial.never")
@_transparent
public static func >>(lhs: Self, rhs: Self) -> Self {
var lhs = lhs
_nonMaskingRightShiftGeneric(&lhs, rhs)
return lhs
}

@available(swift, obsoleted: 4)
@_semantics("optimize.sil.specialize.generic.partial.never")
@_transparent
public static func >>=(lhs: inout Self, rhs: Self) {
_nonMaskingRightShiftGeneric(&lhs, rhs)
}

@available(swift, obsoleted: 4)
@_semantics("optimize.sil.specialize.generic.partial.never")
@_transparent
public static func <<(lhs: Self, rhs: Self) -> Self {
var lhs = lhs
_nonMaskingLeftShiftGeneric(&lhs, rhs)
return lhs
}

@available(swift, obsoleted: 4)
@_semantics("optimize.sil.specialize.generic.partial.never")
@_transparent
public static func <<=(lhs: inout Self, rhs: Self) {
_nonMaskingLeftShiftGeneric(&lhs, rhs)
}
}

extension FixedWidthInteger {
@available(swift, obsoleted: 4, message: "Use addingReportingOverflow(_:) instead.")
@inlinable
public static func addWithOverflow(
_ lhs: Self, _ rhs: Self
) -> (Self, overflow: Bool) {
let (partialValue, overflow) =
lhs.addingReportingOverflow( rhs)
return (partialValue, overflow: overflow)
}

@available(swift, obsoleted: 4, message: "Use subtractingReportingOverflow(_:) instead.")
@inlinable
public static func subtractWithOverflow(
_ lhs: Self, _ rhs: Self
) -> (Self, overflow: Bool) {
let (partialValue, overflow) =
lhs.subtractingReportingOverflow( rhs)
return (partialValue, overflow: overflow)
}

@inlinable
@available(swift, obsoleted: 4, message: "Use multipliedReportingOverflow(by:) instead.")
public static func multiplyWithOverflow(
_ lhs: Self, _ rhs: Self
) -> (Self, overflow: Bool) {
let (partialValue, overflow) =
lhs.multipliedReportingOverflow(by: rhs)
return (partialValue, overflow: overflow)
}

@inlinable
@available(swift, obsoleted: 4, message: "Use dividedReportingOverflow(by:) instead.")
public static func divideWithOverflow(
_ lhs: Self, _ rhs: Self
) -> (Self, overflow: Bool) {
let (partialValue, overflow) =
lhs.dividedReportingOverflow(by: rhs)
return (partialValue, overflow: overflow)
}

@inlinable
@available(swift, obsoleted: 4, message: "Use remainderReportingOverflow(dividingBy:) instead.")
public static func remainderWithOverflow(
_ lhs: Self, _ rhs: Self
) -> (Self, overflow: Bool) {
let (partialValue, overflow) =
lhs.remainderReportingOverflow(dividingBy: rhs)
return (partialValue, overflow: overflow)
}
}

extension BinaryInteger {
@inlinable
@available(swift, obsoleted: 3.2,
message: "Please use FixedWidthInteger protocol as a generic constraint and addingReportingOverflow(_:) method instead.")
public static func addWithOverflow(
_ lhs: Self, _ rhs: Self
) -> (Self, overflow: Bool) {
fatalError("Unavailable")
}

@inlinable
@available(swift, obsoleted: 3.2,
message: "Please use FixedWidthInteger protocol as a generic constraint and subtractingReportingOverflow(_:) method instead.")
public static func subtractWithOverflow(
_ lhs: Self, _ rhs: Self
) -> (Self, overflow: Bool) {
fatalError("Unavailable")
}

@inlinable
@available(swift, obsoleted: 3.2,
message: "Please use FixedWidthInteger protocol as a generic constraint and multipliedReportingOverflow(by:) method instead.")
public static func multiplyWithOverflow(
_ lhs: Self, _ rhs: Self
) -> (Self, overflow: Bool) {
fatalError("Unavailable")
}

@inlinable
@available(swift, obsoleted: 3.2,
message: "Please use FixedWidthInteger protocol as a generic constraint and dividedReportingOverflow(by:) method instead.")
public static func divideWithOverflow(
_ lhs: Self, _ rhs: Self
) -> (Self, overflow: Bool) {
fatalError("Unavailable")
}

@inlinable
@available(swift, obsoleted: 3.2,
message: "Please use FixedWidthInteger protocol as a generic constraint and remainderReportingOverflow(dividingBy:) method instead.")
public static func remainderWithOverflow(
_ lhs: Self, _ rhs: Self
) -> (Self, overflow: Bool) {
fatalError("Unavailable")
}
}

// FIXME(integers): Absence of &+ causes ambiguity in the code like the
// following:
// func f<T : SignedInteger>(_ x: T, _ y: T) {
Expand All @@ -3720,24 +3581,10 @@ extension SignedInteger {
fatalError("Should be overridden in a more specific type")
}

@_transparent
@available(swift, obsoleted: 4.0,
message: "Please use 'FixedWidthInteger' instead of 'SignedInteger' to get '&+' in generic code.")
public static func &+ (lhs: Self, rhs: Self) -> Self {
return _maskingAdd(lhs, rhs)
}

@_transparent
public static func _maskingSubtract(_ lhs: Self, _ rhs: Self) -> Self {
fatalError("Should be overridden in a more specific type")
}

@_transparent
@available(swift, obsoleted: 4.0,
message: "Please use 'FixedWidthInteger' instead of 'SignedInteger' to get '&-' in generic code.")
public static func &- (lhs: Self, rhs: Self) -> Self {
return _maskingSubtract(lhs, rhs)
}
}

extension SignedInteger where Self : FixedWidthInteger {
Expand Down
32 changes: 0 additions & 32 deletions stdlib/public/core/MigrationSupport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -244,26 +244,6 @@ extension String.UnicodeScalarView : _CustomPlaygroundQuickLookable {
}

//===--- Slicing Support --------------------------------------------------===//
// In Swift 3.2, in the absence of type context,
//
// someString.unicodeScalars[
// someString.unicodeScalars.startIndex
// ..< someString.unicodeScalars.endIndex]
//
// was deduced to be of type `String.UnicodeScalarView`. Provide a
// more-specific Swift-3-only `subscript` overload that continues to produce
// `String.UnicodeScalarView`.
extension String.UnicodeScalarView {
@available(swift, obsoleted: 4)
public subscript(bounds: Range<Index>) -> String.UnicodeScalarView {
Builtin.unreachable()
}

@available(swift, obsoleted: 4)
public subscript(bounds: ClosedRange<Index>) -> String.UnicodeScalarView {
Builtin.unreachable()
}
}

// @available(swift,deprecated: 5.0, renamed: "Unicode.UTF8")
public typealias UTF8 = Unicode.UTF8
Expand Down Expand Up @@ -327,11 +307,6 @@ extension Substring {
_precondition(range.upperBound <= endIndex,
"String index range is out of bounds")
}

@available(swift, obsoleted: 4)
public subscript(bounds: ClosedRange<Index>) -> String {
Builtin.unreachable()
}
}

extension Substring : _CustomPlaygroundQuickLookable {
Expand Down Expand Up @@ -567,13 +542,6 @@ extension Sequence {
) rethrows -> [ElementOfResult] {
return try _compactMap(transform)
}

@available(swift, obsoleted: 4)
public func flatMap(
_ transform: (Element) throws -> String
) rethrows -> [String] {
return try map(transform)
}
}

extension Collection {
Expand Down
Loading