Skip to content

Commit 225a26d

Browse files
committed
[Stdlib] Don't redeclare the Magnitude associated type unnecessarily.
Just use a where clause on the protocol to add requirements.
1 parent de66b0c commit 225a26d

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

stdlib/public/core/Integers.swift.gyb

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2348,11 +2348,8 @@ ${operatorComment('&' + x.operator, True)}
23482348
//===----------------------------------------------------------------------===//
23492349

23502350
/// An integer type that can represent only nonnegative values.
2351-
public protocol UnsignedInteger : BinaryInteger {
2352-
/// A type that can represent the absolute value of any possible value of the
2353-
/// conforming type.
2354-
associatedtype Magnitude : BinaryInteger
2355-
}
2351+
public protocol UnsignedInteger : BinaryInteger
2352+
where Magnitude : BinaryInteger { }
23562353

23572354
extension UnsignedInteger {
23582355
/// The magnitude of this value.
@@ -2458,11 +2455,8 @@ extension UnsignedInteger where Self : FixedWidthInteger {
24582455
//===----------------------------------------------------------------------===//
24592456

24602457
/// An integer type that can represent both positive and negative values.
2461-
public protocol SignedInteger : BinaryInteger, SignedNumeric {
2462-
/// A type that can represent the absolute value of any possible value of the
2463-
/// conforming type.
2464-
associatedtype Magnitude : BinaryInteger
2465-
2458+
public protocol SignedInteger : BinaryInteger, SignedNumeric
2459+
where Magnitude : BinaryInteger {
24662460
// These requirements are for the source code compatibility with Swift 3
24672461
static func _maskingAdd(_ lhs: Self, _ rhs: Self) -> Self
24682462
static func _maskingSubtract(_ lhs: Self, _ rhs: Self) -> Self

0 commit comments

Comments
 (0)