Files
swift-mirror/validation-test/stdlib/BoolDiagnostics.swift
Dmitri Hrybenko bbf79427ac stdlib: remove bitwise operations on Bool
Bitwise operations on Bool are redundant with other logic operations
that stdlib already provides.  The only reason to have them was to avoid
branching in the short-circuiting && and ||.

rdar://19340952

Surprisingly, replacing & and | in the standard library with && and ||
brought performance improvements and no significant performance
regressions:

RecursiveOwnedParameter 1.14
SelectionSort 1.19

Swift SVN r24674
2015-01-23 03:09:55 +00:00

13 lines
687 B
Swift

// RUN: %target-parse-verify-swift
func test_removedOperators(a: Bool, b: Bool) {
var t1 = ~a // expected-error {{'~' is unavailable: use the '!' operator instead}}
var t2 = a & b // expected-error {{'&' is unavailable: use the '&&' operator instead}}
var t3 = a | b // expected-error {{'|' is unavailable: use the '||' operator instead}}
var t4 = a ^ b // expected-error {{'^' is unavailable: use the '!=' operator instead}}
t4 &= a // expected-error {{'&=' is unavailable: use the '&&' operator instead}}
t4 |= a // expected-error {{'|=' is unavailable: use the '||' operator instead}}
t4 ^= a // expected-error {{'^=' is unavailable: use the '!=' operator instead}}
}