Skip to content

Commit 32feae5

Browse files
authored
Marking .abs() method for floating point types as obsolete in Swift 4 (#5810)
* Marking .abs() method for floating point types as obsolete in Swift 4 ...and deprecated in Swift 3.1
1 parent 7536b94 commit 32feae5

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,9 +336,10 @@ extension CGFloat {
336336
fatalError("unavailable")
337337
}
338338

339-
@available(*, unavailable, message: "Please use the `abs(_:)` free function")
339+
@available(swift, deprecated: 3.1, obsoleted: 4.0, message: "Please use the `abs(_:)` free function")
340+
@_transparent
340341
public static func abs(_ x: CGFloat) -> CGFloat {
341-
fatalError("unavailable")
342+
return x.magnitude
342343
}
343344
}
344345

stdlib/public/core/FloatingPointTypes.swift.gyb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,9 +1056,10 @@ public postfix func -- (lhs: inout ${Self}) -> ${Self} {
10561056
}
10571057

10581058
extension ${Self} {
1059-
@available(*, unavailable, message: "Please use the `abs(_:)` free function")
1059+
@available(swift, deprecated: 3.1, obsoleted: 4.0, message: "Please use the `abs(_:)` free function")
1060+
@_transparent
10601061
public static func abs(_ x: ${Self}) -> ${Self} {
1061-
fatalError("unavailable")
1062+
return x.magnitude
10621063
}
10631064
}
10641065

test/api-digester/source-stability.swift.expected

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,5 @@ Protocol MutableIndexable has been removed (deprecated)
77
Protocol RandomAccessIndexable has been removed (deprecated)
88
Protocol RangeReplaceableIndexable has been removed (deprecated)
99

10-
/* Moved declarations */
11-
// rdar://28456614 Swift 3 breaking change: static function 'abs' removed from Double/Float/Float80/CGFloat
12-
Func Double.abs(_:) has been moved to Func abs(_:)
13-
Func Float.abs(_:) has been moved to Func abs(_:)
14-
Func Float80.abs(_:) has been moved to Func abs(_:)
15-
1610
/* Function type change */
1711
Func UnsafePointer.withMemoryRebound(to:capacity:_:) has 3rd parameter type change from (UnsafeMutablePointer<T>) throws -> Result to (UnsafePointer<T>) throws -> Result

0 commit comments

Comments
 (0)