Implementing arithmetic operators on NSDecimal, CGFloat, and concrete FP types

This commit is contained in:
Max Moiseev
2017-01-23 10:59:24 -08:00
parent 871d1a2805
commit 1265f0792a
4 changed files with 115 additions and 2 deletions

View File

@@ -1003,7 +1003,10 @@ ${mutatingOperationComment(x.operator)}
% end
}
% for Protocol in ['Arithmetic']:#, 'BinaryInteger', 'FloatingPoint']:
% # FIXME(integers): uncomment once the compilation time improves.
% # Don't forget to remove similar definitions from concrete integer types,
% # floating point types, CGFloat, and Decimal in Foundation.
% for Protocol in []: # !!! FIXME !!! ['Arithmetic', 'BinaryInteger', 'FloatingPoint']:
% # Explicitly providing these operations for BinaryInteger and FloatingPoint
% # protocols because Strideable conformance creates ambiguity if the
% # operationsare only defined for Arithmetic
@@ -2552,7 +2555,7 @@ public struct ${Self}
// gets defined on the protocol rather than on concrete type.
% for x in chain(*binaryArithmetic.values()):
@_transparent
public static func ${x.operator}(_ lhs: ${Self}, _ rhs: ${Self}) -> ${Self} {
public static func ${x.operator}(lhs: ${Self}, rhs: ${Self}) -> ${Self} {
var lhs = lhs
lhs ${x.operator}= rhs
return lhs