Skip to content

Commit 61d1ab9

Browse files
committed
[Standard library] Reintroduce operator declarations for pre/postfix ++/--.
The removal of these operator declarations caused a source compatibility break, because some Swift code is defining prefix or postfix ++/-- functions without defining the ++ or -- operators. Reinstate the operator declarations in the standard library... but not any of the functions. Fixes rdar://problem/43258773.
1 parent 574b7f4 commit 61d1ab9

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

stdlib/public/core/Policy.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,8 @@ precedencegroup BitwiseShiftPrecedence {
390390
//===----------------------------------------------------------------------===//
391391

392392
// Standard postfix operators.
393+
postfix operator ++
394+
postfix operator --
393395
postfix operator ...
394396

395397
// Optional<T> unwrapping operator is built into the compiler as a part of
@@ -398,6 +400,8 @@ postfix operator ...
398400
// postfix operator !
399401

400402
// Standard prefix operators.
403+
prefix operator ++
404+
prefix operator --
401405
prefix operator !
402406
prefix operator ~
403407
prefix operator +

test/Compatibility/operators.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: %target-typecheck-verify-swift -swift-version 4
2+
3+
// expect-no-diagnostics
4+
5+
struct X { }
6+
7+
postfix func ++(x: X) -> X { return x }
8+
prefix func ++(x: X) -> X { return x }
9+
postfix func --(x: X) -> X { return x }
10+
prefix func --(x: X) -> X { return x }

0 commit comments

Comments
 (0)