Skip to content

Commit 74333db

Browse files
author
Max Moiseev
committed
Marking .abs() method for floating point types as obsolete in Swift 4
...and deprecated in Swift 3.1
1 parent 0773731 commit 74333db

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

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

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

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

stdlib/public/core/FloatingPointTypes.swift.gyb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,9 +1056,11 @@ 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, message: "Please use the `abs(_:)` free function")
1060+
@available(swift, obsoleted: 4.0, message: "Please use the `abs(_:)` free function")
1061+
@_transparent
10601062
public static func abs(_ x: ${Self}) -> ${Self} {
1061-
fatalError("unavailable")
1063+
return x.magnitude
10621064
}
10631065
}
10641066

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)