You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Deprecating + and - for SignedInteger and its Stride (#6603)
* Removing uses of mixed-type + and - in benchmarks
Using type cast or explicit type annotations.
* Deprecating use of + and - on SignedInteger
As it leads to mixed type arithmetics that is not supposed to work.
It was needed before the new collection indexing model to make moving
indexes simple.
* Test deprecation warning
public func + <T : Strideable>(lhs: T, rhs: T.Stride) -> T {
65
+
% for Base in ['Strideable', 'SignedInteger']:
66
+
% deprecated = Base == 'SignedInteger'
67
+
% # FIXME: technically the deprecation version is incorrect and should be 3.1
68
+
% # instead but due to <rdar://problem/29884401> it does not work as
69
+
% # expected.
70
+
% DeprecationVersion = '3.0'
71
+
72
+
% if deprecated:
73
+
@available(swift, deprecated: ${DeprecationVersion}, obsoleted: 4.0, message: "Mixed-type addition is deprecated. Please use explicit type conversion.")
74
+
% end
75
+
public func + <T : ${Base}>(lhs: T, rhs: T.Stride) -> T {
66
76
return lhs.advanced(by: rhs)
67
77
}
68
78
69
-
public func + <T : Strideable>(lhs: T.Stride, rhs: T) -> T {
79
+
% if deprecated:
80
+
@available(swift, deprecated: ${DeprecationVersion}, obsoleted: 4.0, message: "Mixed-type addition is deprecated. Please use explicit type conversion.")
81
+
% end
82
+
public func + <T : ${Base}>(lhs: T.Stride, rhs: T) -> T {
70
83
return rhs.advanced(by: lhs)
71
84
}
72
85
73
-
public func - <T : Strideable>(lhs: T, rhs: T.Stride) -> T {
86
+
% if deprecated:
87
+
@available(swift, deprecated: ${DeprecationVersion}, obsoleted: 4.0, message: "Mixed-type subtraction is deprecated. Please use explicit type conversion.")
88
+
% end
89
+
public func - <T : ${Base}>(lhs: T, rhs: T.Stride) -> T {
@available(swift, deprecated: ${DeprecationVersion}, obsoleted: 4.0, message: "Mixed-type subtraction is deprecated. Please use explicit type conversion.")
@available(swift, deprecated: ${DeprecationVersion}, obsoleted: 4.0, message: "Mixed-type addition is deprecated. Please use explicit type conversion.")
@available(swift, deprecated: ${DeprecationVersion}, obsoleted: 4.0, message: "Mixed-type subtraction is deprecated. Please use explicit type conversion.")
0 commit comments