Skip to content

Commit 9e76ee0

Browse files
authored
Merge pull request #4112 from apple/remove-integers-from-3.0-branch
Remove integers from 3.0 branch
2 parents 95463a8 + bfec67d commit 9e76ee0

File tree

11 files changed

+1935
-767
lines changed

11 files changed

+1935
-767
lines changed

benchmark/single-source/MonteCarloE.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ public func run_MonteCarloE(scale: Int) {
3333
"Incorrect results in MonteCarloE: no empty intervals.")
3434
let e_estimate = Double(N)/Double(numEmptyIntervals)
3535
let e = 2.71828
36-
CheckResults(abs(e_estimate - e) < 0.1,
36+
CheckResults(Double.abs(e_estimate - e) < 0.1,
3737
"Incorrect results in MonteCarloE: e_estimate == \(e_estimate)")
3838
}

benchmark/single-source/MonteCarloPi.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ public func run_MonteCarloPi(scale: Int) {
2525
}
2626
let pi_estimate: Double = Double(pointsInside)*4.0/Double(N)
2727
let pi = 3.1415
28-
CheckResults(abs(pi_estimate - pi) < 0.1,
28+
CheckResults(Double.abs(pi_estimate - pi) < 0.1,
2929
"Incorrect results in MonteCarloPi: pi_estimate == \(pi_estimate)")
3030
}

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ public struct CGFloat {
174174
return CGFloat(native.nextUp)
175175
}
176176

177-
public var magnitude: CGFloat {
178-
return CGFloat(abs(native))
177+
public static func abs(_ x: CGFloat) -> CGFloat {
178+
return CGFloat(NativeType.abs(x.native))
179179
}
180180

181181
public mutating func negate() {
@@ -296,11 +296,6 @@ extension CGFloat {
296296
public static var max: CGFloat {
297297
fatalError("unavailable")
298298
}
299-
300-
@available(*, unavailable, message: "Please use the `abs(_:)` free function")
301-
public static func abs(_ x: CGFloat) -> CGFloat {
302-
fatalError("unavailable")
303-
}
304299
}
305300

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

stdlib/public/core/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ set(SWIFTLIB_ESSENTIAL
7070
InputStream.swift
7171
IntegerArithmetic.swift.gyb
7272
IntegerParsing.swift.gyb
73-
Integers.swift.gyb
7473
Join.swift
7574
LazyCollection.swift.gyb
7675
LazySequence.swift

stdlib/public/core/FloatingPoint.swift.gyb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ word_bits = int(CMAKE_SIZEOF_VOID_P) * 8
167167
/// print("Average: \(average)°F in \(validTemps.count) " +
168168
/// "out of \(tempsFahrenheit.count) observations.")
169169
/// // Prints "Average: 74.84°F in 5 out of 7 observations."
170-
public protocol FloatingPoint: Comparable, Arithmetic,
171-
SignedNumber, Strideable {
170+
public protocol FloatingPoint: Comparable, ExpressibleByIntegerLiteral,
171+
SignedNumber, AbsoluteValuable, Strideable {
172172

173173
/// A type that can represent any written exponent.
174174
associatedtype Exponent: SignedInteger
@@ -1954,11 +1954,5 @@ extension BinaryFloatingPoint {
19541954
*/
19551955
}
19561956

1957-
/// Returns the absolute value of `x`.
1958-
@_transparent
1959-
public func abs<T : FloatingPoint>(_ x: T) -> T where T.Magnitude == T {
1960-
return x.magnitude
1961-
}
1962-
19631957
@available(*, unavailable, renamed: "FloatingPoint")
19641958
public typealias FloatingPointType = FloatingPoint

stdlib/public/core/FloatingPointTypes.swift.gyb

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ extension ${Self} : Hashable {
808808
}
809809
}
810810

811-
extension ${Self} : Arithmetic {
811+
extension ${Self} : AbsoluteValuable {
812812
/// The magnitude of this value.
813813
///
814814
/// For any value `x`, `x.magnitude.sign` is `.plus`. If `x` is not NaN,
@@ -832,8 +832,8 @@ extension ${Self} : Arithmetic {
832832
///
833833
/// - SeeAlso: `abs(_:)`
834834
@_transparent
835-
public var magnitude: ${Self} {
836-
return ${Self}(_bits: Builtin.int_fabs_FPIEEE${bits}(_value))
835+
public static func abs(_ x: ${Self}) -> ${Self} {
836+
return ${Self}(_bits: Builtin.int_fabs_FPIEEE${bits}(x._value))
837837
}
838838
}
839839

@@ -1126,13 +1126,4 @@ extension ${Self} {
11261126
% end
11271127
% end
11281128
}
1129-
1130-
1131-
extension ${Self} {
1132-
@available(*, unavailable, message: "Please use the `abs(_:)` free function")
1133-
public static func abs(_ x: ${Self}) -> ${Self} {
1134-
fatalError("unavailable")
1135-
}
1136-
}
1137-
11381129
% end # for (bits, signed) in allInts()

stdlib/public/core/GroupInfo.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@
102102
"BuiltinMath.swift",
103103
{
104104
"Integers": [
105-
"Integers.swift",
106105
"IntegerArithmetic.swift",
107106
"FixedPoint.swift",
108107
"IntegerParsing.swift"],

0 commit comments

Comments
 (0)